From aa1b4172fed92c5391b13f2a8cfbecfda04ea241 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 10 Jun 2018 15:34:21 +0200 Subject: [PATCH 1/9] GPS testing --- README.md | 68 ++++++++++++++++++++++--------------------------- src/gpsread.cpp | 41 +++++++++++++++++++---------- src/hal/lopy.h | 8 ++++-- src/hal/lopy4.h | 8 ++++-- src/lorawan.cpp | 27 +++++++++++--------- src/main.cpp | 4 +-- 6 files changed, 87 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 54f20320..bb6fbcac 100644 --- a/README.md +++ b/README.md @@ -102,50 +102,43 @@ Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only): # Payload -LoRaWAN Port #1: Counter data +LoRaWAN Port #1: - byte 1: WiFi counter, MSB - byte 2: WiFi counter, LSB - byte 3: BLE counter, MSB - byte 4: BLE counter, LSB + byte 1: Paxcount Wifi, MSB + byte 2: Paxcount WiFi, LSB + byte 3: Paxcount Bluetooth, MSB + byte 4: Paxcount Bluetooth, LSB + bytes 5-8: GPS latitude + bytes 9-12: GPS longitude + bytes 13-14: GPS satellites + bytes 15-16: GPS HDOP + bytes 17-18: GPS altitude -LoRaWAN Port #2: Remote commands +LoRaWAN Port #2: see remote control -LoRaWAN Port #3: GPS data - - bytes 1-4: Latitude - bytes 4-8: Longitude - bytes 9-10: Satellites - bytes 11-12: HDOP - bytes 13-14: Altitude - If you're using [TheThingsNetwork](https://www.thethingsnetwork.org/) you may want to use a payload converter. Go to TTN Console - Application - Payload Formats and paste the code example below in tabs Decoder and Converter. Make sure that your application parses the fields `pax`, `ble` and `wifi`. Decoder: ```javascript function Decoder(bytes, port) { - // decode counter messages var decoded = {}; if (port === 1) { decoded.wifi = (bytes[0] << 8) | bytes[1]; decoded.ble = (bytes[2] << 8) | bytes[3]; - } - - // decode GPS messages - if (port === 3) { - decoded.latitude = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0]; - decoded.longitude = (bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | bytes[4]; - decoded.satellites = (bytes[9] << 8) | bytes[8]; - decoded.hdop = (bytes[11] << 8) | bytes[10]; - decoded.altitude = (bytes[13] << 8) | bytes[12]; + decoded.latitude = ((bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | bytes[4]); + decoded.longitude = ((bytes[11] << 24) | (bytes[10] << 16) | (bytes[9] << 8) | bytes[8]); + decoded.satellites = (bytes[13] << 8) | bytes[12]; + decoded.hdop = (bytes[15] << 8) | bytes[14]; + decoded.altitude = (bytes[17] << 8) | bytes[16]; } return decoded; } +} ``` Converter: @@ -153,24 +146,24 @@ Converter: ```javascript function Converter(decoded, port) { var converted = decoded; - // sum up ble + wifi counters + if (port === 1) { converted.pax = converted.ble + converted.wifi; + converted.hdop /= 100; + converted.latitude /= 1000000; + converted.longitude /= 1000000; } - // convert some GPS values - if (port === 3) { - converted.latitude = converted.latitude / 100000; - converted.longitude = converted.longitude / 100000; - converted.hdop = converted.hdop / 100; + return converted; } +} ``` -# Remote control +# Remote command set The device listenes for remote control commands on LoRaWAN Port 2. Each command is followed by exactly one parameter. -For "set" commands, multiple command/parameter pairs can be concatenated and sent in one downlink, all commands are executed. For "get" commands, only one command/parameter pair per downlink is processed. +Multiple command/parameter pairs can be concatenated and sent in one single payload downlink. Note: all settings are stored in NVRAM and will be reloaded when device starts. To reset device to factory settings press button (if device has one), or send remote command 09 02 09 00 unconfirmed(!) once. @@ -185,10 +178,10 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts. 1 = cumulative counter, mac counter is never reset 2 = cyclic confirmed, like 0 but data is resent until confirmation by network received -0x03 set GPS on/off (NOT YET IMPLEMENTED) +0x03 (NOT YET IMPLEMENTED) set screen saver mode - 0 = GPS off [default] - 1 = GPS on, GPS data set (if present) is added to payload + 0 = screen saver off [default] + 1 = screen saver on 0x04 set display on/off @@ -258,7 +251,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts. 0x80 get device configuration -device answers with it's current configuration. The configuration is a C structure declared in file [globals.h](src/globals.h#L32-L50) with the following definition: +device answers with it's current configuration. The configuration is a C structure declared in file [globals.h](src/globals.h#L27-L44) with the following definition: byte 1: Lora SF (7..12) byte 2: Lora TXpower (2..15) @@ -274,8 +267,7 @@ device answers with it's current configuration. The configuration is a C structu byte 13: Wifi antenna switch (0=internal, 1=external) byte 14: Vendorfilter mode (0=disabled, 1=enabled) byte 15: RGB LED luminosity (0..100 %) - byte 16: GPS status (1=on, 0=off) - bytes 17-27: Software version (ASCII format, terminating with zero) + bytes 16-26: Software version (ASCII format, terminating with zero) 0x81 get device uptime diff --git a/src/gpsread.cpp b/src/gpsread.cpp index 0cedc315..eb38eb73 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -6,7 +6,7 @@ static const char TAG[] = "main"; // read GPS data and cast to global struct -void gps_read(){ +void gps_read() { gps_status.latitude = (uint32_t) (gps.location.lat() * 1000000); gps_status.longitude = (uint32_t) (gps.location.lng() * 1000000); gps_status.satellites = (uint8_t) gps.satellites.value(); @@ -19,11 +19,10 @@ void gps_loop(void * pvParameters) { configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check - #ifdef GPS_SERIAL + // initialize and, if needed, configure, GPS + #if defined GPS_SERIAL HardwareSerial GPS_Serial(1); - #endif - - #ifdef GPS_I2C + #elif defined GPS_I2C // to be done #endif @@ -31,7 +30,8 @@ void gps_loop(void * pvParameters) { if (cfg.gpsmode) { - #ifdef GPS_SERIAL + #if defined GPS_SERIAL + // serial connect to GPS device GPS_Serial.begin(GPS_SERIAL); @@ -39,19 +39,34 @@ void gps_loop(void * pvParameters) { // feed GPS decoder with serial NMEA data from GPS device while (GPS_Serial.available()) { gps.encode(GPS_Serial.read()); - vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog } + vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog } // after GPS function was disabled, close connect to GPS device GPS_Serial.end(); - #endif - #ifdef GPS_I2C - // I2C connect to GPS device + #elif defined GPS_I2C - /* - to be done - */ + // I2C connect to GPS device with 100 kHz + Wire.begin(GPS_I2C_PINS, 100000); + Wire.beginTransmission(GPS_I2C_ADDRESS_WRITE); + Wire.write(0x00); + + i2c_ret == Wire.beginTransmission(GPS_I2C_ADDRESS_READ); + if (i2c_ret == 0) { // check if device seen on i2c bus + while(cfg.gpsmode) { + // feed GPS decoder with serial NMEA data from GPS device + while (Wire.available()) { + Wire.requestFrom(GPS_I2C_ADDRESS_READ, 255); + gps.encode(Wire.read()); + vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog + } + } + // after GPS function was disabled, close connect to GPS device + + Wire.endTransmission(); + Wire.setClock(400000); // Set back to 400KHz to speed up OLED + } #endif } diff --git a/src/hal/lopy.h b/src/hal/lopy.h index dd5a0b7b..d54004f6 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -4,9 +4,13 @@ #define HAS_LED NOT_A_PIN // LoPy4 has no on board LED, so we use RGB LED on LoPy4 #define HAS_RGB_LED GPIO_NUM_0 // WS2812B RGB LED on GPIO0 -// use only if your LoPy lives on a Pytrack expansion board +// !!EXPERIMENTAL - not tested yet!! +// uncomment this only if your LoPy lives on a Pytrack expansion board with GPS +// see http://www.quectel.com/UploadImage/Downlad/Quectel_L76-L_I2C_Application_Note_V1.0.pdf //#define HAS_GPS 1 -//#define GPS_I2C GPIO_NUM_9, GPIO_NUM_8 // SDA, SCL +//#define GPS_I2C_PINS GPIO_NUM_9, GPIO_NUM_8 // SDA, SCL +//#define GPS_I2C_ADDRESS_READ 0x21 +//#define GPS_I2C_ADDRESS_WRITE 0x20 //#define HAS_BUTTON GPIO_NUM_4 // Hardware pin definitions for Pycom LoPy board diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index 721b11ef..708a861d 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -4,9 +4,13 @@ #define HAS_LED NOT_A_PIN // LoPy4 has no on board LED, so we use RGB LED on LoPy4 #define HAS_RGB_LED GPIO_NUM_0 // WS2812B RGB LED on GPIO0 -// use only if your LoPy lives on a Pytrack expansion board +// !!EXPERIMENTAL - not tested yet!!f +// uncomment this only if your LoPy lives on a Pytrack expansion board with GPS +// see http://www.quectel.com/UploadImage/Downlad/Quectel_L76-L_I2C_Application_Note_V1.0.pdf //#define HAS_GPS 1 -//#define GPS_I2C GPIO_NUM_9, GPIO_NUM_8 // SDA, SCL +//#define GPS_I2C_PINS GPIO_NUM_9, GPIO_NUM_8 // SDA, SCL +//#define GPS_I2C_ADDRESS_READ 0x21 +//#define GPS_I2C_ADDRESS_WRITE 0x20 //#define HAS_BUTTON GPIO_NUM_4 // Hardware pin definitions for Pycom LoPy4 board diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 92d2f61c..8fd1b86f 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -116,7 +116,7 @@ void do_send(osjob_t* j){ // prepare payload with sum of unique WIFI MACs seen static uint8_t mydata[4]; - + mydata[0] = (macs_wifi & 0xff00) >> 8; mydata[1] = macs_wifi & 0xff; @@ -129,19 +129,26 @@ void do_send(osjob_t* j){ mydata[3] = 0; } - // Prepare upstream data transmission at the next possible time. - LMIC_setTxData2(COUNTERPORT, mydata, sizeof(mydata), (cfg.countermode & 0x02)); - ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata)); - sprintf(display_lmic, "PACKET QUEUED"); - #ifdef HAS_GPS + static uint8_t gpsdata[18]; if (cfg.gpsmode && gps.location.isValid()) { gps_read(); - LMIC_setTxData2(GPSPORT, (byte*)&gps_status, sizeof(gps_status), (cfg.countermode & 0x02)); + memcpy (gpsdata+4, &gps_status, sizeof(gps_status)); + memcpy (gpsdata, mydata, 4); ESP_LOGI(TAG, "lat=%f / lon=%f | Sats=%u | HDOP=%u | Alti=%u", gps_status.latitude / 1000000, gps_status.longitude / 1000000, gps_status.satellites, gps_status.hdop, gps_status.altitude); + LMIC_setTxData2(COUNTERPORT, gpsdata, sizeof(gpsdata), (cfg.countermode & 0x02)); + ESP_LOGI(TAG, "%d bytes queued to send", sizeof(gpsdata)); } + else { #endif - + LMIC_setTxData2(COUNTERPORT, mydata, sizeof(mydata), (cfg.countermode & 0x02)); + ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata)); + sprintf(display_lmic, "PACKET QUEUED"); + + #ifdef HAS_GPS + } + #endif + // clear counter if not in cumulative counter mode if (cfg.countermode != 1) { reset_counters(); // clear macs container and reset all counters @@ -178,10 +185,6 @@ void onEvent (ev_t ev) { strcpy_P(buff, PSTR("JOINED")); sprintf(display_lora, " "); // clear previous lmic status message from display - // Disable link check validation (automatically enabled - // during join, but not supported by TTN at this time). -> do we need this? - // LMIC_setLinkCheckMode(0); - // set data rate adaptation LMIC_setAdrMode(cfg.adrmode); // Set data rate and transmit power (note: txpower seems to be ignored by the library) diff --git a/src/main.cpp b/src/main.cpp index e722ad72..240474bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -586,8 +586,8 @@ xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 2048, ( void * ) 1, 1, NULL // if device has GPS and GPS function is enabled, start GPS reader task on core 0 #ifdef HAS_GPS if (cfg.gpsmode) { - ESP_LOGI(TAG, "Starting GPS task on core 0"); - xTaskCreatePinnedToCore(gps_loop, "gpsfeed", 2048, ( void * ) 1, 1, NULL, 0); + ESP_LOGI(TAG, "Starting GPS task on core 0"); + xTaskCreatePinnedToCore(gps_loop, "gpsfeed", 2048, ( void * ) 1, 1, NULL, 0); } #endif From e30e133bf1be712c66313536a0c51166952931e5 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 10 Jun 2018 16:00:11 +0200 Subject: [PATCH 2/9] GPS integration now fully functional --- README.md | 20 +++++++++----------- platformio.ini | 3 +-- src/lorawan.cpp | 9 +++++++-- src/main.cpp | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bb6fbcac..9f08846e 100644 --- a/README.md +++ b/README.md @@ -104,15 +104,13 @@ Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only): LoRaWAN Port #1: - byte 1: Paxcount Wifi, MSB - byte 2: Paxcount WiFi, LSB - byte 3: Paxcount Bluetooth, MSB - byte 4: Paxcount Bluetooth, LSB - bytes 5-8: GPS latitude + byte 1-2: Number of unique pax, first seen on Wifi + byte 3-4: Number of unique pax, first seen on Bluetooth [0 if BT disabled] + bytes 5-8: GPS latitude bytes 9-12: GPS longitude - bytes 13-14: GPS satellites + bytes 13-14: GPS number of satellites bytes 15-16: GPS HDOP - bytes 17-18: GPS altitude + bytes 17-18: GPS altitude [meter] LoRaWAN Port #2: @@ -281,13 +279,13 @@ device answers with it's current configuration. The configuration is a C structu bytes 1-2: battery voltage in millivolt, 0 if unreadable (little endian format) -0x84 get device GPS status (NOT YET IMPLEMENTED) +0x84 get device GPS status bytes 1-4: latitude bytes 5-8: longitude - byte 9: number of satellites - byte 10: HDOP - bytes 11-12: altidute [meter] + byte 9-10: number of satellites + byte 11-12: HDOP + bytes 13-14: altidute [meter] # License diff --git a/platformio.ini b/platformio.ini index 076c7674..1a9fae0e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,8 +32,7 @@ lib_deps_display = lib_deps_rgbled = SmartLeds@>=1.1.3 lib_deps_gps = - https://github.com/mikalhart/TinyGPSPlus.git -;beware of TinyGPSplus in PlatformIO library manager, it loads old v.092 labeled as 1.0.0 !! + TinyGPSPlus@>=1.0.2 build_flags = ; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework ; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <--- diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 8fd1b86f..b832b311 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -133,9 +133,14 @@ void do_send(osjob_t* j){ static uint8_t gpsdata[18]; if (cfg.gpsmode && gps.location.isValid()) { gps_read(); - memcpy (gpsdata+4, &gps_status, sizeof(gps_status)); memcpy (gpsdata, mydata, 4); - ESP_LOGI(TAG, "lat=%f / lon=%f | Sats=%u | HDOP=%u | Alti=%u", gps_status.latitude / 1000000, gps_status.longitude / 1000000, gps_status.satellites, gps_status.hdop, gps_status.altitude); + memcpy (gpsdata+4, &gps_status, sizeof(gps_status)); + ESP_LOGI(TAG, "lat=%.6f / lon=%.6f | %u Sats | HDOP=%.1f | Altitude=%u m", \ + gps_status.latitude / (float) 1000000, \ + gps_status.longitude / (float) 1000000, \ + gps_status.satellites, \ + gps_status.hdop / (float) 100, \ + gps_status.altitude); LMIC_setTxData2(COUNTERPORT, gpsdata, sizeof(gpsdata), (cfg.countermode & 0x02)); ESP_LOGI(TAG, "%d bytes queued to send", sizeof(gpsdata)); } diff --git a/src/main.cpp b/src/main.cpp index 240474bb..c95ef652 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -630,7 +630,7 @@ void loop() { } if ( (uptime() % 10000) == 0 ) - ESP_LOGI(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix()); + ESP_LOGD(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix()); vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog From 3f8820a8dc69c0b332855dbc5bd4110b482b6ac6 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 10 Jun 2018 16:04:13 +0200 Subject: [PATCH 3/9] v1.3.8 RC --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c95ef652..a6216a3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -629,8 +629,11 @@ void loop() { reset_salt(); // get new salt for salting hashes } - if ( (uptime() % 10000) == 0 ) - ESP_LOGD(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix()); + #ifdef HAS_GPS + // log NMEA status every 30 seconds, useful for debugging GPS connection + if ( (uptime() % 30000) == 0 ) + ESP_LOGD(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix()); + #endif vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog From 67de5257271ce9645535aab968165b9a221f5d8a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 10 Jun 2018 16:13:35 +0200 Subject: [PATCH 4/9] v1.3.8 RC --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 1a9fae0e..be9dda45 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,11 +11,11 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -;env_default = heltec +env_default = heltec ;env_default = ttgov1 ;env_default = ttgov2 ;env_default = ttgov21 -env_default = ttgobeam +;env_default = ttgobeam ;env_default = lopy ;env_default = lopy4 ;env_default = fipy From 4b6efba3fe9a7308614c04f3674349121b53e4a1 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 10 Jun 2018 16:35:10 +0200 Subject: [PATCH 5/9] Update README.md --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9f08846e..168e81c7 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,23 @@ This can all be done with a single small and cheap ESP32 board for less than $20 # Hardware Supported ESP32 based LoRa IoT boards: -- Heltec LoRa-32 {1} -- TTGOv1 {1} -- TTGOv2 {1}{4} -- TTGOv2.1 {1}{5} -- TTGO T-Beam {4}{5} -- Pycom LoPy {2} -- Pycom LoPy4 {2} -- Pycom FiPy {2} -- LoLin32 with [LoraNode32 shield](https://github.com/hallard/LoLin32-Lora) {2}{3} -- LoLin32 Lite with [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-Lora) {2}{3} +- Heltec LoRa-32 a) +- TTGOv1 a) +- TTGOv2 a,d) +- TTGOv2.1 a),e) +- TTGO T-Beam d),e),f) +- Pycom LoPy b) +- Pycom LoPy4 b) +- Pycom FiPy b) +- LoLin32 with [LoraNode32 shield](https://github.com/hallard/LoLin32-Lora) b),c) +- LoLin32 Lite with [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-Lora) b),c) -{1} on board OLED Display supported; {2} on board RGB LED supported; {3} on board Hardware unique DEVEUI supported; {4} special wiring needed, see instructions in file /hal/.h; {5} battery voltage monitoring supported +a) on board OLED Display supported; +b) on board RGB LED supported; +c) on board Hardware unique DEVEUI supported; +d) external wiring needed, see instructions in file /hal/.h; +e) battery voltage monitoring supported; +f) on board GPS supported Target platform must be selected in [platformio.ini](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/platformio.ini).
Hardware dependent settings (pinout etc.) are stored in board files in /hal directory.
@@ -136,7 +141,6 @@ function Decoder(bytes, port) { return decoded; } -} ``` Converter: @@ -154,7 +158,6 @@ function Converter(decoded, port) { return converted; } -} ``` # Remote command set From aa008edfbeade86a332e0057a88f1390160b1db4 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 10 Jun 2018 16:37:48 +0200 Subject: [PATCH 6/9] Update README.md --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 168e81c7..c347c370 100644 --- a/README.md +++ b/README.md @@ -20,23 +20,23 @@ This can all be done with a single small and cheap ESP32 board for less than $20 # Hardware Supported ESP32 based LoRa IoT boards: -- Heltec LoRa-32 a) -- TTGOv1 a) -- TTGOv2 a,d) -- TTGOv2.1 a),e) -- TTGO T-Beam d),e),f) -- Pycom LoPy b) -- Pycom LoPy4 b) -- Pycom FiPy b) -- LoLin32 with [LoraNode32 shield](https://github.com/hallard/LoLin32-Lora) b),c) -- LoLin32 Lite with [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-Lora) b),c) +- **Heltec LoRa-32** a) +- **TTGOv1** a) +- **TTGOv2** a,d) +- **TTGOv2.1** a),e) +- **TTGO T-Beam** d),e),f) +- **Pycom LoPy** b),f)* +- **Pycom LoPy4** b),f)* +- **Pycom FiPy** b),f)* +- **LoLin32** with [LoraNode32 shield](https://github.com/hallard/LoLin32-Lora) b),c) +- **LoLin32 Lite** with [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-Lora) b),c) a) on board OLED Display supported; b) on board RGB LED supported; c) on board Hardware unique DEVEUI supported; d) external wiring needed, see instructions in file /hal/.h; e) battery voltage monitoring supported; -f) on board GPS supported +f) on board GPS supported, *for Pycom devices with additional PyTrack board Target platform must be selected in [platformio.ini](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/platformio.ini).
Hardware dependent settings (pinout etc.) are stored in board files in /hal directory.
From 1b6b0377ea034952a0a52c2186a7b1b2acb6a991 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 10 Jun 2018 16:40:12 +0200 Subject: [PATCH 7/9] Update README.md --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c347c370..5d40afd4 100644 --- a/README.md +++ b/README.md @@ -107,19 +107,24 @@ Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only): # Payload -LoRaWAN Port #1: +**LoRaWAN Port #1:** + + Paxcounter data byte 1-2: Number of unique pax, first seen on Wifi byte 3-4: Number of unique pax, first seen on Bluetooth [0 if BT disabled] + + GPS data (only, if GPS is present and has a fix) + bytes 5-8: GPS latitude - bytes 9-12: GPS longitude + bytes 9-12: GPS longitude bytes 13-14: GPS number of satellites bytes 15-16: GPS HDOP bytes 17-18: GPS altitude [meter] -LoRaWAN Port #2: +**LoRaWAN Port #2:** - see remote control + - see remote control - If you're using [TheThingsNetwork](https://www.thethingsnetwork.org/) you may want to use a payload converter. Go to TTN Console - Application - Payload Formats and paste the code example below in tabs Decoder and Converter. Make sure that your application parses the fields `pax`, `ble` and `wifi`. @@ -288,7 +293,7 @@ device answers with it's current configuration. The configuration is a C structu bytes 5-8: longitude byte 9-10: number of satellites byte 11-12: HDOP - bytes 13-14: altidute [meter] + bytes 13-14: altidute [meter] # License From 85d3e31cd32f32fa78068ca5fa5183e7a12559c1 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 10 Jun 2018 16:46:07 +0200 Subject: [PATCH 8/9] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d40afd4..72a5db04 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,9 @@ Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only): - see remote control - -If you're using [TheThingsNetwork](https://www.thethingsnetwork.org/) you may want to use a payload converter. Go to TTN Console - Application - Payload Formats and paste the code example below in tabs Decoder and Converter. Make sure that your application parses the fields `pax`, `ble` and `wifi`. +If you're using [TheThingsNetwork](https://www.thethingsnetwork.org/) (TTN) you may want to use a payload converter. Go to TTN Console - Application - Payload Formats and paste the code example below in tabs Decoder and Converter. Make sure that your application parses the fields `pax`, `ble` and `wifi`. + +To map a GPS capable paxcounter device and at the same time contribute to TTN coverage mapping, you simply activate the [TTNmapper integration](https://www.thethingsnetwork.org/docs/applications/ttnmapper/) in TTN Console. Paxcounter generates ttnmapper compatible data fields. Decoder: From 6b4effde7cc75bc7e24deec2b0d265c442b406cf Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 10 Jun 2018 16:55:21 +0200 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72a5db04..dadfdfa5 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ function Decoder(bytes, port) { decoded.ble = (bytes[2] << 8) | bytes[3]; decoded.latitude = ((bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | bytes[4]); decoded.longitude = ((bytes[11] << 24) | (bytes[10] << 16) | (bytes[9] << 8) | bytes[8]); - decoded.satellites = (bytes[13] << 8) | bytes[12]; + decoded.sats = (bytes[13] << 8) | bytes[12]; decoded.hdop = (bytes[15] << 8) | bytes[14]; decoded.altitude = (bytes[17] << 8) | bytes[16]; }