From 8873a7ce705bd1a7c08461c8df74c898cca62127 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 11 Aug 2018 21:47:51 +0200 Subject: [PATCH 01/16] cpu temp reduced to 8bit --- src/TTN/packed_decoder.js | 2 +- src/TTN/plain_decoder.js | 10 +++++----- src/payload.cpp | 8 ++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index 6bf29f09..21097634 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -18,7 +18,7 @@ function Decoder(bytes, port) { if (port === 2) { // device status data - return decode(bytes, [uint16, uptime, temperature, uint32], ['voltage', 'uptime', 'cputemp', 'memory']); + return decode(bytes, [uint16, uptime, uint8, uint32], ['voltage', 'uptime', 'cputemp', 'memory']); } diff --git a/src/TTN/plain_decoder.js b/src/TTN/plain_decoder.js index 32850474..ba674d35 100644 --- a/src/TTN/plain_decoder.js +++ b/src/TTN/plain_decoder.js @@ -13,7 +13,7 @@ function Decoder(bytes, port) { if (bytes.length > 4) { decoded.latitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]); decoded.longitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]); - decoded.sats = (bytes[i++]); + decoded.sats = bytes[i++]; decoded.hdop = (bytes[i++] << 8) | (bytes[i++]); decoded.altitude = (bytes[i++] << 8) | (bytes[i++]); } @@ -24,18 +24,18 @@ function Decoder(bytes, port) { decoded.battery = ((bytes[i++] << 8) | bytes[i++]); decoded.uptime = ((bytes[i++] << 56) | (bytes[i++] << 48) | (bytes[i++] << 40) | (bytes[i++] << 32) | (bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]); - decoded.temp = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]); + decoded.temp = bytes[i++]; } if (port === 5) { var i = 0; - decoded.button = (bytes[i++]); + decoded.button = bytes[i++]; } if (port === 6) { var i = 0; - decoded.rssi = (bytes[i++]); - decoded.beacon = (bytes[i++]); + decoded.rssi = bytes[i++]; + decoded.beacon = bytes[i++]; } return decoded; diff --git a/src/payload.cpp b/src/payload.cpp index ab3d2c91..87334b83 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -54,7 +54,6 @@ void PayloadConvert::addConfig(configData_t value) { void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp, uint32_t mem) { - uint32_t temp = (uint32_t)cputemp; buffer[cursor++] = highByte(voltage); buffer[cursor++] = lowByte(voltage); buffer[cursor++] = (byte)((uptime & 0xFF00000000000000) >> 56); @@ -65,10 +64,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, buffer[cursor++] = (byte)((uptime & 0x0000000000FF0000) >> 16); buffer[cursor++] = (byte)((uptime & 0x000000000000FF00) >> 8); buffer[cursor++] = (byte)((uptime & 0x00000000000000FF)); - buffer[cursor++] = (byte)((temp & 0xFF000000) >> 24); - buffer[cursor++] = (byte)((temp & 0x00FF0000) >> 16); - buffer[cursor++] = (byte)((temp & 0x0000FF00) >> 8); - buffer[cursor++] = (byte)((temp & 0x000000FF)); + buffer[cursor++] = (byte)(cputemp); buffer[cursor++] = (byte)((mem & 0xFF000000) >> 24); buffer[cursor++] = (byte)((mem & 0x00FF0000) >> 16); buffer[cursor++] = (byte)((mem & 0x0000FF00) >> 8); @@ -131,7 +127,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp, uint32_t mem) { writeUint16(voltage); writeUptime(uptime); - writeTemperature(cputemp); + writeUint8((byte)cputemp); writeUint32(mem); } From 0318987a4e4b4a307b96874368ab70498ee7b74b Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 12 Aug 2018 13:44:29 +0200 Subject: [PATCH 02/16] Bugfix main.cpp introduced with last commit --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 1b258f14..bd6d04f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -330,6 +330,8 @@ void loop() { processSendBuffer(); // check send cycle and enqueue payload if cycle is expired sendPayload(); + // reset watchdog + vTaskDelay(1 / portTICK_PERIOD_MS); } // loop() } From f659d18390837e589760b94506759ee5bca1d845 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 14 Aug 2018 15:39:36 +0200 Subject: [PATCH 03/16] bugfix rcommand.cpp (illegal commands chrash) --- src/rcommand.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 8899a805..0335877e 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -138,7 +138,7 @@ void set_loraadr(uint8_t val[]) { ESP_LOGI(TAG, "Remote command: set LoRa ADR mode to %s", val[0] ? "on" : "off"); cfg.adrmode = val[0] ? 1 : 0; -LMIC_setAdrMode(cfg.adrmode); + LMIC_setAdrMode(cfg.adrmode); #else ESP_LOGW(TAG, "Remote command: LoRa not implemented"); #endif // HAS_LORA @@ -267,10 +267,11 @@ void rcommand(uint8_t cmd[], uint8_t cmdlength) { TAG, "Remote command x%02X called with missing parameter(s), skipped", table[i].opcode); - break; // exit table lookup loop, command was found - } // command validation - } // command table lookup loop - + break; // command found -> exit table lookup loop + } // end of command validation + } // end of command table lookup loop + if (i < 0) // command not found -> exit parser + break; } // command parsing loop if (storeflag) From f6dc5efab33ee0a09bd87c5fb291813c19ced559 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 14 Aug 2018 15:50:17 +0200 Subject: [PATCH 04/16] espressif 1.3.0 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 98296872..498ffd27 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,7 +28,7 @@ env_default = generic description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. [common_env_data] -platform_espressif32 = espressif32@1.2.0 +platform_espressif32 = espressif32@1.3.0 ;platform_espressif32 = https://github.com/platformio/platform-espressif32.git#feature/stage board_build.partitions = no_ota.csv lib_deps_all = From b9327100f2079705a57e1ffb8e90dd71ef15f944 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Tue, 14 Aug 2018 22:28:34 +0200 Subject: [PATCH 05/16] rcommand.cpp: bugfix issue #139 --- src/rcommand.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 0335877e..84af6cd6 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -267,11 +267,13 @@ void rcommand(uint8_t cmd[], uint8_t cmdlength) { TAG, "Remote command x%02X called with missing parameter(s), skipped", table[i].opcode); - break; // command found -> exit table lookup loop - } // end of command validation - } // end of command table lookup loop - if (i < 0) // command not found -> exit parser + break; // command found -> exit table lookup loop + } // end of command validation + } // end of command table lookup loop + if (i < 0) { // command not found -> exit parser + ESP_LOGI(TAG, "Unknown remote command x%02X, ignored", cmd[cursor]); break; + } } // command parsing loop if (storeflag) From 758918bf7e6c2acaebcbb6456bcf3d4e5e914826 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Tue, 14 Aug 2018 22:41:21 +0200 Subject: [PATCH 06/16] espressif32 v1.3.0 --- README.md | 4 ++-- platformio.ini | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6d5b64d5..8c6400aa 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,8 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering. byte 1-2: Battery or USB Voltage [mV], 0 if no battery probe byte 3-10: Uptime [seconds] - bytes 11-14: CPU temperature [°C] - bytes 15-18: Free RAM [bytes] + byte 11: CPU temperature [°C] + bytes 12-15: Free RAM [bytes] **Port #3:** Device configuration query result diff --git a/platformio.ini b/platformio.ini index 98296872..6f198ad0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,7 +28,7 @@ env_default = generic description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around. [common_env_data] -platform_espressif32 = espressif32@1.2.0 +platform_espressif32 = espressif32@1.3.0 ;platform_espressif32 = https://github.com/platformio/platform-espressif32.git#feature/stage board_build.partitions = no_ota.csv lib_deps_all = @@ -48,9 +48,9 @@ build_flags = ; Error ; -DCORE_DEBUG_LEVEL=1 ; Warn - -DCORE_DEBUG_LEVEL=2 +; -DCORE_DEBUG_LEVEL=2 ; Info -; -DCORE_DEBUG_LEVEL=3 + -DCORE_DEBUG_LEVEL=3 ; Debug ; -DCORE_DEBUG_LEVEL=4 ; Verbose From 4883497a6bbd981e07e36c4af40acdcae4948639 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 15 Aug 2018 21:02:15 +0200 Subject: [PATCH 07/16] rcommand.cpp: code sanitization --- src/rcommand.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 0335877e..76f7ba9b 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -269,10 +269,10 @@ void rcommand(uint8_t cmd[], uint8_t cmdlength) { table[i].opcode); break; // command found -> exit table lookup loop } // end of command validation - } // end of command table lookup loop - if (i < 0) // command not found -> exit parser + } // end of table lookup loop + if (i < 0) // command not found -> exit parser loop break; - } // command parsing loop + } // end of command parsing loop if (storeflag) saveConfig(); From 051272063553be51efcdf6e87416b71da27486a3 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 15 Aug 2018 21:04:48 +0200 Subject: [PATCH 08/16] upgrade u8g2 in platformio.ini --- platformio.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 498ffd27..bb895931 100644 --- a/platformio.ini +++ b/platformio.ini @@ -33,7 +33,7 @@ platform_espressif32 = espressif32@1.3.0 board_build.partitions = no_ota.csv lib_deps_all = lib_deps_display = - U8g2@>=2.23.12 + U8g2@>=2.23.16 lib_deps_rgbled = SmartLeds@>=1.1.3 lib_deps_gps = @@ -44,11 +44,11 @@ build_flags = ; otherwise device may leak RAM ; ; None -; -DCORE_DEBUG_LEVEL=0 + -DCORE_DEBUG_LEVEL=0 ; Error ; -DCORE_DEBUG_LEVEL=1 ; Warn - -DCORE_DEBUG_LEVEL=2 +; -DCORE_DEBUG_LEVEL=2 ; Info ; -DCORE_DEBUG_LEVEL=3 ; Debug From 2c6ac9f4c034386611221729ebe43aa83107b438 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Thu, 16 Aug 2018 14:37:42 +0200 Subject: [PATCH 09/16] testing --- platformio.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index ce164811..7e4ca091 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,12 +11,12 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -env_default = generic +;env_default = generic ;env_default = ebox ;env_default = heltec ;env_default = ttgov1 ;env_default = ttgov2 -;env_default = ttgov21 +env_default = ttgov21 ;env_default = ttgobeam ;env_default = lopy ;env_default = lopy4 @@ -50,7 +50,7 @@ build_flags = ; Warn ; -DCORE_DEBUG_LEVEL=2 ; Info - -DCORE_DEBUG_LEVEL=3 +; -DCORE_DEBUG_LEVEL=3 ; Debug ; -DCORE_DEBUG_LEVEL=4 ; Verbose From e68126a7f6dd9b60da41ebdb3ff5f4ae2e0780cd Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 18 Aug 2018 16:28:33 +0200 Subject: [PATCH 10/16] testing --- .gitignore | 4 +++- platformio.ini | 6 +++--- src/paxcounter.conf | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a535321a..03205dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,10 @@ .vscode/c_cpp_properties.json .vscode/settings.json .vscode/launch.json -src/loraconf.h .vscode/*.db .vscode/.browse.c_cpp.db* .clang_complete .gcc-flags.json +platformio.ini +src/paxcounter.conf +src/loraconf.h diff --git a/platformio.ini b/platformio.ini index ce164811..c5bbf652 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,8 +11,8 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -env_default = generic -;env_default = ebox +;env_default = generic +env_default = ebox ;env_default = heltec ;env_default = ttgov1 ;env_default = ttgov2 @@ -50,7 +50,7 @@ build_flags = ; Warn ; -DCORE_DEBUG_LEVEL=2 ; Info - -DCORE_DEBUG_LEVEL=3 +; -DCORE_DEBUG_LEVEL=3 ; Debug ; -DCORE_DEBUG_LEVEL=4 ; Verbose diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 7cf76677..bcecc56d 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -9,7 +9,7 @@ // Payload send cycle and encoding #define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec. -#define PAYLOAD_ENCODER 1 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed +#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed // Set this to include BLE counting and vendor filter functions #define VENDORFILTER 1 // comment out if you want to count things, not people From 468d054fd297b6cd22a3fdc94cb5fcaadd2da654 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 8 Sep 2018 12:33:32 +0200 Subject: [PATCH 11/16] support TTGO21 v1.6 added --- README.md | 3 +++ platformio.ini | 8 ++++---- src/hal/ttgov21.h | 47 ++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8c6400aa..73490820 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,9 @@ Depending on board hardware following features are 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.
+A suitable board with paxcounter software preloaded can be purchased via AliExpress +here.
+ 3D printable cases can be found (and, if wanted so, ordered) on Thingiverse, see Heltec, TTGOv2, TTGOv2.1, T-BEAM for example.
diff --git a/platformio.ini b/platformio.ini index c5bbf652..325f8df7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,8 +11,8 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -;env_default = generic -env_default = ebox +env_default = generic +;env_default = ebox ;env_default = heltec ;env_default = ttgov1 ;env_default = ttgov2 @@ -44,13 +44,13 @@ build_flags = ; otherwise device may leak RAM ; ; None - -DCORE_DEBUG_LEVEL=0 +; -DCORE_DEBUG_LEVEL=0 ; Error ; -DCORE_DEBUG_LEVEL=1 ; Warn ; -DCORE_DEBUG_LEVEL=2 ; Info -; -DCORE_DEBUG_LEVEL=3 + -DCORE_DEBUG_LEVEL=3 ; Debug ; -DCORE_DEBUG_LEVEL=4 ; Verbose diff --git a/src/hal/ttgov21.h b/src/hal/ttgov21.h index 06cda59f..4341b0ed 100644 --- a/src/hal/ttgov21.h +++ b/src/hal/ttgov21.h @@ -1,18 +1,51 @@ /* Hardware related definitions for TTGO V2.1 Board / ATTENTION: check your board version! / Different versions are on the market which need different settings in this file: -/ - without label -> "old" -/ - labelled v1.5 on pcb -> "old" -/ - labelled v1.6 on pcb -> "new" +/ - without label -> settings (2) +/ - labeled v1.5 on pcb -> settings (2) +/ - labeled v1.6 on pcb -> settings (1) +/ Choose the right configuration below */ +// (1) settings for board labeled "t3 v1.6" on pcb + +#define HAS_LORA 1 // comment out if device shall not send data via LoRa +#define HAS_SPI 1 // comment out if device shall not send data via SPI +#define CFG_sx1276_radio 1 // HPD13A LoRa SoC + +#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C +#define HAS_LED GPIO_NUM_23 // green on board LED +#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7 +#define BATT_FACTOR 2 // voltage divider 100k/100k on board + +// re-define pin definitions of pins_arduino.h +#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input +#define PIN_SPI_MOSI GPIO_NUM_27 // ESP32 GPIO27 (Pin27) -- HPD13A MOSI/DSI (Pin6) SPI Data Input +#define PIN_SPI_MISO GPIO_NUM_19 // ESP32 GPIO19 (Pin19) -- HPD13A MISO/DSO (Pin7) SPI Data Output +#define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input + +// non arduino pin definitions +//#define RST GPIO_NUM_23 // ESP32 GPIO23 <-> HPD13A RESET +#define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN (old board) +//#define RST GPIO_NUM_12 // (boards labeled v1.5) +#define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0 +#define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1 +#define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2 + +// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display +#define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN +#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 +#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 + +/* +// (2) settings for boards without label on pcb, or labeled v1.5 on pcb + #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C #define DISPLAY_FLIP 1 // rotated display -#define HAS_LED GPIO_NUM_23 // green on board LED (new board ONLY) #define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7 #define BATT_FACTOR 2 // voltage divider 100k/100k on board @@ -24,8 +57,7 @@ // non arduino pin definitions #define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN (old board) -//#define RST GPIO_NUM_12 // (old board v1.5) -//#define RST GPIO_NUM_19 //(new board) +//#define RST GPIO_NUM_12 // (boards labeled v1.5) #define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0 #define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1 #define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2 @@ -33,4 +65,5 @@ // Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display #define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN #define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 -#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 \ No newline at end of file +#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 +*/ \ No newline at end of file From 25d42d42531a80d376a5061e64138f6c81dc22bc Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 8 Sep 2018 13:12:37 +0200 Subject: [PATCH 12/16] edits ttgov21.h --- src/hal/ttgov21.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/hal/ttgov21.h b/src/hal/ttgov21.h index 4341b0ed..db1f65b1 100644 --- a/src/hal/ttgov21.h +++ b/src/hal/ttgov21.h @@ -14,7 +14,7 @@ #define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C -#define HAS_LED GPIO_NUM_23 // green on board LED +#define HAS_LED GPIO_NUM_25 // green on board LED #define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7 #define BATT_FACTOR 2 // voltage divider 100k/100k on board @@ -25,9 +25,7 @@ #define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input // non arduino pin definitions -//#define RST GPIO_NUM_23 // ESP32 GPIO23 <-> HPD13A RESET -#define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN (old board) -//#define RST GPIO_NUM_12 // (boards labeled v1.5) +#define RST GPIO_NUM_23 // ESP32 GPIO23 <-> HPD13A RESET #define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0 #define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1 #define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2 From e4e5cc98e1918a261c213c76eb39196f302b4d8e Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 8 Sep 2018 13:56:08 +0200 Subject: [PATCH 13/16] sanitizations --- .gitignore | 2 -- platformio.ini | 4 ++-- src/hal/heltec.h | 1 - src/hal/ttgov21.h | 8 ++++---- src/paxcounter.conf | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 03205dfd..030b6f3d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,4 @@ .vscode/.browse.c_cpp.db* .clang_complete .gcc-flags.json -platformio.ini -src/paxcounter.conf src/loraconf.h diff --git a/platformio.ini b/platformio.ini index 325f8df7..bb895931 100644 --- a/platformio.ini +++ b/platformio.ini @@ -44,13 +44,13 @@ build_flags = ; otherwise device may leak RAM ; ; None -; -DCORE_DEBUG_LEVEL=0 + -DCORE_DEBUG_LEVEL=0 ; Error ; -DCORE_DEBUG_LEVEL=1 ; Warn ; -DCORE_DEBUG_LEVEL=2 ; Info - -DCORE_DEBUG_LEVEL=3 +; -DCORE_DEBUG_LEVEL=3 ; Debug ; -DCORE_DEBUG_LEVEL=4 ; Verbose diff --git a/src/hal/heltec.h b/src/hal/heltec.h index a860df50..2671fac8 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -5,7 +5,6 @@ #define CFG_sx1276_radio 1 #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board -//#define DISPLAY_FLIP 1 // uncomment this for rotated display #define HAS_LED GPIO_NUM_25 // white LED on board #define HAS_BUTTON GPIO_NUM_0 // button "PROG" on board diff --git a/src/hal/ttgov21.h b/src/hal/ttgov21.h index db1f65b1..f5c4b760 100644 --- a/src/hal/ttgov21.h +++ b/src/hal/ttgov21.h @@ -1,13 +1,13 @@ /* Hardware related definitions for TTGO V2.1 Board / ATTENTION: check your board version! / Different versions are on the market which need different settings in this file: -/ - without label -> settings (2) -/ - labeled v1.5 on pcb -> settings (2) -/ - labeled v1.6 on pcb -> settings (1) +/ - without label -> use settings (2) +/ - labeled V1.5 on pcb -> use settings (2) +/ - labeled V1.6 on pcb -> use settings (1) / Choose the right configuration below */ -// (1) settings for board labeled "t3 v1.6" on pcb +// (1) settings for board labeled "T3_V1.6" on pcb #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define HAS_SPI 1 // comment out if device shall not send data via SPI diff --git a/src/paxcounter.conf b/src/paxcounter.conf index bcecc56d..7cf76677 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -9,7 +9,7 @@ // Payload send cycle and encoding #define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec. -#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed +#define PAYLOAD_ENCODER 1 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed // Set this to include BLE counting and vendor filter functions #define VENDORFILTER 1 // comment out if you want to count things, not people From 90cf056e3db9463d82e33e26b82983b7e19ffe36 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sat, 8 Sep 2018 16:31:56 +0200 Subject: [PATCH 14/16] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 73490820..8c6400aa 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,6 @@ Depending on board hardware following features are 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.
-A suitable board with paxcounter software preloaded can be purchased via AliExpress -here.
- 3D printable cases can be found (and, if wanted so, ordered) on Thingiverse, see Heltec, TTGOv2, TTGOv2.1, T-BEAM for example.
From c963dbe1c6b643013d4c54b639381ec30acd4f44 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 9 Sep 2018 17:13:12 +0200 Subject: [PATCH 15/16] bugfix in ttgov21.h --- src/hal/ttgov21.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hal/ttgov21.h b/src/hal/ttgov21.h index f5c4b760..6d59065d 100644 --- a/src/hal/ttgov21.h +++ b/src/hal/ttgov21.h @@ -7,6 +7,7 @@ / Choose the right configuration below */ +/* // (1) settings for board labeled "T3_V1.6" on pcb #define HAS_LORA 1 // comment out if device shall not send data via LoRa @@ -35,12 +36,14 @@ #define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 #define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 -/* +*/ + // (2) settings for boards without label on pcb, or labeled v1.5 on pcb #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // HPD13A LoRa SoC +#define HAS_LED NOT_A_PIN // no usable LED on board #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C #define DISPLAY_FLIP 1 // rotated display @@ -64,4 +67,3 @@ #define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN #define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2 #define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0 -*/ \ No newline at end of file From 48734bca632350cd8a55af68a7eae49f8d982e5a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Thu, 13 Sep 2018 21:50:45 +0200 Subject: [PATCH 16/16] lmic/radio.c: Fix RSSI and SNR calculation --- lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c b/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c index 780226c2..0fffaa4f 100644 --- a/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c +++ b/lib/arduino-lmic-1.5.0-arduino-2-tweaked/src/lmic/radio.c @@ -790,8 +790,12 @@ void radio_irq_handler (u1_t dio) { // now read the FIFO readBuf(RegFifo, LMIC.frame, LMIC.dataLen); // read rx quality parameters - LMIC.snr = readReg(LORARegPktSnrValue); // SNR [dB] * 4 - LMIC.rssi = readReg(LORARegPktRssiValue) - 125 + 64; // RSSI [dBm] (-196...+63) + //LMIC.snr = readReg(LORARegPktSnrValue); // SNR [dB] * 4 + LMIC.snr = readReg(LORARegPktSnrValue) / 4; + //LMIC.rssi = readReg(LORARegPktRssiValue) - 125 + 64; // RSSI [dBm] (-196...+63) + LMIC.rssi = readReg(LORARegPktRssiValue) - 157; // RFI_HF for 868 and 915MHZ band + if (LMIC.snr < 0) + LMIC.rssi += LMIC.snr; } else if( flags & IRQ_LORA_RXTOUT_MASK ) { // indicate timeout LMIC.dataLen = 0;