diff --git a/README.md b/README.md index a6d43a0a..243d4ea8 100644 --- a/README.md +++ b/README.md @@ -90,16 +90,16 @@ Note: If you use this software you do this at your own risk. That means that you Paxcounter generates identifiers for sniffed MAC adresses and collects them temporary in the device's RAM for a configurable scan cycle time (default 240 seconds). After each scan cycle the collected identifiers are cleared. Identifiers are generated by salting and hashing MAC adresses. The random salt value changes after each scan cycle. Identifiers and MAC adresses are never transferred to the LoRaWAN network. No persistent storing of MAC adresses, identifiers or timestamps and no other kind of analytics than counting are implemented in this code. Wireless networks are not touched by this code, but MAC adresses from wireless devices as well within as not within wireless networks, regardless if encrypted or unencrypted, are sniffed and processed by this code. If the bluetooth option in the code is enabled, bluetooth MACs are scanned and processed by the included BLE stack, then hashed and counted by this code. -# LED +# LED blink pattern -Legend for mono color on board LED: +**Mono color LED:** - Single Flash (50ms): seen a new Wifi or BLE device - Quick blink (20ms on each 1/5 second): joining LoRaWAN network in progress or pending - Small blink (10ms on each 1/2 second): LoRaWAN data transmit in progress or pending - Long blink (200ms on each 2 seconds): LoRaWAN stack error -Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only): +**RGB LED:** - Green each blink: seen a new Wifi device - Magenta each blink: seen a new BLE device @@ -107,9 +107,9 @@ Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only): - Blue blink: LoRaWAN data transmit in progress or pending - Red long blink: LoRaWAN stack error -# Payload +# Payload format -You can select between different payload formats in [paxcounter.conf](src/paxcounter.conf#L40): +You can select different payload formats in [paxcounter.conf](src/paxcounter.conf#L40): - ***Plain*** uses big endian format and generates json fields, e.g. useful for TTN console @@ -117,11 +117,11 @@ You can select between different payload formats in [paxcounter.conf](src/paxcou - [***CayenneLPP***](https://mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload-reference-implementation) generates MyDevices Cayenne readable fields -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`. +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. This way your MQTT application can parse 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. +To track a paxcounter device with on board GPS 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. The formats *plain* and *packed* generate the fields `latitude`, `longitude` and `hdop` required by ttnmapper. -Hereafter described is the default *Plain* format. +Hereafter described is the default *plain* format. **LoRaWAN Port #1:** diff --git a/platformio.ini b/platformio.ini index 75d57140..797a0724 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,7 +25,7 @@ env_default = heltec 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.0.2 +platform_espressif32 = espressif32@1.0.2 board_build.partitions = no_ota.csv lib_deps_all = lib_deps_display = @@ -119,7 +119,7 @@ build_flags = -include "src/hal/ttgobeam.h" [env:fipy] -platform = espressif32@1.0.1 +platform = ${common_env_data.platform_espressif32} framework = arduino board = esp32dev board_build.partitions = ${common_env_data.board_build.partitions} @@ -188,4 +188,4 @@ lib_deps = ${common_env_data.lib_deps_rgbled} build_flags = ${common_env_data.build_flags} - -include "src/hal/lolin32_lora.h" \ No newline at end of file + -include "src/hal/lolin32_lora.h" diff --git a/src/blecsan.cpp b/src/blecsan.cpp index a22a2964..bfefc948 100644 --- a/src/blecsan.cpp +++ b/src/blecsan.cpp @@ -12,7 +12,6 @@ https://github.com/nkolban/esp32-snippets/tree/master/BLE/scanner #include #include #include // needed for BLE_ADDR types, do not remove -#include #define BT_BD_ADDR_HEX(addr) \ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] @@ -277,4 +276,4 @@ void stop_BLEscan(void) { ESP_LOGI(TAG, "Bluetooth scanner stopped"); } // stop_BLEscan -#endif // BLECOUNTER \ No newline at end of file +#endif // BLECOUNTER diff --git a/src/hal/lopy.h b/src/hal/lopy.h index d9d4068d..11b3cff2 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -4,15 +4,6 @@ #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 -// !!EXPERIMENTAL - not tested yet!! -// uncomment this only if your LoPy runs 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_QUECTEL_L76 GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21) -//#define GPS_ADDR 0x10 -//#define HAS_BUTTON GPIO_NUM_37 // (P14) -//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown - // Hardware pin definitions for Pycom LoPy board #define PIN_SPI_SS GPIO_NUM_17 #define PIN_SPI_MOSI GPIO_NUM_27 @@ -26,3 +17,24 @@ // select WIFI antenna (internal = onboard / external = u.fl socket) #define HAS_ANTENNA_SWITCH 16 // pin for switching wifi antenna #define WIFI_ANTENNA 0 // 0 = internal, 1 = external + +// !!EXPERIMENTAL - not tested yet!! +// uncomment this only if your LoPy runs 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_QUECTEL_L76 GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21) +//#define GPS_ADDR 0x10 +//#define HAS_BUTTON GPIO_NUM_37 // (P14) +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown + +// uncomment this only if your LoPy runs on a expansion board 3.0 +//#define HAS_BATTERY_PROBE ADC1_GPIO39_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 +//#define BATT_FACTOR 2 // voltage divider 1MOhm/1MOhm on board +//#define HAS_BUTTON GPIO_NUM_37 // (P14) +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown + +// uncomment this only if your LoPy runs on a expansion board 2.0 +//#define HAS_BATTERY_PROBE ADC1_GPIO39_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 +//#define BATT_FACTOR 4 // voltage divider 115kOhm/56kOhm on board +//#define HAS_BUTTON GPIO_NUM_13 // (P10) +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index e5481f12..ef6a4d77 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -4,15 +4,6 @@ #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 -// !!EXPERIMENTAL - not tested yet!! -// uncomment this only if your LoPy runs 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_QUECTEL_L76 GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21) -//#define GPS_ADDR 0x10 -//#define HAS_BUTTON GPIO_NUM_37 // (P14) -//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown - // Hardware pin definitions for Pycom LoPy4 board #define PIN_SPI_SS GPIO_NUM_18 #define PIN_SPI_MOSI GPIO_NUM_27 @@ -25,4 +16,25 @@ // select WIFI antenna (internal = onboard / external = u.fl socket) #define HAS_ANTENNA_SWITCH 21 // pin for switching wifi antenna -#define WIFI_ANTENNA 0 // 0 = internal, 1 = external \ No newline at end of file +#define WIFI_ANTENNA 0 // 0 = internal, 1 = external + +// !!EXPERIMENTAL - not tested yet!! +// uncomment this only if your LoPy runs 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_QUECTEL_L76 GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21) +//#define GPS_ADDR 0x10 +//#define HAS_BUTTON GPIO_NUM_37 // (P14) +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown + +// uncomment this only if your LoPy runs on a expansion board 3.0 +//#define HAS_BATTERY_PROBE ADC1_GPIO39_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 +//#define BATT_FACTOR 2 // voltage divider 1MOhm/1MOhm on board +//#define HAS_BUTTON GPIO_NUM_37 // (P14) +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown + +// uncomment this only if your LoPy runs on a expansion board 2.0 +//#define HAS_BATTERY_PROBE ADC1_GPIO39_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 +//#define BATT_FACTOR 4 // voltage divider 115kOhm/56kOhm on board +//#define HAS_BUTTON GPIO_NUM_13 // (P10) +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown \ No newline at end of file diff --git a/src/hal/ttgov21.h b/src/hal/ttgov21.h index 96617e1f..6f4d1255 100644 --- a/src/hal/ttgov21.h +++ b/src/hal/ttgov21.h @@ -1,12 +1,19 @@ -// Hardware related definitions for TTGO V2.1 Board +/* 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" +*/ + #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_G3 (not in initial board version) -#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 -#define BATT_FACTOR 2 // voltage divider 100k/100k on board +#define HAS_LED GPIO_NUM_23 // green on board LED (new board ONLY) +#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7 (new board ONLY) +#define BATT_FACTOR 2 // voltage divider 100k/100k on board (new board ONLY) // 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 @@ -15,7 +22,9 @@ #define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input // non arduino pin definitions -#define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN +#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 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