commit
0c584f0f1b
12
README.md
12
README.md
@ -171,7 +171,7 @@ Output of sensor and peripheral data is internally switched by a bitmask registe
|
||||
|
||||
| Bit | Sensordata | Default
|
||||
| --- | ------------- | -------
|
||||
| 0 | GPS | off*
|
||||
| 0 | GPS* | on
|
||||
| 1 | Beacon alarm | on
|
||||
| 2 | BME280/680 | on
|
||||
| 3 | Paxcounter | on
|
||||
@ -190,6 +190,12 @@ Paxcounter can keep it's time-of-day synced with an external time source. Set *#
|
||||
|
||||
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 via https://opensensemap.org/
|
||||
This describes how to set up a mobile PaxCounter:
|
||||
Follow all steps so far for preparing the device, use the packed payload format. In paxcounter.conf set PAYLOAD_OPENSENSEBOX to 1. Register a new sensbox on https://opensensemap.org/.
|
||||
There in the sensor configuration select "TheThingsNetwork" and set Decoding Profil to "LoRa serialization", enter your TTN Application and Device Id. Decoding option has to be
|
||||
[{"decoder":"latLng"},{"decoder":"uint16","sensor_id":"yoursensorid"}]
|
||||
|
||||
# Payload format
|
||||
|
||||
You can select different payload formats in [paxcounter.conf](src/paxcounter.conf#L12):
|
||||
@ -213,7 +219,6 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
|
||||
[**packed_decoder.js**](src/TTN/packed_decoder.js) |
|
||||
[**packed_converter.js**](src/TTN/packed_converter.js)
|
||||
|
||||
|
||||
**Port #1:** Paxcount data
|
||||
|
||||
byte 1-2: Number of unique devices, seen on Wifi
|
||||
@ -308,7 +313,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
||||
0x03 set GPS data on/off
|
||||
|
||||
0 = GPS data off
|
||||
1 = GPS data on, sends GPS data on port 4, if GPS is present and has a fix [default]
|
||||
1 = GPS data on, sends GPS data on port 4 (default, use port 1 for mobile pax counter), if GPS is present and has a fix
|
||||
|
||||
0x04 set display on/off
|
||||
|
||||
@ -501,3 +506,4 @@ Thanks to
|
||||
- [robbi5](https://github.com/robbi5) for the payload converter
|
||||
- [terrillmoore](https://github.com/mcci-catena) for maintaining the LMIC for arduino LoRaWAN stack
|
||||
- [sbamueller](https://github.com/sbamueller) for writing the tutorial in Make Magazine
|
||||
- [Stefan](https://github.com/nerdyscout) for paxcounter opensensebox integration
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
||||
[board]
|
||||
;halfile = generic.h
|
||||
halfile = generic.h
|
||||
;halfile = ebox.h
|
||||
;halfile = eboxtube.h
|
||||
;halfile = ecopower.h
|
||||
@ -18,7 +18,7 @@
|
||||
;halfile = ttgov21old.h
|
||||
;halfile = ttgov21new.h
|
||||
;halfile = ttgofox.h
|
||||
halfile = ttgobeam.h
|
||||
;halfile = ttgobeam.h
|
||||
;halfile = ttgobeam10.h
|
||||
;halfile = fipy.h
|
||||
;halfile = lopy.h
|
||||
@ -43,10 +43,10 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 1.9.81
|
||||
release_version = 1.9.82
|
||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||
debug_level = 4
|
||||
debug_level = 3
|
||||
extra_scripts = pre:build.py
|
||||
otakeyfile = ota.conf
|
||||
lorakeyfile = loraconf.h
|
||||
|
@ -18,6 +18,14 @@ function Decoder(bytes, port) {
|
||||
if (bytes.length === 4) {
|
||||
return decode(bytes, [uint16, uint16], ['wifi', 'ble']);
|
||||
}
|
||||
// combined wifi counter and gps data, used by https://opensensemap.org
|
||||
if (bytes.length === 10) {
|
||||
return decode(bytes, [latLng, latLng, uint16], ['latitude', 'longitude', 'wifi']);
|
||||
}
|
||||
// combined wifi + ble counter and gps data, used by https://opensensemap.org
|
||||
if (bytes.length === 12) {
|
||||
return decode(bytes, [latLng, latLng, uint16, uint16], ['latitude', 'longitude', 'wifi', 'ble']);
|
||||
}
|
||||
// combined wifi counter and gps data
|
||||
if (bytes.length === 15) {
|
||||
return decode(bytes, [uint16, latLng, latLng, uint8, hdop, altitude], ['wifi', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
||||
@ -42,8 +50,12 @@ function Decoder(bytes, port) {
|
||||
|
||||
if (port === 4) {
|
||||
// gps data
|
||||
if (bytes.length === 8) {
|
||||
return decode(bytes, [latLng, latLng], ['latitude', 'longitude']);
|
||||
} else {
|
||||
return decode(bytes, [latLng, latLng, uint8, hdop, altitude], ['latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
||||
}
|
||||
}
|
||||
|
||||
if (port === 5) {
|
||||
// button pressed
|
||||
|
@ -9,9 +9,9 @@ nvs_handle my_handle;
|
||||
esp_err_t err;
|
||||
|
||||
#define PAYLOADMASK \
|
||||
((ALARM_DATA | MEMS_DATA | COUNT_DATA | SENSOR1_DATA | SENSOR2_DATA | \
|
||||
SENSOR3_DATA) & \
|
||||
(~BATT_DATA) & (~GPS_DATA))
|
||||
((GPS_DATA | ALARM_DATA | MEMS_DATA | COUNT_DATA | \
|
||||
SENSOR1_DATA | SENSOR2_DATA | SENSOR3_DATA) & \
|
||||
(~BATT_DATA) )
|
||||
|
||||
// populate cfg vars with factory settings
|
||||
void defaultConfig() {
|
||||
|
@ -34,9 +34,9 @@ IDLE 0 0 ESP32 arduino scheduler -> runs wifi sniffer
|
||||
lmictask 1 2 MCCI LMiC LORAWAN stack
|
||||
clockloop 1 4 generates realtime telegrams for external clock
|
||||
timesync_req 1 3 processes realtime time sync requests
|
||||
irqhandler 1 1 display, timesync, gps, etc. triggered by timers
|
||||
irqhandler 1 1 cyclic tasks (i.e. displayrefresh) triggered by timers
|
||||
gpsloop 1 1 reads data from GPS via serial or i2c
|
||||
lorasendtask 1 1 feed data from lora sendqueue to lmcic
|
||||
lorasendtask 1 1 feeds data from lora sendqueue to lmcic
|
||||
IDLE 1 0 ESP32 arduino scheduler -> runs wifi channel rotator
|
||||
|
||||
Low priority numbers denote low priority tasks.
|
||||
|
@ -47,6 +47,7 @@
|
||||
#define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle
|
||||
#define RETRANSMIT_RCMD 5 // [seconds] wait time before retransmitting rcommand results
|
||||
#define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit
|
||||
#define PAYLOAD_OPENSENSEBOX 0 // send payload compatible to sensebox.de (swap geo position and pax data)
|
||||
#define LORADRDEFAULT 5 // 0 .. 15, LoRaWAN datarate, according to regional LoRaWAN specs [default = 5]
|
||||
#define LORATXPOWDEFAULT 14 // 0 .. 255, LoRaWAN TX power in dBm [default = 14]
|
||||
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy
|
||||
@ -92,7 +93,7 @@
|
||||
#define RCMDPORT 2 // remote commands
|
||||
#define STATUSPORT 2 // remote command results
|
||||
#define CONFIGPORT 3 // config query results
|
||||
#define GPSPORT 4 // gps - set to 1 to send combined GPS+COUNT payload
|
||||
#define GPSPORT 4 // gps - set to 1 to send combined GPS+COUNTERPORT payload
|
||||
#define BUTTONPORT 5 // button pressed signal
|
||||
#define BEACONPORT 6 // beacon alarms
|
||||
#define BMEPORT 7 // BME680 sensor
|
||||
|
@ -89,12 +89,14 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
|
||||
buffer[cursor++] = (byte)((value.longitude & 0x00FF0000) >> 16);
|
||||
buffer[cursor++] = (byte)((value.longitude & 0x0000FF00) >> 8);
|
||||
buffer[cursor++] = (byte)((value.longitude & 0x000000FF));
|
||||
#if (!PAYLOAD_OPENSENSEBOX)
|
||||
buffer[cursor++] = value.satellites;
|
||||
buffer[cursor++] = highByte(value.hdop);
|
||||
buffer[cursor++] = lowByte(value.hdop);
|
||||
buffer[cursor++] = highByte(value.altitude);
|
||||
buffer[cursor++] = lowByte(value.altitude);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void PayloadConvert::addSensor(uint8_t buf[]) {
|
||||
@ -193,10 +195,12 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp,
|
||||
void PayloadConvert::addGPS(gpsStatus_t value) {
|
||||
#if(HAS_GPS)
|
||||
writeLatLng(value.latitude, value.longitude);
|
||||
#if (!PAYLOAD_OPENSENSEBOX)
|
||||
writeUint8(value.satellites);
|
||||
writeUint16(value.hdop);
|
||||
writeUint16(value.altitude);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void PayloadConvert::addSensor(uint8_t buf[]) {
|
||||
|
@ -58,6 +58,7 @@ void sendData() {
|
||||
|
||||
uint8_t bitmask = cfg.payloadmask;
|
||||
uint8_t mask = 1;
|
||||
gpsStatus_t gps_status;
|
||||
|
||||
while (bitmask) {
|
||||
switch (bitmask & mask) {
|
||||
@ -65,21 +66,28 @@ void sendData() {
|
||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
||||
case COUNT_DATA:
|
||||
payload.reset();
|
||||
#if !(PAYLOAD_OPENSENSEBOX)
|
||||
if (cfg.wifiscan)
|
||||
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
||||
if (cfg.blescan)
|
||||
payload.addCount(macs_ble, MAC_SNIFF_BLE);
|
||||
|
||||
#if (HAS_GPS) && (GPSPORT == 1)
|
||||
#endif
|
||||
#if (HAS_GPS)
|
||||
if (GPSPORT == COUNTERPORT) {
|
||||
// send GPS position only if we have a fix
|
||||
if (gps.location.isValid()) {
|
||||
gpsStatus_t gps_status;
|
||||
gps_storelocation(&gps_status);
|
||||
payload.addGPS(gps_status);
|
||||
} else
|
||||
ESP_LOGD(TAG, "No valid GPS position");
|
||||
}
|
||||
#endif
|
||||
#if (PAYLOAD_OPENSENSEBOX)
|
||||
if (cfg.wifiscan)
|
||||
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
||||
if (cfg.blescan)
|
||||
payload.addCount(macs_ble, MAC_SNIFF_BLE);
|
||||
#endif
|
||||
|
||||
SendPayload(COUNTERPORT, prio_normal);
|
||||
// clear counter if not in cumulative counter mode
|
||||
if (cfg.countermode != 1) {
|
||||
@ -102,17 +110,18 @@ void sendData() {
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (HAS_GPS) && (GPSPORT != 1)
|
||||
#if (HAS_GPS)
|
||||
case GPS_DATA:
|
||||
if (GPSPORT != COUNTERPORT) {
|
||||
// send GPS position only if we have a fix
|
||||
if (gps.location.isValid()) {
|
||||
gpsStatus_t gps_status;
|
||||
gps_storelocation(&gps_status);
|
||||
payload.reset();
|
||||
payload.addGPS(gps_status);
|
||||
SendPayload(GPSPORT, prio_high);
|
||||
} else
|
||||
ESP_LOGD(TAG, "No valid GPS position");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user