Configuration
Sensors and Peripherals
You can add up to 3 user defined sensors. Insert your sensor's payload scheme in sensor.cpp
. More examples and a detailed description can be found in the sensor documentation.
Supported Peripherals
- Bosch BMP180 / BME280 / BMP280 / BMP680
- SDS011
- RTC DS3231
- generic serial NMEA GPS
- I2C Lopy GPS
For these peripherals no additional code is needed. To activate configure them in the board's hal file before building the code.
See generic.h
for all options and for proper configuration of BME280/BME680.
shared/hal/generic.h | |
---|---|
shared/hal/generic.h | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
Output of user sensor data can be switched by user remote control command 0x14
sent to Port 2.
Output of sensor and peripheral data is internally switched by a bitmask register. Default mask can be tailored by editing cfg.payloadmask initialization value in configmanager.cpp
following this scheme:
Bit | Sensordata | Default |
---|---|---|
0 | Paxcounter | on |
1 | unused | off |
2 | BME280/680 | on |
3 | GPS* | on |
4 | User sensor 1 | on |
5 | User sensor 2 | on |
6 | User sensor 3 | on |
7 | Batterylevel | off |
*) GPS data can also be combined with paxcounter payload on port 1, #define GPSPORT 1
in paxcounter.conf to enable
shared/paxcounter_orig.conf | |
---|---|
Power saving mode
Paxcounter supports a battery friendly power saving mode. In this mode the device enters deep sleep, after all data is polled from all sensors and the dataset is completeley sent through all user configured channels (LORAWAN / SPI / MQTT / SD-Card). Set #define SLEEPCYCLE
in paxcounter.conf to enable power saving mode and to specify the duration of a sleep cycle.
shared/paxcounter_orig.conf | |
---|---|
Power consumption in deep sleep mode depends on your hardware, i.e. if on board peripherals can be switched off or set to a chip specific sleep mode either by MCU or by power management unit (PMU) as found on TTGO T-BEAM v1.0/V1.1. See power.cpp
for power management, and reset.cpp
for sleep and wakeup logic.
Time sync
Paxcounter can keep a time-of-day synced with external or on board time sources. Set #define TIME_SYNC_INTERVAL
in paxcounter.conf
to enable time sync.
shared/paxcounter_orig.conf | |
---|---|
Supported external time sources are GPS, LORAWAN network time and LORAWAN application timeserver time. Supported on board time sources are the RTC of ESP32 and a DS3231 RTC chip, both are kept sycned as fallback time sources. Time accuracy depends on board's time base which generates the pulse per second. Supported are GPS PPS, SQW output of RTC, and internal ESP32 hardware timer. Time base is selected by #defines in the board's hal file, see example in generic.h
.
shared/hal/generic.h | |
---|---|
Tip
If your LORAWAN network does not support network time, you can run a Node-Red timeserver application using the enclosed Timeserver code. Configure the MQTT nodes in Node-Red for the LORAWAN application used by your paxcounter device. Time can also be set without precision liability, by simple remote command, see section remote control.
Syncing multiple paxcounters
A fleet of paxcounters can be synchronized to keep all devices wake up and start scanning at the same time. Synchronization is based on top-of-hour as common time point of reference. This feature requires time-of-day to be present on each device. Thus, TIME_SYNC_INTERVAL
option, as explained above, must be enabled. Wake up syncing is enabled by setting SYNCWAKEUP
in paxcounter.conf
to a value X, in seconds, greater than zero, and smaller than SLEEPCYCLE
(in seconds/10). This defines a time window, centered at top-of-hour, sized +/- X seconds. If a device, returning from sleep, would wakeup within this time window, it's wakeup will be adjusted to top-of-hour.
Wall clock controller
Paxcounter can be used to sync a wall clock which has a DCF77 or IF482 time telegram input. Set #define HAS_IF482
or #define HAS_DCF77
in board's hal file to setup clock controller. Use case of this function is to integrate paxcounter and clock. Accurary of the synthetic DCF77 signal depends on accuracy of on board's time base, see above.
Mobile PaxCounter using openSenseMap
This describes how to set up a mobile PaxCounter:
Follow all steps so far for preparing the device, selecting the packed payload format. In paxcounter.conf
set PAYLOAD_OPENSENSEBOX
to 1
.
shared/paxcounter_orig.conf | |
---|---|
Register a new sensebox on https://opensensemap.org/. In the sensor configuration select "TheThingsNetwork" and set decoding profile to "LoRa serialization". Enter your TTN Application and Device ID. Setup decoding option using:
SD-card
Data can be stored on a FAT32 (pre-)formatted SD-card if the board provides an SD card interface, either with SPI or MMC mode. To enable this feature, specify interface mode and hardware pins in board's hal file (shared/hal/<board.h\>
):
#define HAS_SDCARD 1 // SD-card interface, using SPI mode
//OR
#define HAS_SDCARD 2 // SD-card interface, using MMC mode
// Pins for SPI interface
#define SDCARD_CS (13) // fill in the correct numbers for your board
#define SDCARD_MOSI (15)
#define SDCARD_MISO (2)
#define SDCARD_SCLK (14)
This is an example of a board with MMC SD-card interface: https://www.aliexpress.com/item/32915894264.html. For this board use file shared/hal/ttgov21new.h
and add the lines given above.
Another approach would be this tiny board: https://www.aliexpress.com/item/32424558182.html (needs 5V). In this case you choose the correct file for your ESP32-board in the shared/hal-directory and add the lines given above. Edit the pin numbers given in the example, according to your wiring.
Data is written on SD-card to a single file. After 3 write operations the data is flushed to the disk to minimize flash write cycles. Thus, up to the last 3 records of data will get lost when the Paxcounter looses power during operation.
Format of the resulting file is CSV, thus easy import in LibreOffice, Excel, InfluxDB, etc. Each record contains timestamp (in ISO8601 format), paxcount (wifi and ble) and battery voltage (optional). Voltage is logged if the device has a battery voltage sensor (to be configured in board hal file).
File contents example:
timestamp,wifi,ble[,voltage]
2022-01-30T21:12:41Z,11,25[,4100]
2022-01-30T21:14:24Z,10,21[,4070]
2022-01-30T21:16:08Z,12,26[,4102]
2022-01-30T21:17:52Z,11,26[,4076]
src/sdcard.cpp
and include/sdcard.h
.
Additionally, it's possible to redirect system console output to a plain text file on SD card. This can be useful for debugging headless devices in the field. In paxcounter.conf
set SDLOGGING
to 1
.
shared/paxcounter_orig.conf | |
---|---|