From 9f2a56cce576c1547a57d8d9b8b4f5446712e8d3 Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Mon, 29 Jan 2024 19:44:35 +0100 Subject: [PATCH 1/8] clean up more --- .github/workflows/buildproject.yml | 4 ++ .gitignore | 1 + .travis.yml | 67 ----------------------------- src/{config.h => config.h.template} | 52 +++++++++++----------- src/fromV08.ino.cpp | 3 +- test/README | 11 ----- 6 files changed, 33 insertions(+), 105 deletions(-) delete mode 100644 .travis.yml rename src/{config.h => config.h.template} (98%) delete mode 100644 test/README diff --git a/.github/workflows/buildproject.yml b/.github/workflows/buildproject.yml index df83677..d552d84 100644 --- a/.github/workflows/buildproject.yml +++ b/.github/workflows/buildproject.yml @@ -19,6 +19,10 @@ jobs: python-version: '3.9' - name: Install PlatformIO Core run: pip install --upgrade platformio + + - name: Copy the config template + run: | + cp "./src/config.h.template" "./src/config.h" - name: Build PlatformIO Project run: pio run diff --git a/.gitignore b/.gitignore index 53dea31..43e7562 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ dkms.conf .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +src/config.h diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a8bbc57..0000000 --- a/.travis.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Continuous Integration (CI) is the practice, in software -# engineering, of merging all developer working copies with a shared mainline -# several times a day < https://docs.platformio.org/page/ci/index.html > -# -# Documentation: -# -# * Travis CI Embedded Builds with PlatformIO -# < https://docs.travis-ci.com/user/integration/platformio/ > -# -# * PlatformIO integration with Travis CI -# < https://docs.platformio.org/page/ci/travis.html > -# -# * User Guide for `platformio ci` command -# < https://docs.platformio.org/page/userguide/cmd_ci.html > -# -# -# Please choose one of the following templates (proposed below) and uncomment -# it (remove "# " before each line) or use own configuration according to the -# Travis CI documentation (see above). -# - - -# -# Template #1: General project. Test it using existing `platformio.ini`. -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio run - - -# -# Template #2: The project is intended to be used as a library with examples. -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# env: -# - PLATFORMIO_CI_SRC=path/to/test/file.c -# - PLATFORMIO_CI_SRC=examples/file.ino -# - PLATFORMIO_CI_SRC=path/to/test/directory -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/src/config.h b/src/config.h.template similarity index 98% rename from src/config.h rename to src/config.h.template index d85ef6d..d107c27 100644 --- a/src/config.h +++ b/src/config.h.template @@ -1,26 +1,26 @@ -// Using ABP for now. -//#define OTAA - -#ifndef LORA_TTNMAPPER_TBEAM_CONFIG_INCLUDED -#define LORA_TTNMAPPER_TBEAM_CONFIG_INCLUDED - -#define CFG_eu868 1 - -#ifndef OTAA -// UPDATE WITH YOUR TTN KEYS AND ADDR. -// Setting for ABP -static PROGMEM u1_t NWKSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // LoRaWAN NwkSKey, network session key -static u1_t PROGMEM APPSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // LoRaWAN AppSKey, application session key -static const u4_t DEVADDR = 0x00000000; // LoRaWAN end-device address (DevAddr) -#else -// Settings from OTAA device (not used) -static const u1_t PROGMEM DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ; // Device EUI, hex, lsb -static const u1_t PROGMEM APPEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Application EUI, hex, lsb -static const u1_t PROGMEM APPKEY[16] = { 0x12, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01 }; // App Key, hex, msb - -void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} -void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} -void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} -#endif - -#endif //LORA_TTNMAPPER_TBEAM_CONFIG_INCLUDED +// Using ABP for now. +//#define OTAA + +#ifndef LORA_TTNMAPPER_TBEAM_CONFIG_INCLUDED +#define LORA_TTNMAPPER_TBEAM_CONFIG_INCLUDED + +#define CFG_eu868 1 + +#ifndef OTAA +// UPDATE WITH YOUR TTN KEYS AND ADDR. +// Setting for ABP +static PROGMEM u1_t NWKSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // LoRaWAN NwkSKey, network session key +static u1_t PROGMEM APPSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // LoRaWAN AppSKey, application session key +static const u4_t DEVADDR = 0x00000000; // LoRaWAN end-device address (DevAddr) +#else +// Settings from OTAA device (not used) +static const u1_t PROGMEM DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ; // Device EUI, hex, lsb +static const u1_t PROGMEM APPEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Application EUI, hex, lsb +static const u1_t PROGMEM APPKEY[16] = { 0x12, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01 }; // App Key, hex, msb + +void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} +void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} +void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} +#endif + +#endif //LORA_TTNMAPPER_TBEAM_CONFIG_INCLUDED diff --git a/src/fromV08.ino.cpp b/src/fromV08.ino.cpp index 47c570e..ac0cbf1 100644 --- a/src/fromV08.ino.cpp +++ b/src/fromV08.ino.cpp @@ -494,11 +494,12 @@ void loop() { gps.encode(); sf_select(); + os_runloop_once(); + if (lastMillis + 1000 < millis()) { lastMillis = millis(); VBAT = axp.getBattVoltage() / 1000; - os_runloop_once(); if (gps.checkGpsFix()) { GPSonceFixed = true; noFix = false; diff --git a/test/README b/test/README deleted file mode 100644 index c3b0ed6..0000000 --- a/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PIO Unit Testing and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PIO Unit Testing: -- https://docs.platformio.org/page/plus/unit-testing.html From 8b883d04e9cbae067f1449d9c3c684bf98f79161 Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Mon, 29 Jan 2024 19:48:54 +0100 Subject: [PATCH 2/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8c1440..7e97f9a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The forked repo from hottimuc was converted to a PlatformIO project (currently f ## Instructions -Copy all from here locally, open it with PlatformIO, modify the config.h with your ABP credentials and upload. +Copy all from here locally, open it with PlatformIO, rename **config.h.template** to **config.h** and fill with your ABP credentials. Then upload it to the T-Beam. On The Things Network side, the settings needed are available [here](https://www.thethingsnetwork.org/docs/applications/ttnmapper/). From c1b894abadc22b8c751197a3e0096a8078b8b8e8 Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Mon, 29 Jan 2024 19:53:30 +0100 Subject: [PATCH 3/8] Update spell_check.yml --- .github/workflows/spell_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index b2d651b..37fb2ec 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -16,4 +16,4 @@ jobs: # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md - name: Spell check - uses: codespell-project/actions-codespell@master \ No newline at end of file + uses: codespell-project/actions-codespell@v2 From e257996c98323cbf31cb4c2c41e76fb391961edb Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Sat, 24 Feb 2024 17:33:56 +0100 Subject: [PATCH 4/8] set gps serial speed to 115200 changes the gps module config --- src/gps.cpp | 130 ++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 59 deletions(-) diff --git a/src/gps.cpp b/src/gps.cpp index 7997366..ec8196d 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -2,97 +2,109 @@ HardwareSerial GPSSerial(1); -void gps::init() -{ +void gps::init() { + GPSSerial.setRxBufferSize(2048); // Default is 256 GPSSerial.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX); GPSSerial.setTimeout(2); + + // CFG-PRT to 115200 Baudrate + byte packet[] = { + 0xB5, // sync char 1 + 0x62, // sync char 2 + 0x06, // class + 0x00, // id + 0x14, // length + 0x00, // + 0x01, // payload + 0x00, // payload + 0x00, // payload + 0x00, // payload + 0xD0, // payload + 0x08, // payload + 0x00, // payload + 0x00, // payload + 0x00, // payload + 0xC2, // payload + 0x01, // payload + 0x00, // payload + 0x07, // payload + 0x00, // payload + 0x03, // payload + 0x00, // payload + 0x00, // payload + 0x00, // payload + 0x00, // payload + 0x00, // payload + + 0xC0, // CK_A + 0x7E, // CK_B + }; + + for (byte i = 0; i < sizeof(packet); i++) + { + GPSSerial.write(packet[i]); + } + + delay(100); + GPSSerial.flush(); + GPSSerial.updateBaudRate(115200); } -void gps::encode() -{ - int data; - unsigned long previousMillis = millis(); - - while((previousMillis + 100) > millis()) - { - while (GPSSerial.available() ) - { - char data = GPSSerial.read(); - tGps.encode(data); - //Serial.print(data); - } +void gps::encode() { + int data; + unsigned long previousMillis = millis(); + + while ((previousMillis + 100) > millis()) { + while (GPSSerial.available()) { + char data = GPSSerial.read(); + tGps.encode(data); + //Serial.print(data); } - //Serial.println(""); + } + //Serial.println(""); } -void gps::buildPacket(uint8_t txBuffer[9]) -{ +void gps::buildPacket(uint8_t txBuffer[9]) { LatitudeBinary = ((tGps.location.lat() + 90) / 180.0) * 16777215; LongitudeBinary = ((tGps.location.lng() + 180) / 360.0) * 16777215; - + sprintf(t, "Lat: %f", tGps.location.lat()); Serial.println(t); - + sprintf(t, "Lng: %f", tGps.location.lng()); Serial.println(t); - - txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF; - txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF; + + txBuffer[0] = (LatitudeBinary >> 16) & 0xFF; + txBuffer[1] = (LatitudeBinary >> 8) & 0xFF; txBuffer[2] = LatitudeBinary & 0xFF; - txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF; - txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF; + txBuffer[3] = (LongitudeBinary >> 16) & 0xFF; + txBuffer[4] = (LongitudeBinary >> 8) & 0xFF; txBuffer[5] = LongitudeBinary & 0xFF; altitudeGps = tGps.altitude.meters(); - txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF; + txBuffer[6] = (altitudeGps >> 8) & 0xFF; txBuffer[7] = altitudeGps & 0xFF; - hdopGps = tGps.hdop.value()/10; + hdopGps = tGps.hdop.value() / 10; txBuffer[8] = hdopGps & 0xFF; } -void gps::gdisplay(uint16_t txBuffer2[5]) -{ +void gps::gdisplay(uint16_t txBuffer2[5]) { txBuffer2[0] = tGps.satellites.value(); txBuffer2[1] = tGps.speed.kmph(); txBuffer2[2] = tGps.course.deg(); txBuffer2[3] = tGps.altitude.meters(); - txBuffer2[4] = tGps.hdop.value()/10; + txBuffer2[4] = tGps.hdop.value() / 10; } -bool gps::checkGpsFix() -{ +bool gps::checkGpsFix() { encode(); - if (tGps.location.isValid() && - tGps.location.age() < 4000 && - tGps.hdop.isValid() && - tGps.hdop.value() <= 600 && - tGps.hdop.age() < 4000 && - tGps.altitude.isValid() && - tGps.altitude.age() < 4000 ) - { + if (tGps.location.isValid() && tGps.location.age() < 4000 && tGps.hdop.isValid() && tGps.hdop.value() <= 600 && tGps.hdop.age() < 4000 && tGps.altitude.isValid() && tGps.altitude.age() < 4000) { Serial.println("Valid gps Fix."); return true; - } - else - { - Serial.println("No gps Fix."); -// sprintf(t, "location valid: %i" , tGps.location.isValid()); -// Serial.println(t); -// sprintf(t, "location age: %i" , tGps.location.age()); -// Serial.println(t); -// sprintf(t, "hdop valid: %i" , tGps.hdop.isValid()); -// Serial.println(t); -// sprintf(t, "hdop age: %i" , tGps.hdop.age()); -// Serial.println(t); -// sprintf(t, "hdop: %i" , tGps.hdop.value()); -// Serial.println(t); -// sprintf(t, "altitude valid: %i" , tGps.altitude.isValid()); -// Serial.println(t); -// sprintf(t, "altitude age: %i" , tGps.altitude.age()); -// Serial.println(t); - + } else { + Serial.println("No gps Fix."); return false; } } From e167dd952a899e498b49bf594f98fd4270da4a3b Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Sat, 24 Feb 2024 21:38:52 +0100 Subject: [PATCH 5/8] min distance, shutdown, undervolt --- src/fromV08.ino.cpp | 60 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/src/fromV08.ino.cpp b/src/fromV08.ino.cpp index ac0cbf1..e763023 100644 --- a/src/fromV08.ino.cpp +++ b/src/fromV08.ino.cpp @@ -12,6 +12,18 @@ #include "Adafruit_GFX.h" #include "Adafruit_SSD1306.h" +#define MIN_DIST 10.0 // Minimum distance in meters from the last sent location before we send again. +#define STATIONARY_TX_INTERVAL (1 * 60) // Send one uplink at least once every N seconds + +// Below BATTERY_LOW_VOLTAGE, power off until USB power allows charging. +// The PMIC also has a (safety) turn-off at 2.6v, much lower than this setting. +// We use a conservative cutoff here since the battery will last longer if it's not repeatedly run to minimum. +// A new-condition 18650 cell gives around 9Wh (Molicell) when discharged to the absolute lowest 2.5v +// 8110mWh to 3.3v +// 8875mWh to 3.1v +// 9210mWh to 2.5v +#define BATTERY_LOW_VOLTAGE 3.3 + // T-Beam specific hardware #define SELECT_BTN 38 @@ -44,6 +56,12 @@ uint16_t txBuffer2[5]; gps gps; Preferences prefs; +float min_dist_moved = MIN_DIST; +double last_send_lat = 0; // Last known location +double last_send_lon = 0; // +double dist_moved = 0; // Distance in m from last uplink +unsigned long int last_send_ms = 0; // Time of last uplink + #ifndef OTAA // These callbacks are only used in over-the-air activation, so they are // left empty here (we cannot leave them out completely unless @@ -76,18 +94,19 @@ void do_send(osjob_t* j) { Serial.println(F("OP_TXRXPEND, not sending")); LoraStatus = "OP_TXRXPEND, not sending"; } else { - if (gps.checkGpsFix()) - //if (true) - { + if (gps.checkGpsFix() && ((dist_moved > min_dist_moved) || (millis() > (last_send_ms + STATIONARY_TX_INTERVAL)))) { // Prepare upstream data transmission at the next possible time. gps.buildPacket(txBuffer); + last_send_lat = gps.tGps.location.lat(); + last_send_lon = gps.tGps.location.lng(); + last_send_ms = millis(); LMIC_setTxData2(port, txBuffer, sizeof(txBuffer), 0); Serial.println(F("Packet queued")); axp.setChgLEDMode(ledMode); LoraStatus = "Packet queued"; } else { - //try again in 3 seconds - os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(3), do_send); + //try again in 2 seconds + os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(2), do_send); } } // Next TX is scheduled after TX_COMPLETE event. @@ -214,7 +233,6 @@ void sf_select() { } if (selection == 2) // Unused { - } if (selection == 3) // Change Port { @@ -332,6 +350,13 @@ void onEvent(ev_t ev) { } +// Power OFF -- does not return +void clean_shutdown(void) { + LMIC_shutdown(); // cleanly shutdown the radio + axp.setChgLEDMode(AXP20X_LED_OFF); // Surprisingly sticky if you don't set it + axp.shutdown(); // PMIC power off +} + void setup() { Serial.begin(115200); @@ -354,14 +379,15 @@ void setup() { axp.adc1Enable(AXP202_VBUS_CUR_ADC1, true); // activate power rails - axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA radio - axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS main power + axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA radio + axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS main power axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON); axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON); axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable only the short press IRQ axp.enableIRQ(AXP202_PEK_SHORTPRESS_IRQ, true); + axp.enableIRQ(AXP202_PEK_LONGPRESS_IRQ, true); axp.clearIRQ(); // read preferences @@ -489,6 +515,10 @@ void loop() { ledMode = AXP20X_LED_OFF; } } + if (axp.isPEKLongtPressIRQ()) { + // want to turn OFF + clean_shutdown(); + } axp.clearIRQ(); } @@ -500,8 +530,20 @@ void loop() { lastMillis = millis(); VBAT = axp.getBattVoltage() / 1000; + float charge_ma = axp.getBattChargeCurrent(); + + if (axp.isBatteryConnect() && VBAT < BATTERY_LOW_VOLTAGE && charge_ma < 99.0) { + Serial.println("Low Battery OFF"); + clean_shutdown(); + } + + if (gps.checkGpsFix()) { GPSonceFixed = true; + + // distance from last transmitted location + dist_moved = gps.tGps.distanceBetween(last_send_lat, last_send_lon, gps.tGps.location.lat(), gps.tGps.location.lng()); + noFix = false; gps.gdisplay(txBuffer2); float hdop = txBuffer2[4] / 10.0; @@ -522,7 +564,7 @@ void loop() { display.setCursor(0, 10); display.print("Speed: " + String(txBuffer2[1]) + " km/h"); display.setCursor(0, 20); - display.print("Course: " + String(txBuffer2[2]) + (char)247); + display.print("Dist: " + String(dist_moved) + "m"); display.setCursor(0, 30); display.print("Alt: " + String(txBuffer2[3]) + "m"); display.setCursor(0, 40); From 43aee72926bc897a0ed8baf214b36da6d3c11abf Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Mon, 26 Feb 2024 19:06:08 +0100 Subject: [PATCH 6/8] fix gps must be 115k --- src/fromV08.ino.cpp | 4 +++- src/gps.cpp | 16 ++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/fromV08.ino.cpp b/src/fromV08.ino.cpp index e763023..e84728e 100644 --- a/src/fromV08.ino.cpp +++ b/src/fromV08.ino.cpp @@ -94,7 +94,7 @@ void do_send(osjob_t* j) { Serial.println(F("OP_TXRXPEND, not sending")); LoraStatus = "OP_TXRXPEND, not sending"; } else { - if (gps.checkGpsFix() && ((dist_moved > min_dist_moved) || (millis() > (last_send_ms + STATIONARY_TX_INTERVAL)))) { + if (gps.checkGpsFix() && ((dist_moved > min_dist_moved) || (millis() > (last_send_ms + STATIONARY_TX_INTERVAL * 1000)))) { // Prepare upstream data transmission at the next possible time. gps.buildPacket(txBuffer); last_send_lat = gps.tGps.location.lat(); @@ -620,6 +620,8 @@ void loop() { } else { display.print("v"); } + display.setCursor(0, 0); + display.print("SAT: " + String(gps.tGps.satellites.value())); } redraw = true; } diff --git a/src/gps.cpp b/src/gps.cpp index ec8196d..c77bc21 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -4,7 +4,7 @@ HardwareSerial GPSSerial(1); void gps::init() { GPSSerial.setRxBufferSize(2048); // Default is 256 - GPSSerial.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX); + GPSSerial.begin(115200, SERIAL_8N1, GPS_TX, GPS_RX); GPSSerial.setTimeout(2); // CFG-PRT to 115200 Baudrate @@ -42,12 +42,12 @@ void gps::init() { for (byte i = 0; i < sizeof(packet); i++) { - GPSSerial.write(packet[i]); + //GPSSerial.write(packet[i]); } - delay(100); - GPSSerial.flush(); - GPSSerial.updateBaudRate(115200); + //delay(100); + //GPSSerial.flush(); + //GPSSerial.updateBaudRate(115200); } void gps::encode() { @@ -104,7 +104,11 @@ bool gps::checkGpsFix() { Serial.println("Valid gps Fix."); return true; } else { - Serial.println("No gps Fix."); + Serial.print("No gps Fix. "); + Serial.print(tGps.failedChecksum()); + Serial.print(" Failed Checksums, "); + Serial.print(tGps.charsProcessed()); + Serial.println(" Chars Ok"); return false; } } From 5624705d524e06fc6c2e94e1e5c5e3ad17d49d3d Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Mon, 26 Feb 2024 19:13:55 +0100 Subject: [PATCH 7/8] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7e97f9a..b4664b9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ * Working in 2024 with TTN V3. * T-Beam 1.0 in 868MHZ (yes that's an old one). * Only tested with Platformio in VScode. +* GPS set to 115k baud (must be done with u-center or so). +* TX window, only send if moved at least a configurable distance. +* Auto power off if battery is below a configurable voltage. * supports OLED display on the I²C interface on GPIO22 and GPI21. This repo contains a patched SSD1306 library from [smartnick](https://github.com/smartinick/Adafruit_SSD1306), enabling individual I²C pins and to set I²C Clock to 800kHz. From 9a8992620a9617e9009160d8429a3893230474e4 Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Sat, 9 Mar 2024 15:59:34 +0100 Subject: [PATCH 8/8] update ci to latest versions --- .github/workflows/buildproject.yml | 12 +++--------- .github/workflows/spell_check.yml | 2 +- src/fromV08.ino.cpp | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/buildproject.yml b/.github/workflows/buildproject.yml index d552d84..12a686c 100644 --- a/.github/workflows/buildproject.yml +++ b/.github/workflows/buildproject.yml @@ -7,16 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - path: | - ~/.cache/pip - ~/.platformio/.cache - key: ${{ runner.os }}-pio - - uses: actions/setup-python@v4 - with: - python-version: '3.9' + python-version: '3.10' - name: Install PlatformIO Core run: pip install --upgrade platformio diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index 37fb2ec..5c73c87 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md - name: Spell check diff --git a/src/fromV08.ino.cpp b/src/fromV08.ino.cpp index e84728e..719330a 100644 --- a/src/fromV08.ino.cpp +++ b/src/fromV08.ino.cpp @@ -12,7 +12,7 @@ #include "Adafruit_GFX.h" #include "Adafruit_SSD1306.h" -#define MIN_DIST 10.0 // Minimum distance in meters from the last sent location before we send again. +#define MIN_DIST 20.0 // Minimum distance in meters from the last sent location before we send again. #define STATIONARY_TX_INTERVAL (1 * 60) // Send one uplink at least once every N seconds // Below BATTERY_LOW_VOLTAGE, power off until USB power allows charging. @@ -564,7 +564,7 @@ void loop() { display.setCursor(0, 10); display.print("Speed: " + String(txBuffer2[1]) + " km/h"); display.setCursor(0, 20); - display.print("Dist: " + String(dist_moved) + "m"); + display.print("Dist: " + String(dist_moved,0) + "m"); display.setCursor(0, 30); display.print("Alt: " + String(txBuffer2[3]) + "m"); display.setCursor(0, 40);