v1.6.996
This commit is contained in:
parent
48cbcd40cd
commit
9574a194fd
@ -53,7 +53,8 @@ Target platform must be selected in [platformio.ini](https://github.com/cyberman
|
||||
Hardware dependent settings (pinout etc.) are stored in board files in /hal directory. If you want to use a ESP32 board which is not yet supported, use hal file generic.h and tailor pin mappings to your needs. Pull requests for new boards welcome.<br>
|
||||
|
||||
<b>3D printable cases</b> can be found (and, if wanted so, ordered) on Thingiverse, see
|
||||
<A HREF="https://www.thingiverse.com/thing:2670713">Heltec</A>, <A HREF="https://www.thingiverse.com/thing:2811127">TTGOv2</A>, <A HREF="https://www.thingiverse.com/thing:3005574">TTGOv2.1</A>, <A HREF="https://www.thingiverse.com/thing:3041339">T-BEAM</A> for example.<br>
|
||||
<A HREF="https://www.thingiverse.com/thing:2670713">Heltec</A>, <A HREF="https://www.thingiverse.com/thing:2811127">TTGOv2</A>, <A HREF="https://www.thingiverse.com/thing:3005574">TTGOv2.1</A>, <A HREF="https://www.thingiverse.com/thing:3041339">T-BEAM</A>,
|
||||
<A HREF="https://www.thingiverse.com/thing:3203177">T-BEAM parts</A> for example.<br>
|
||||
|
||||
<b>Power consumption</b> was metered at around 450 - 1000mW, depending on board and user settings in paxcounter.conf.
|
||||
By default bluetooth sniffing is disabled (line *#define BLECOUNTER* in paxcounter.conf is commented out). Enabling bluetooth costs 30% more power + 30% flash storage for the software stack. Proof of concept showed that for passenger flow metering wifi sniffing shows better results than bluetooth sniffing. If you enable bluetooth be aware that this goes on expense of wifi sniffing results, because then wifi and bt stack must share the 2,4 GHz RF ressources of ESP32. If you need to sniff wifi and bt in parallel and need best possible results, use two boards - one for wifi only and one for bt only - and add counted results.
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "globals.h"
|
||||
#include <Wire.h>
|
||||
#include "bsec_integration.h"
|
||||
#include "irqhandler.h"
|
||||
|
||||
extern const uint8_t bsec_config_iaq[454];
|
||||
|
||||
|
@ -71,14 +71,14 @@ typedef struct {
|
||||
} gpsStatus_t;
|
||||
|
||||
typedef struct {
|
||||
float iaq; // IAQ signal
|
||||
uint8_t iaq_accuracy; // accuracy of IAQ signal
|
||||
float temperature; // temperature signal
|
||||
float humidity; // humidity signal
|
||||
float pressure; // pressure signal
|
||||
float raw_temperature; // raw temperature signal
|
||||
float raw_humidity; // raw humidity signal
|
||||
float gas; // raw gas sensor signal
|
||||
float iaq; // IAQ signal
|
||||
uint8_t iaq_accuracy; // accuracy of IAQ signal
|
||||
float temperature; // temperature signal
|
||||
float humidity; // humidity signal
|
||||
float pressure; // pressure signal
|
||||
float raw_temperature; // raw temperature signal
|
||||
float raw_humidity; // raw humidity signal
|
||||
float gas; // raw gas sensor signal
|
||||
} bmeStatus_t;
|
||||
|
||||
// global variables
|
||||
@ -86,9 +86,9 @@ extern configData_t cfg; // current device configuration
|
||||
extern char display_line6[], display_line7[]; // screen buffers
|
||||
extern uint8_t volatile channel; // wifi channel rotation counter
|
||||
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
|
||||
batt_voltage; // display values
|
||||
extern std::set<uint16_t> macs; // temp storage for MACs
|
||||
extern hw_timer_t *channelSwitch, *sendCycle;
|
||||
batt_voltage; // display values
|
||||
extern std::set<uint16_t> macs; // temp storage for MACs
|
||||
extern hw_timer_t *channelSwitch, *sendCycle, *displaytimer;
|
||||
|
||||
extern std::array<uint64_t, 0xff>::iterator it;
|
||||
extern std::array<uint64_t, 0xff> beacons;
|
||||
|
@ -30,13 +30,13 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 1.6.995
|
||||
release_version = 1.6.996
|
||||
; 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 = 0
|
||||
; UPLOAD MODE: select esptool to flash via USB/UART, select custom to upload to cloud for OTA
|
||||
upload_protocol = esptool
|
||||
;upload_protocol = custom
|
||||
;upload_protocol = esptool
|
||||
upload_protocol = custom
|
||||
extra_scripts = pre:build.py
|
||||
keyfile = ota.conf
|
||||
;platform_espressif32 = espressif32@1.5.0
|
||||
|
@ -8,7 +8,7 @@ static const char TAG[] = "main";
|
||||
bmeStatus_t bme_status;
|
||||
TaskHandle_t BmeTask;
|
||||
|
||||
float bme_offset = (float) BME_TEMP_OFFSET;
|
||||
float bme_offset = (float)BME_TEMP_OFFSET;
|
||||
|
||||
// --- Bosch BSEC library configuration ---
|
||||
// 3,3V supply voltage; 3s max time between sensor_control calls; 4 days
|
||||
@ -59,7 +59,7 @@ int bme_init(void) {
|
||||
return_values_init ret =
|
||||
bsec_iot_init(BSEC_SAMPLE_RATE_LP, bme_offset, i2c_write, i2c_read,
|
||||
user_delay_ms, state_load, config_load);
|
||||
|
||||
|
||||
if ((int)ret.bme680_status) {
|
||||
ESP_LOGE(TAG, "Could not initialize BME680, error %d",
|
||||
(int)ret.bme680_status);
|
||||
|
@ -26,8 +26,8 @@ void doHousekeeping() {
|
||||
// time sync once per TIME_SYNC_INTERVAL
|
||||
#ifdef TIME_SYNC_INTERVAL
|
||||
if (millis() >= nextTimeSync) {
|
||||
nextTimeSync = millis() + TIME_SYNC_INTERVAL *
|
||||
60000; // set up next time sync period
|
||||
nextTimeSync =
|
||||
millis() + TIME_SYNC_INTERVAL * 60000; // set up next time sync period
|
||||
do_timesync();
|
||||
}
|
||||
#endif
|
||||
@ -62,8 +62,8 @@ void doHousekeeping() {
|
||||
"free heap = %d bytes)",
|
||||
esp_get_minimum_free_heap_size(), ESP.getFreeHeap());
|
||||
SendPayload(COUNTERPORT); // send data before clearing counters
|
||||
reset_counters(); // clear macs container and reset all counters
|
||||
get_salt(); // get new salt for salting hashes
|
||||
reset_counters(); // clear macs container and reset all counters
|
||||
get_salt(); // get new salt for salting hashes
|
||||
|
||||
if (esp_get_minimum_free_heap_size() <= MEM_LOW) // check again
|
||||
do_reset(); // memory leak, reset device
|
||||
@ -89,7 +89,8 @@ void reset_counters() {
|
||||
|
||||
void do_timesync() {
|
||||
#ifdef TIME_SYNC_INTERVAL
|
||||
// sync time & date if we have valid gps time
|
||||
|
||||
// sync time & date by GPS if we have valid gps time
|
||||
#ifdef HAS_GPS
|
||||
if (gps.time.isValid()) {
|
||||
setTime(gps.time.hour(), gps.time.minute(), gps.time.second(),
|
||||
@ -101,9 +102,14 @@ void do_timesync() {
|
||||
ESP_LOGI(TAG, "No valid GPS time");
|
||||
}
|
||||
#endif // HAS_GPS
|
||||
|
||||
// sync time by LoRa Network if network supports DevTimeReq
|
||||
#ifdef LMIC_ENABLE_DeviceTimeReq
|
||||
// Schedule a network time request at the next possible time
|
||||
LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime);
|
||||
ESP_LOGI(TAG, "Network time request scheduled");
|
||||
#endif
|
||||
|
||||
#endif // TIME_SYNC_INTERVAL
|
||||
} // do_timesync()
|
||||
|
||||
|
@ -121,8 +121,7 @@ void refreshtheDisplay() {
|
||||
// update Battery status (line 2)
|
||||
#ifdef HAS_BATTERY_PROBE
|
||||
u8x8.setCursor(0, 2);
|
||||
u8x8.printf(batt_voltage > 4000 ? "B:USB " : "B:%.1fV",
|
||||
batt_voltage / 1000.0);
|
||||
u8x8.printf("B:%.1fV", batt_voltage / 1000.0);
|
||||
#endif
|
||||
|
||||
// update GPS status (line 2)
|
||||
|
@ -13,13 +13,20 @@
|
||||
// BME680 sensor on I2C bus
|
||||
// don't forget to connect SDIO of BME680 to GND for selecting i2c addr 0x76
|
||||
//
|
||||
//#define HAS_BME GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
|
||||
#define HAS_BME GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
|
||||
|
||||
#define HAS_LED GPIO_NUM_14 // on board green LED
|
||||
|
||||
// user defined sensors
|
||||
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||
|
||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (21)
|
||||
#define MY_OLED_SCL (22)
|
||||
#define MY_OLED_RST (NOT_A_PIN)
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||
#define BOARD_HAS_PSRAM // use extra 4MB external RAM
|
||||
|
@ -61,7 +61,7 @@ void IRAM_ATTR SendCycleIRQ() {
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
void IRAM_ATTR DisplayIRQ() {
|
||||
xTaskNotifyFromISR(irqHandlerTask, DISPLAY_IRQ, eSetBits, NULL);
|
||||
xTaskNotifyFromISR(irqHandlerTask, DISPLAY_IRQ, eSetBits, NULL);
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@
|
||||
//#define LMIC_USE_INTERRUPTS
|
||||
|
||||
//time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3)
|
||||
#define LMIC_ENABLE_DeviceTimeReq 1
|
||||
//#define LMIC_ENABLE_DeviceTimeReq 1
|
||||
|
||||
// 16 μs per tick
|
||||
// LMIC requires ticks to be 15.5μs - 100 μs long
|
||||
@ -34,7 +34,7 @@
|
||||
// faster or slower. This causes the transceiver to be earlier switched on,
|
||||
// so consuming more power. You may sharpen (reduce) this value if you are
|
||||
// limited on battery.
|
||||
#define CLOCK_ERROR_PROCENTAGE 20
|
||||
#define CLOCK_ERROR_PROCENTAGE 3
|
||||
|
||||
// Set this to 1 to enable some basic debug output (using printf) about
|
||||
// RF settings used during transmission and reception. Set to 2 to
|
||||
|
12
src/main.cpp
12
src/main.cpp
@ -54,7 +54,7 @@ configData_t cfg; // struct holds current device configuration
|
||||
char display_line6[16], display_line7[16]; // display buffers
|
||||
uint8_t volatile channel = 0; // channel rotation counter
|
||||
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
|
||||
batt_voltage = 0; // globals for display
|
||||
batt_voltage = 0; // globals for display
|
||||
|
||||
hw_timer_t *channelSwitch = NULL, *sendCycle = NULL, *homeCycle = NULL,
|
||||
*displaytimer = NULL; // irq tasks
|
||||
@ -105,9 +105,15 @@ void setup() {
|
||||
chip_info.revision, spi_flash_get_chip_size() / (1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
|
||||
: "external");
|
||||
ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion());
|
||||
ESP_LOGI(TAG, "Internal Total heap %d, internal Free Heap %d",
|
||||
ESP.getHeapSize(), ESP.getFreeHeap());
|
||||
ESP_LOGI(TAG, "SPIRam Total heap %d, SPIRam Free Heap %d", ESP.getPsramSize(),
|
||||
ESP.getFreePsram());
|
||||
ESP_LOGI(TAG, "ChipRevision %d, Cpu Freq %d, SDK Version %s",
|
||||
ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
|
||||
ESP_LOGI(TAG, "Flash Size %d, Flash Speed %d", ESP.getFlashChipSize(),
|
||||
ESP.getFlashChipSpeed());
|
||||
ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", esp_coex_version_get());
|
||||
ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap());
|
||||
|
||||
#ifdef HAS_GPS
|
||||
ESP_LOGI(TAG, "TinyGPS+ v%s", TinyGPSPlus::libraryVersion());
|
||||
|
@ -81,7 +81,7 @@
|
||||
#define RESPONSE_TIMEOUT_MS 60000 // firmware binary server connection timeout [milliseconds]
|
||||
|
||||
// setting for syncing time of node
|
||||
//#define TIME_SYNC_INTERVAL 60 // sync time each ... minutes [default = 60], comment out means off
|
||||
#define TIME_SYNC_INTERVAL 60 // sync time each ... minutes [default = 60], comment out means off
|
||||
|
||||
// LMIC settings
|
||||
// moved to src/lmic_config.h
|
@ -54,8 +54,6 @@ void wifi_sniffer_init(void) {
|
||||
ESP_ERROR_CHECK(esp_coex_preference_set(
|
||||
ESP_COEX_PREFER_BALANCE)); // configure Wifi/BT coexist lib
|
||||
|
||||
coex_deinit();
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
|
||||
ESP_ERROR_CHECK(
|
||||
esp_wifi_set_country(&wifi_country)); // set locales for RF and channels
|
||||
|
Loading…
Reference in New Issue
Block a user