Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6d5d045f1 | ||
|
|
74bca8966b | ||
|
|
1772cf6f7e | ||
|
|
cefc4473e5 |
@@ -12,7 +12,7 @@ BME280 bme280;
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Firmware Version */
|
/* Firmware Version */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
static const int32_t fwVersion = 20210423;
|
static const int32_t fwVersion = 20210427;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* LoraWAN Settings */
|
/* LoraWAN Settings */
|
||||||
@@ -850,12 +850,14 @@ void AddSensorDataToLoraData()
|
|||||||
timer_pos0 = millis();
|
timer_pos0 = millis();
|
||||||
}
|
}
|
||||||
my_position++;
|
my_position++;
|
||||||
|
|
||||||
last_sensor_reading = sensor_data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TooBigWeightChange()
|
bool TooBigWeightChange()
|
||||||
{
|
{
|
||||||
|
// on first position there cannot be a difference
|
||||||
|
if (my_position == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool big_difference = (abs(last_sensor_reading.weight - sensor_data.weight) > SEND_DIFF_THRESHOLD_5GRAMS);
|
bool big_difference = (abs(last_sensor_reading.weight - sensor_data.weight) > SEND_DIFF_THRESHOLD_5GRAMS);
|
||||||
if (big_difference) {
|
if (big_difference) {
|
||||||
lora_data.weight_last = sensor_data.weight;
|
lora_data.weight_last = sensor_data.weight;
|
||||||
@@ -907,6 +909,7 @@ bool ReadSensors(bool read_only)
|
|||||||
if (!read_only) {
|
if (!read_only) {
|
||||||
AddSensorDataToLoraData();
|
AddSensorDataToLoraData();
|
||||||
send_data = (TooBigWeightChange()) || (my_position >= MAX_VALUES_TO_SEND) || (iteration <= INIT_PACKETS) || (iteration % INIT_PACKAGE_INTERVAL == 0);
|
send_data = (TooBigWeightChange()) || (my_position >= MAX_VALUES_TO_SEND) || (iteration <= INIT_PACKETS) || (iteration % INIT_PACKAGE_INTERVAL == 0);
|
||||||
|
last_sensor_reading = sensor_data;
|
||||||
|
|
||||||
if (config_data.debug_level > 0) {
|
if (config_data.debug_level > 0) {
|
||||||
if (send_data) {
|
if (send_data) {
|
||||||
|
|||||||
@@ -22,11 +22,13 @@ Das sind die verwendeten Libraries [1]:
|
|||||||
|
|
||||||
| URL | Branch | Commit | Commit Date |
|
| URL | Branch | Commit | Commit Date |
|
||||||
| --- | ------ | ----- | ----------- |
|
| --- | ------ | ----- | ----------- |
|
||||||
| https://github.com/HelTecAutomation/CubeCell-Arduino.git | 68b01ab | Fri, 16 Apr 2021 17:59:03 +0800 |
|
| https://github.com/HelTecAutomation/CubeCell-Arduino.git | 58ed094 | Mon, 26 Apr 2021 09:48:49 +0800 |
|
||||||
| https://github.com/sparkfun/SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.git | master | 688f255 | Fri, 3 Jan 2020 12:35:22 -0700 |
|
| https://github.com/sparkfun/SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.git | master | 688f255 | Fri, 3 Jan 2020 12:35:22 -0700 |
|
||||||
| https://github.com/sparkfun/SparkFun_BME280_Arduino_Library.git | master | 0b5eabf | Wed, 30 Dec 2020 20:44:27 -0700 |
|
| https://github.com/sparkfun/SparkFun_BME280_Arduino_Library.git | master | 0b5eabf | Wed, 30 Dec 2020 20:44:27 -0700 |
|
||||||
|
|
||||||
|
`
|
||||||
[1]: echo "| $(git remote -v |grep fetch |awk '{print $2}' |tr '\n' ' ') | $(git log --pretty=format:'%h | %cD ' -n 1) |"
|
[1]: echo "| $(git remote -v |grep fetch |awk '{print $2}' |tr '\n' ' ') | $(git log --pretty=format:'%h | %cD ' -n 1) |"
|
||||||
|
`
|
||||||
|
|
||||||
## Wir verwenden arduino-cli
|
## Wir verwenden arduino-cli
|
||||||
|
|
||||||
@@ -46,9 +48,24 @@ $ arduino-cli core install CubeCell:CubeCell
|
|||||||
$ arduino-cli core list
|
$ arduino-cli core list
|
||||||
|
|
||||||
Compile:
|
Compile:
|
||||||
$ arduino-cli compile --fqbn CubeCell:CubeCell:CubeCell-Board MiniBeieliNodeSketch
|
$ arduino-cli compile --fqbn CubeCell:CubeCell:CubeCell-Board \
|
||||||
|
--build-property "build.band=REGION_EU868" \
|
||||||
|
--build-property "build.LORAWAN_CLASS=CLASS_A" \
|
||||||
|
--build-property "build.LORAWAN_CLASS=CLASS_A" \
|
||||||
|
--build-property "build.LORAWAN_DEVEUI_AUTO=0" \
|
||||||
|
--build-property "build.LORAWAN_NETMODE=true" \
|
||||||
|
--build-property "build.LORAWAN_ADR=true" \
|
||||||
|
--build-property "build.LORAWAN_UPLINKMODE=false" \
|
||||||
|
--build-property "build.LORAWAN_Net_Reserve=false" \
|
||||||
|
--build-property "build.LORAWAN_AT_SUPPORT=1" \
|
||||||
|
--build-property "build.RGB=0" \
|
||||||
|
--build-property "build.LORAWAN_DebugLevel=0" \
|
||||||
|
MiniBeieliNodeSketch
|
||||||
|
|
||||||
|
Output ist in /tmp/arduino-sketch-XXXXXXXXXXXXXXXXXXXXXXXXX und kann kopiert werden:
|
||||||
|
$ mkdir ~/arduino-builds-saved/20210423/
|
||||||
|
$ cp /tmp/arduino-sketch-0870BAA82DFEB3C4E076C8FBBDEB25B4/CubeCell_Board_REGION_EU868_RGB_0.cyacd ~/arduino-builds-saved/20210423/
|
||||||
|
|
||||||
Upload:
|
Upload:
|
||||||
$ arduino-cli board list
|
/home/joerg/Arduino/hardware/CubeCell/CubeCell/tools/CubeCellflash/CubeCellflash -serial /dev/ttyUSB0 /home/joerg/arduino-builds-saved/latest/CubeCell_Board_REGION_EU868_RGB_0.cyacd
|
||||||
$ arduino-cli upload -p /dev/ttyUSB0 --fqbn CubeCell:CubeCell:CubeCell-Board MiniBeieliNodeSketch
|
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -58,6 +58,51 @@ func readSerial(p *serial.Port) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getAppKey(deveui string) string {
|
||||||
|
if len(deveui) == 16 {
|
||||||
|
appkey := fmt.Sprintf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
|
||||||
|
deveui[10],
|
||||||
|
deveui[3],
|
||||||
|
deveui[4],
|
||||||
|
deveui[7],
|
||||||
|
deveui[15],
|
||||||
|
deveui[9],
|
||||||
|
deveui[11],
|
||||||
|
deveui[2],
|
||||||
|
deveui[0],
|
||||||
|
deveui[8],
|
||||||
|
deveui[1],
|
||||||
|
deveui[6],
|
||||||
|
deveui[5],
|
||||||
|
deveui[12],
|
||||||
|
deveui[14],
|
||||||
|
deveui[13],
|
||||||
|
deveui[3],
|
||||||
|
deveui[6],
|
||||||
|
deveui[12],
|
||||||
|
deveui[7],
|
||||||
|
deveui[15],
|
||||||
|
deveui[1],
|
||||||
|
deveui[9],
|
||||||
|
deveui[11],
|
||||||
|
deveui[2],
|
||||||
|
deveui[10],
|
||||||
|
deveui[0],
|
||||||
|
deveui[8],
|
||||||
|
deveui[5],
|
||||||
|
deveui[14],
|
||||||
|
deveui[4],
|
||||||
|
deveui[13])
|
||||||
|
|
||||||
|
fmt.Printf("calculated AppKey: %s\n", appkey)
|
||||||
|
return appkey
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fmt.Printf("devEui has wrong length: %s\n", deveui)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) != 3 {
|
if len(os.Args) != 3 {
|
||||||
fmt.Println("usage: " + filepath.Base(os.Args[0]) + " <SerialDevice> <appEui>")
|
fmt.Println("usage: " + filepath.Base(os.Args[0]) + " <SerialDevice> <appEui>")
|
||||||
@@ -75,10 +120,11 @@ func main() {
|
|||||||
|
|
||||||
sendCommand(s, "AT+XXX")
|
sendCommand(s, "AT+XXX")
|
||||||
devEui := getDevEui(s)
|
devEui := getDevEui(s)
|
||||||
|
appKey := getAppKey(devEui)
|
||||||
if devEui != "" {
|
if devEui != "" {
|
||||||
sendCommand(s, "AT+DevEui="+devEui)
|
sendCommand(s, "AT+DevEui="+devEui)
|
||||||
sendCommand(s, "AT+AppEui="+appEui)
|
sendCommand(s, "AT+AppEui="+appEui)
|
||||||
sendCommand(s, "AT+AppKey="+devEui+devEui)
|
sendCommand(s, "AT+AppKey="+appKey)
|
||||||
sendCommand(s, "AT+SAVE_OTAA_CONFIG=1")
|
sendCommand(s, "AT+SAVE_OTAA_CONFIG=1")
|
||||||
sendCommand(s, "AT+RESET=1")
|
sendCommand(s, "AT+RESET=1")
|
||||||
readSerial(s)
|
readSerial(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user