cyberman54 / ESP32-Paxcounter

Wifi & BLE driven passenger flow metering with cheap ESP32 boards

Home Page:https://cyberman54.github.io/ESP32-Paxcounter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GPS not starting and BME680 not sending data on Lilygo v2.1 New

proffalken opened this issue · comments

Hello :)

I just received my LILYGO V2.1 from the official store on AliExpress and I'm trying to get it working with my Neo 6M GPS dongle.

I've uncommented the required lines, connect the GPS serial as instructed, but it doesn't show in the logs as being connected.

I've also got a BME680 connected to the board, and this is recognised on startup, but data is not sent from the board as I'd expect it to.

The data for BLE and WiFi devices is recorded and sent to TTN, so I know that part of things is working fine, but I don't see any data on ports 4 (GPS) or 7(BME680).

Have I missed a step in the setup?

My paxcounter.conf

// clang-format off

// ----- Paxcounter user config file ------
//
// --> adapt to your needs and use case <--
//
// Notes:
// 1. After editing, before "build", use "clean" button in PlatformIO!
// 2. Clear NVRAM of the board to delete previous stored runtime settings (pio run -t erase)

// Device options
#define VERBOSE                         1       // set to 0 to silence the device, 1 enables additional debug output
#define BOOTMENU                        0       // 0 = no bootmenu, 1 = device brings up boot menu before starting application
#define BOOTDELAY                       30      // time [seconds] while devices waits in boot menue for input
#define BOOTTIMEOUT                     300     // time [seconds] while devices waits to finish upload a firmware file
#define SDLOGGING                       0       // set to 1 for system logging to SD card (if device has one)

// Payload send cycle and encoding
#define SENDCYCLE                       30      // payload send cycle [seconds/2], 0 .. 255
#define SLEEPCYCLE                      0       // sleep time after a send cycle [seconds/10], 0 .. 65535; 0 means no sleep [default = 0]
#define PAYLOAD_ENCODER                 2       // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed
#define COUNTERMODE                     0       // 0=cyclic, 1=cumulative, 2=cyclic confirmed
#define SYNCWAKEUP                      300     // shifts sleep wakeup to top-of-hour, when +/- X seconds off [0=off]

// default settings for transmission of sensor data (first list = data on / second line = data off)
#define PAYLOADMASK                                                                             \
            ((GPS_DATA | MEMS_DATA | COUNT_DATA | SENSOR1_DATA | SENSOR2_DATA | SENSOR3_DATA) & \
            (~BATT_DATA) & (~RESERVED_DATA))

// MAC sniffing settings
#define BLECOUNTER                      1       // set to 0 if you do not want to start the BLE sniffer
#define WIFICOUNTER                     1       // set to 0 if you do not want to start the WIFI sniffer
#define RSSILIMIT                       0       // 0...-128, set to 0 if you do not want to filter signals

// BLE scan parameters
#define BLESCANTIME                     0       // [seconds] scan duration, 0 means infinite [default], see note below
#define BLESCANWINDOW                   80      // [milliseconds] scan window, see below, 3 .. 10240, default 80ms
#define BLESCANINTERVAL                 80      // [illiseconds] scan interval, see below, 3 .. 10240, default 80ms = 100% duty cycle

/* Note: guide for setting bluetooth parameters
*
* |< Scan Window >       |< Scan Window >       | ... |< Scan Window >       |
* |<    Scan Interval   >|<    Scan Interval   >| ... |<    Scan Interval   >|
* |<                   Scan duration                                        >|
*
* Scan duration sets how long scanning should be going on, before starting a new scan cycle. 0 means infinite (default).
* Scan window sets how much of the interval should be occupied by scanning. Should be >= BLESCANINTERVAL.
* Scan interval is how long scanning should be done on each channel. BLE uses 3 channels for advertising.
* -> Adjust these values with power consumption in mind if power is limited.
* -> Scan interval can be changed during runtime by remote comammand.
*/

// WiFi scan parameters
#define WIFI_MY_COUNTRY                 "01"    // select 2-letter locale for Wifi RF settings, e.g. "DE"; use "01" for world safe mode
#define	WIFI_CHANNEL_SWITCH_INTERVAL    50      // [seconds/100] -> 0,5 sec.
#define WIFI_CHANNEL_MAP                WIFI_CHANNEL_ALL  // possible values see libpax_api.h

// LoRa payload default parameters
#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            1       // 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
#define SEND_QUEUE_SIZE                 10      // maximum number of messages in payload send queue [1 = no queue]

// Hardware settings
#define RGBLUMINOSITY                   30      // RGB LED luminosity [default = 30%]
#define DISPLAYREFRESH_MS               40      // OLED refresh cycle in ms [default = 40] -> 1000/40 = 25 frames per second
#define DISPLAYCONTRAST                 80      // 0 .. 255, OLED display contrast [default = 80]
#define DISPLAYCYCLE                    3       // Auto page flip delay in sec [default = 2] for devices without button
#define HOMECYCLE                       30      // house keeping cycle in seconds [default = 30 secs]

// Settings for BME680 environmental sensor
#define BME_TEMP_OFFSET                 5.0f    // Offset sensor on chip temp <-> ambient temp [default = 5°C]
#define STATE_SAVE_PERIOD               UINT32_C(360 * 60 * 1000) // update every 360 minutes = 4 times a day
#define BMECYCLE                        1       // bme sensor read cycle in seconds [default = 1 secs]

// OTA settings
#define USE_OTA                         1       // set to 0 to disable OTA update
#define WIFI_MAX_TRY                    5       // maximum number of wifi connect attempts for OTA update [default = 20]
#define OTA_MAX_TRY                     5       // maximum number of attempts for OTA download and write to flash [default = 3]
#define OTA_MIN_BATT                    50      // minimum battery level for OTA [percent]
#define RESPONSE_TIMEOUT_MS             60000   // firmware binary server connection timeout [milliseconds]

// settings for syncing time of node with a time source (network / gps / rtc / timeserver)
#define TIME_SYNC_LORAWAN               1       // set to 1 to use LORA network as time source, 0 means off [default = 1]
#define TIME_SYNC_LORASERVER            0       // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
#define TIME_SYNC_INTERVAL              60      // sync time attempt each .. minutes from time source [default = 60], 0 means off
#define TIME_SYNC_INTERVAL_RETRY        10      // retry time sync after lost sync each .. minutes [default = 10], 0 means off
#define TIME_SYNC_SAMPLES               1       // number of time requests for averaging, max. 255
#define TIME_SYNC_CYCLE                 60      // delay between two time samples [seconds]
#define TIME_SYNC_TIMEOUT               400     // timeout waiting for timeserver answer [seconds]
#define TIME_SYNC_COMPILEDATE           0       // set to 1 to use compile date to initialize RTC after power outage [default = 0]
#define TIME_SYNC_TIMEZONE              "CET-1CEST,M3.4.0/2,M10.4.0/3" // Timezone in POSIX format (example shows Germany/Berlin)

// Ports on which the device sends and listenes on LoRaWAN and SPI
#define COUNTERPORT                     1       // counts
#define MACPORT                         0       // network commands
#define RCMDPORT                        2       // remote commands
#define STATUSPORT                      2       // remote command results
#define CONFIGPORT                      3       // config query results
#define GPSPORT                         4       // gps - NOTE: set to 1 to send combined GPS+COUNTERPORT payload
#define BUTTONPORT                      5       // button pressed signal
#define RESERVEDPORT                    6       // reserved (unused)
#define BMEPORT                         7       // BME680 sensor
#define BATTPORT                        8       // battery voltage
#define TIMEPORT                        9       // time query and response
#define SENSOR1PORT                     10      // user sensor #1
#define SENSOR2PORT                     11      // user sensor #2
#define SENSOR3PORT                     12      // user sensor #3

// Cayenne LPP Ports, see https://community.mydevices.com/t/cayenne-lpp-2-0/7510
#define CAYENNE_LPP1                    1       // dynamic sensor payload (LPP 1.0)
#define CAYENNE_LPP2                    2       // packed sensor payload (LPP 2.0)
#define CAYENNE_GPS                     3       // full scale GPS payload
#define CAYENNE_ACTUATOR                10	    // actuator commands
#define CAYENNE_DEVICECONFIG            11	    // device period configuration
#define CAYENNE_SENSORREAD              13	    // sensor period configuration
#define CAYENNE_SENSORENABLE            14	    // sensor enable configuration

// MQTT settings, only needed if MQTT is used (#define HAS_MQTT in board hal file)
#define MQTT_ETHERNET 1 // select PHY: set 0 for Wifi, 1 for ethernet (Wifi not yet implemented!)
#define MQTT_INTOPIC "paxin"
#define MQTT_OUTTOPIC "paxout"
#define MQTT_PORT 1883
#define MQTT_SERVER "public.cloud.shiftr.io"
#define MQTT_USER "public"
#define MQTT_PASSWD "public"
#define MQTT_RETRYSEC 20  // retry reconnect every 20 seconds
#define MQTT_KEEPALIVE 10 // keep alive interval in seconds
//#define MQTT_CLIENTNAME "my_paxcounter" // generated by default

My shared/hal/generic.h file:

// clang-format off
// upload_speed 115200
// board esp32dev

#ifndef _GENERIC_H
#define _GENERIC_H

#include <stdint.h>

// Hardware related definitions for generic ESP32 boards
// generic.h is kitchensink with all available options

#define HAS_LORA 1 // comment out if device shall not send data via LoRa or has no LoRa
//#define HAS_SPI 1  // comment out if device shall not send data via SPI
// pin definitions for SPI slave interface
//#define SPI_MOSI GPIO_NUM_23
//#define SPI_MISO GPIO_NUM_19
//#define SPI_SCLK GPIO_NUM_18
//#define SPI_CS   GPIO_NUM_5

// enable only if you want to store a local paxcount table on the device
#define HAS_SDCARD  1      // this board has an SD-card-reader/writer
// Pins for SD-card
#define SDCARD_CS    (13)
#define SDCARD_MOSI  (15)
#define SDCARD_MISO  (2)
#define SDCARD_SCLK  (14)

// enable only if device has these sensors, otherwise comment these lines
// tutorial to connect BME sensor see here:
// https://sbamueller.wordpress.com/2019/02/26/paxcounter-mit-umweltsensor/
//
// in platformio.ini append
// lib_deps = <...> ${common.lib_deps_sensors}
// for loading necessary libraries

// BME680 sensor on I2C bus
#define HAS_BME 1 // Enable BME sensors in general
#define HAS_BME680 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
//#define BME680_ADDR BME68X_I2C_ADDR_LOW // connect SDIO of BME680 to GND

// BME280 sensor on I2C bus
//#define HAS_BME 1 // Enable BME sensors in general
//#define HAS_BME280 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
//#define BME280_ADDR 0x76 // change to 0x77 depending on your wiring

// BMP180 sensor on I2C bus
//#define HAS_BMP180
//#define BMP180_ADDR 0x77

// SDS011 dust sensor settings
//#define HAS_SDS011 1 // use SDS011
// used pins on the ESP-side:
//#define SDS_TX 19     // connect to RX on the SDS011
//#define SDS_RX 23     // connect to TX on the SDS011

// up to three user defined sensors (if connected)
//#define HAS_SENSOR_1 1 // comment out if device has user defined sensor #1
//#define HAS_SENSOR_2 1 // comment out if device has user defined sensor #2
//#define HAS_SENSOR_3 1 // comment out if device has user defined sensor #3

#define CFG_sx1276_radio 1 // select LoRa chip
//#define CFG_sx1272_radio 1 // select LoRa chip
//#define BOARD_HAS_PSRAM // use if board has external SPIRAM, note: this will reduce IRAM0 by 64KB for SPIRAM cache
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature

//#define HAS_DISPLAY 1
//#define MY_DISPLAY_FLIP  1 // use if display is rotated
#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board

#define HAS_LED (21) // on board  LED
#define HAS_BUTTON (39) // on board button
//#define RGB_LED_COUNT 1 // we have 1 LED
//#define HAS_RGB_LED FastLED.addLeds<WS2812, GPIO_NUM_0, GRB>(leds, RGB_LED_COUNT);

// GPS settings
#define HAS_GPS 1 // use on board GPS
#define GPS_SERIAL 9600, SERIAL_8N1, GPIO_NUM_12, GPIO_NUM_15 // UBlox NEO 6M RX, TX
//#define GPS_INT GPIO_NUM_13 // 30ns accurary timepulse, to be external wired on pcb: NEO 6M Pin#3 -> GPIO13

// Pins for I2C interface of OLED Display
//#define MY_DISPLAY_SDA (4)
//#define MY_DISPLAY_SCL (15)
//#define MY_DISPLAY_RST (16)

// Settings for on board DS3231 RTC chip
//#define HAS_RTC MY_DISPLAY_SDA, MY_DISPLAY_SCL // SDA, SCL
//#define RTC_INT GPIO_NUM_34 // timepulse with accuracy +/- 2*e-6 [microseconds] = 0,1728sec / day

// Settings for IF482 interface
//#define HAS_IF482 9600, SERIAL_7E1, GPIO_NUM_12, GPIO_NUM_14 // IF482 serial port parameters

// Settings for DCF77 interface
//#define HAS_DCF77 GPIO_NUM_1
//#define DCF77_ACTIVE_LOW 1

// Pins for LORA chip SPI interface, reset line and interrupt lines
#define LORA_SCK  (5) 
#define LORA_CS   (18)
#define LORA_MISO (19)
#define LORA_MOSI (27)
#define LORA_RST  (14)
#define LORA_IRQ  (26)
#define LORA_IO1  (33)
#define LORA_IO2  LMIC_UNUSED_PIN

#endif

My platformio.ini file:

; ---> SELECT ONE TARGET BOARD FROM FOLLOWING ROWS <---
;
; Note: For "LILYGO TTGO ESP32-Paxcounter LoRa32 V2.1 1.6.1" select board ttgov21new.h
; Note: For "LILYGO TTGO ESP32-Paxcounter LoRa32 V2.0 1.6.0" select board ttgov2.h and add bodge wire from LORA_IO1 to GPIO33
;
;
[board]
;halfile = generic.h
;halfile = ebox.h
;halfile = eboxtube.h
;halfile = ecopower.h
;halfile = heltec.h
;halfile = heltecv2.h
;halfile = heltecv21.h
;halfile = ttgov1.h
;halfile = ttgov2.h
;halfile = ttgov21old.h
halfile = ttgov21new.h
;halfile = ttgofox.h
;halfile = ttgobeam.h
;halfile = ttgobeam10.h
;halfile = ttgotdisplay.h
;halfile = ttgotwristband.h
;halfile = fipy.h
;halfile = lopy.h
;halfile = lopy4.h
;halfile = lolin32litelora.h
;halfile = lolin32lora.h
;halfile = lolin32lite.h
;halfile = wemos32oled.h
;halfile = wemos32matrix.h
;halfile = octopus32.h
;halfile = tinypico.h
;halfile = tinypicomatrix.h
;halfile = m5core.h
;halfile = m5fire.h
;halfile = olimexpoeiso.h

[platformio]
; upload firmware to board with usb cable
default_envs = usb
; upload firmware to a paxexpress repository
;default_envs = ota
; use upstream version of arduino-espressif32 framework
;default_envs = dev
description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around.

[common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
release_version = 3.6.1
; 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 = 3
extra_scripts = pre:shared/build.py
otakeyfile = ota.conf
lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@6.4.0
monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_lora =
    mcci-catena/MCCI LoRaWAN LMIC library @ ^4.1.1
lib_deps_display =
    bitbank2/OneBitDisplay @ ^2.3.1
    bitbank2/bb_spi_lcd @ ^2.4.1
    ricmoo/QRCode @ ^0.0.1
lib_deps_ledmatrix =
    seeed-studio/Ultrathin_LED_Matrix @ ^1.0.0
lib_deps_rgbled =
    fastled/FastLED @ ^3.6.0
lib_deps_gps =
    mikalhart/TinyGPSPlus @ ^1.0.3
lib_deps_sensors =
    adafruit/Adafruit Unified Sensor @ ^1.1.13
    adafruit/Adafruit BME280 Library @ ^2.2.2
    adafruit/Adafruit BMP085 Library @ ^1.2.2
    boschsensortec/BSEC Software Library @ 1.8.1492
    lewapek/Nova Fitness Sds dust sensors library @ ^1.5.1
lib_deps_basic =
    https://github.com/dbSuS/libpax.git
    https://github.com/SukkoPera/Arduino-Rokkit-Hash.git
    bblanchon/ArduinoJson @ ^6.21.3
    makuna/RTC @ ^2.4.2
    mathertel/OneButton @ ^2.0.3
    lewisxhe/XPowersLib @ ^0.1.8
    256dpi/MQTT @ ^2.5.1
lib_deps_all =
    ${common.lib_deps_basic}
    ${common.lib_deps_lora}
    ${common.lib_deps_display}
    ${common.lib_deps_rgbled}
    ${common.lib_deps_gps}
    ${common.lib_deps_sensors}
    ${common.lib_deps_ledmatrix}
build_flags_all =
    -include "shared/paxcounter.conf"
    '-D CORE_DEBUG_LEVEL=${common.debug_level}'
    '-D LOG_LOCAL_LEVEL=${common.debug_level}'
    '-D PROGVERSION="${common.release_version}"'
    '-D LIBPAX_WIFI'
    '-D LIBPAX_BLE'
    '-D LIBPAX_ARDUINO'
    '-D USE_ESP_IDF_LOG'
    '-D TAG=__FILE__'
    '-U BOARD_HAS_PSRAM'

[env]
framework = arduino
board = esp32dev
board_build.partitions = min_spiffs.csv
build_type = release
upload_speed = ${common.upload_speed}
;upload_port = COM12
platform = ${common.platform_espressif32}
lib_deps = ${common.lib_deps_all}
build_flags =
    -include "shared/hal/${board.halfile}"
    ${common.build_flags_all}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
monitor_filters = time, esp32_exception_decoder, default

[env:ota]
upload_protocol = custom

[env:usb]
upload_protocol = esptool
upload_speed = 921600
monitor_speed = 115200
; necessary for macos - adjust devicename accordingly
;upload_port = /dev/tty.usbserial-xxxxxxx
;monitor_port = /dev/tty.usbserial-xxxxxxx

[env:dev]
upload_protocol = esptool
platform = https://github.com/platformio/platform-espressif32.git#develop
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

[env:ci]
build_flags =
    -include "shared/hal/${sysenv.CI_HALFILE}" ; set by CI
    ${common.build_flags_all}
upload_protocol = esptool

My logs:

20:01:23.335 > ets Jun  8 2016 00:22:57
20:01:23.335 > 
20:01:23.335 > rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
20:01:23.335 > configsip: 188777542, SPIWP:0xee
20:01:23.335 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:01:23.346 > mode:DIO, clock div:2
20:01:23.346 > load:0x3fff0030,len:1184
20:01:23.346 > load:0x40078000,len:13232
20:01:23.351 > load:0x40080400,len:3028
20:01:23.351 > entry 0x400805e4
20:01:23.906 > I (16) src/sdcard.cpp: looking for SD-card...
20:01:23.942 > E (46) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
20:01:23.942 > E (46) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
20:01:23.942 > I (46) src/sdcard.cpp: No SD-card found (263)
20:01:23.953 > I (50) src/configmanager.cpp: Loading device configuration from NVRAM...
20:01:23.953 > I (58) src/configmanager.cpp: Runtime configuration v3.6.1 loaded
20:01:23.964 > I (63) src/main.cpp: Starting paxcounter_11d2f6dd v3.6.1 (runmode=0 / restarts=0)
20:01:23.975 > I (69) src/main.cpp: code build date: 1709822600
20:01:23.975 > I (74) src/main.cpp: This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB embedded Flash
20:01:23.986 > I (83) src/main.cpp: Internal Total heap 223900, internal Free Heap 196140
20:01:23.986 > I (90) src/main.cpp: ChipRevision 1, Cpu Freq 240, SDK Version v4.4.5
20:01:23.997 > I (96) src/main.cpp: Flash Size 4194304, Flash Speed 40000000
20:01:23.997 > I (102) src/main.cpp: Wifi/BT software coexist version 1.2.0
20:01:24.009 > I (107) src/main.cpp: IBM LMIC version 1.6.1468577746
20:01:24.009 > I (112) src/main.cpp: Arduino LMIC version 4.1.1.0
20:01:24.020 > I (117) src/lorawan.cpp: DevEUI: E86BEA341754FEFF
20:01:24.020 > I (121) /home/mmw/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-i2c.c: Initialising I2C Master: sda=21 scl=22 freq=100000
20:01:24.031 > I (135) src/i2c.cpp: Starting I2C bus scan...
20:01:24.042 > W (138) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: Bus already started in Master Mode.
20:01:24.165 > I (269) src/i2c.cpp: Device found at 0x3C, type = Unknown
20:01:24.165 > I (270) src/i2c.cpp: Device found at 0x76, type = BME680
20:01:24.165 > I (270) src/i2c.cpp: 2 I2C device(s) found
20:01:24.176 > W (272) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: Bus already started in Master Mode.
20:01:34.321 > I (10425) src/main.cpp: Starting LED Controller...
20:01:34.322 > I (10425) src/power.cpp: ADC characterization based on reference voltage stored in eFuse
20:01:34.333 > I (10429) src/main.cpp: Starting libpax...
20:01:34.333 > I (10430) src/main.cpp: WIFISCAN: on
20:01:34.333 > I (10433) src/main.cpp: BLESCAN: on
20:01:34.341 > I (10437) .pio/libdeps/usb/libpax/lib/libpax/blescan.cpp: Initializing bluetooth scanner ...
20:01:35.046 > I (11153) .pio/libdeps/usb/libpax/lib/libpax/blescan.cpp: BLE Scanning started
20:01:35.247 > I (11354) .pio/libdeps/usb/libpax/lib/libpax/blescan.cpp: Bluetooth scanner started
20:01:35.260 > I (11363) src/main.cpp: Starting rcommand interpreter...
20:01:35.260 > I (11363) src/rcommand.cpp: Rcommand send queue created, size 55 Bytes
20:01:35.266 > I (11364) src/lorawan.cpp: LORA send queue created, size 530 Bytes
20:01:35.282 > I (11386) src/lorawan.cpp: Starting LMIC...
20:01:35.282 > I (11387) src/main.cpp: Starting Interrupt Handler...
20:01:35.282 > I (11387) src/main.cpp: Starting Timers...
20:01:36.317 > I (12420) src/timekeeper.cpp: Starting time pulse...
20:01:36.317 > I (12421) src/timekeeper.cpp: Timepulse: internal (ESP32 hardware timer)
20:01:37.313 > I (13421) src/main.cpp: Features: DISP LED BATT OTA LORA PACKED TIME
20:01:37.344 > I (13450) src/timesync.cpp: [13.456] Timeserver sync request started, seqNo#131
20:01:44.546 > I (20648) src/lorawan.cpp: DEVaddr: 0x260B3F94 | Network ID: 0x000013 | Network Type: 0
20:01:44.546 > I (20649) src/lorawan.cpp: RSSI: 5 | SNR: 6
20:01:44.553 > I (20650) src/lorawan.cpp: Radio parameters: SF7 | BW125 | CR 4/5

The TTN Output:

image

I've also tried copying the relevant lines into ttgov21new.h and that hasn't had an effect either:

// clang-format off
// upload_speed 921600
// board esp32dev

#ifndef _TTGOV21NEW_H
#define _TTGOV21NEW_H

#include <stdint.h>

/*  Hardware related definitions for TTGO V2.1 Board
// ATTENTION: check your board version!
// This settings are for boards labeled v1.6 or v1.6.1 on pcb, NOT for v1.5 or older
*/

#define HAS_LORA         1 // comment out if device shall not send data via LoRa
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC

// enable only if you want to store a local paxcount table on the device
#define HAS_SDCARD  2      // this board has a SD MMC card-reader/writer
#define SDCARD_SLOTWIDTH 4 // 4-line interface

#define HAS_DISPLAY 1
#define HAS_LED (25) // green on board LED
//#define HAS_LED NOT_A_PIN

#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board

// Pins for I2C interface of OLED Display
#define MY_DISPLAY_SDA (21)
#define MY_DISPLAY_SCL (22)
#define MY_DISPLAY_RST NOT_A_PIN

// Pins for LORA chip SPI interface, reset line and interrupt lines
#define LORA_SCK  (5) 
#define LORA_CS   (18)
#define LORA_MISO (19)
#define LORA_MOSI (27)
#define LORA_RST  (23)
#define LORA_IRQ  (26)
#define LORA_IO1  (33)
#define LORA_IO2  (32)


// BME680 sensor on I2C bus
#define HAS_BME 1 // Enable BME sensors in general
#define HAS_BME680 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
//#define BME680_ADDR BME68X_I2C_ADDR_LOW // connect SDIO of BME680 to GND

// GPS settings
#define HAS_GPS 1 // use on board GPS
#define GPS_SERIAL 9600, SERIAL_8N1, GPIO_NUM_12, GPIO_NUM_15 // UBlox NEO 6M RX, TX
//#define GPS_INT GPIO_NUM_13 // 30ns accurary timepulse, to be external wired on pcb: NEO 6M Pin#3 -> GPIO13
#endif

Logs:

20:13:04.152 > ets Jun  8 2016 00:22:57
20:13:04.152 > 
20:13:04.152 > rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
20:13:04.152 > configsip: 188777542, SPIWP:0xee
20:13:04.152 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:13:04.163 > mode:DIO, clock div:2
20:13:04.163 > load:0x3fff0030,len:1184
20:13:04.163 > load:0x40078000,len:13232
20:13:04.167 > load:0x40080400,len:3028
20:13:04.167 > entry 0x400805e4
20:13:04.723 > I (16) src/sdcard.cpp: looking for SD-card...
20:13:04.759 > E (46) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
20:13:04.760 > E (46) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
20:13:04.760 > I (46) src/sdcard.cpp: No SD-card found (263)
20:13:04.770 > I (50) src/configmanager.cpp: Loading device configuration from NVRAM...
20:13:04.770 > I (58) src/configmanager.cpp: Runtime configuration v3.6.1 loaded
20:13:04.781 > I (63) src/main.cpp: Starting paxcounter_11d2f6dd v3.6.1 (runmode=0 / restarts=0)
20:13:04.792 > I (69) src/main.cpp: code build date: 1709822600
20:13:04.792 > I (74) src/main.cpp: This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB embedded Flash
20:13:04.804 > I (83) src/main.cpp: Internal Total heap 223900, internal Free Heap 196140
20:13:04.804 > I (90) src/main.cpp: ChipRevision 1, Cpu Freq 240, SDK Version v4.4.5
20:13:04.815 > I (96) src/main.cpp: Flash Size 4194304, Flash Speed 40000000
20:13:04.815 > I (102) src/main.cpp: Wifi/BT software coexist version 1.2.0
20:13:04.826 > I (107) src/main.cpp: IBM LMIC version 1.6.1468577746
20:13:04.826 > I (112) src/main.cpp: Arduino LMIC version 4.1.1.0
20:13:04.837 > I (117) src/lorawan.cpp: DevEUI: E86BEA341754FEFF
20:13:04.837 > I (121) /home/mmw/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-i2c.c: Initialising I2C Master: sda=21 scl=22 freq=100000
20:13:04.848 > I (135) src/i2c.cpp: Starting I2C bus scan...
20:13:04.859 > W (138) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: Bus already started in Master Mode.
20:13:05.982 > I (1269) src/i2c.cpp: Device found at 0x3C, type = Unknown
20:13:05.982 > I (1271) src/i2c.cpp: Device found at 0x76, type = BME680
20:13:05.982 > I (1271) src/i2c.cpp: 2 I2C device(s) found
20:13:05.993 > W (1273) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: Bus already started in Master Mode.
20:13:16.139 > I (11426) src/main.cpp: Starting LED Controller...
20:13:16.139 > I (11426) src/power.cpp: ADC characterization based on reference voltage stored in eFuse
20:13:16.150 > I (11430) src/main.cpp: Starting libpax...
20:13:16.150 > I (11431) src/main.cpp: WIFISCAN: on
20:13:16.150 > I (11434) src/main.cpp: BLESCAN: on
20:13:16.159 > I (11438) .pio/libdeps/usb/libpax/lib/libpax/blescan.cpp: Initializing bluetooth scanner ...
20:13:16.868 > I (12158) .pio/libdeps/usb/libpax/lib/libpax/blescan.cpp: BLE Scanning started
20:13:17.069 > I (12359) .pio/libdeps/usb/libpax/lib/libpax/blescan.cpp: Bluetooth scanner started
20:13:17.081 > I (12368) src/main.cpp: Starting rcommand interpreter...
20:13:17.082 > I (12368) src/rcommand.cpp: Rcommand send queue created, size 55 Bytes
20:13:17.088 > I (12369) src/lorawan.cpp: LORA send queue created, size 530 Bytes
20:13:17.104 > I (12391) src/lorawan.cpp: Starting LMIC...
20:13:17.105 > I (12392) src/main.cpp: Starting Interrupt Handler...
20:13:17.105 > I (12393) src/main.cpp: Starting Timers...
20:13:18.139 > I (13425) src/timekeeper.cpp: Starting time pulse...
20:13:18.139 > I (13426) src/timekeeper.cpp: Timepulse: internal (ESP32 hardware timer)
20:13:19.134 > I (14426) src/main.cpp: Features: DISP LED BATT OTA LORA PACKED TIME
20:13:19.166 > I (14455) src/timesync.cpp: [14.461] Timeserver sync request started, seqNo#77

I spotted the bit in platform.io about running platformio run -t clean so did that and now I have an MD5 mismatch:

Wrote 1338960 bytes (856697 compressed) at 0x00010000 in 10.2 seconds (effective 1054.8 kbit/s)...
File  md5: a77fa4d1b614c30ef9dd28ac017ccdfa
Flash md5: 6422caf17eddc9261c09d6955031d580
MD5 of 0xFF is bf1d28f6275e0a4b6539ff8e3b7b7a98

A fatal error occurred: MD5 of file does not match data in flash!
*** [upload] Error 2

This appears to be because the GPS is connected on pin12, so I removed that and flashed it successfully, but I still don't see the GPS being started in the logs, and I'm still not getting BME680 data :(

  1. Check your GPS wiring: RX/TX swapped?
  2. Clear NVRAM by pio run -t erase
  3. Switch on GPS and BME data transmission by using rcommand 0x03 0x01 0x21 and 0x15 0x01 0x21

Thanks.

GPS wiring is correct (have checked and rechecked multiple times!) and after cleaning, clearing the NVRAM, and rebuilding logs now show:

12:48:10.232 > I (11373) src/gpsread.cpp: Opening serial GPS
12:48:10.448 > I (11594) src/main.cpp: Starting GPS Feed...

The GPS doesn't have a fix yet, so no data is being sent, but my understanding is that this is correct operating procedure.

The BME is also enabled, but I'm getting the following in the logs that means all the readings are zero:

12:48:10.500 > I (11645) src/bmesensor.cpp: BSEC v1.4.9.2
12:48:10.500 > I (11647) src/bmesensor.cpp: no BSEC state stored in NVRAM, starting sensor with defaults
12:48:10.512 > E (11647) src/bmesensor.cpp: BME680 error -2
12:48:10.512 > E (11650) src/main.cpp: BME sensor could not be initialized

This appears to be a comms error so I'll see if I've got a 280 or similar that I can swap in and test the connections with because the wiring is definitely correct.

Is there a list of the commands for enabling things like the SDS011 sesnsor? The manual seems to cover GPS, BME, and various other things, but not the SDS011 (unless that falls under "custom sensors"?)

OK, this looks like a pin config thing.

The defaults in the code suggest that the SDS011 should be on pins 19 & 23, however these are already in use on the TTGO v2.1 as MSIO and RST for the LORA module.

I'm going through and trying different pins to find a combination that works for the SDS011, then I'll come back to the GPS and the BME680 to work out the pins for those.

The BME680 is the one that's throwing me at the moment though, because that's I2C so it shouldn't matter that the OLED is already on that bus, and indeed I can see in my logs that both devices are picked up

BME680: you're probably using wrong chip address. Try enabling this line in ttgov21new.h file:

//#define BME680_ADDR BME68X_I2C_ADDR_LOW // connect SDIO of BME680 to GND

GPS: as long as it has no fix, there will be no data sent. Go outside to get a fix. Can take up to 20 minutes after a cold start.

SDS011: not sure if ttgov21 board has enough free GPIOs if you 're already using two GPIOs for serial GPS. Check the pinout. If you find free GPIOs you can drive SDS011 on this. Paxcounter firmware will pickup data of all sensors and GPS in parallel, no limitation.

SDS data is always sent, if an SDS011 is present. SDS payload is never masked, so no need and no option to switch on/off.

If you don't need wifi/ble sniffing in you application (e.g. using sensors only), you should disable it in paxcounter.conf to save power and cpu time.

//#define BME680_ADDR BME68X_I2C_ADDR_LOW // connect SDIO of BME680 to GND

Thanks, I'll do that tomorrow. FWIW I'm using 0x76 which is what it displays as in the logs when it's detected. Do I need to actually solder SDIO to GND in order for this to work?

SDS data is always sent, if an SDS011 is present. SDS payload is never masked, so no need and no option to switch on/off.

Thanks again, good to know, I'll check this out tomorrow as well.

If you don't need wifi/ble sniffing in you application (e.g. using sensors only), you should disable it in paxcounter.conf to save power and cpu time.

Of all the sensors I can do with out, it's probably the BME680, and then the GPS (this won't be mobile, it's just useful to have incase someone moves it).

This is for a "how many people are in the area vs. what's the air quality like" project, so the SDS011 and BLE/WiFi tracking are essential.

Just want to say thank you for both the project and your time btw - I remember seeing this idea way back in 2019 when I was running a LoRaWAN consultancy and wanted to use it back then but couldn't get the funding. It's an awesome project and I really appreciate the effort you've put into it! :)

GPS: as long as it has no fix, there will be no data sent. Go outside to get a fix. Can take up to 20 minutes after a cold start.

I'll try again tomorrow, but I had it outside for three hours with no data being sent. The "fix" LED on the NEO 6M module is flashing though, which suggests it is seeing something, but switching the TX/RX around doesn't seem to make a difference. I'll try a test sketch tomorrow as well to try and rule out the module.

BME680: I2c scanner detects your BME module at 0x76 = lower address, so probably your module does connect SDIO to GND. Thus, you must change the chip address on software side.

GPS: blinking LED on Neo 6M boards usually shows PPS pulse, this must not indicate it has a fix.

OK, I dropped the GPS and changed the code for the BME680 back to the one in the generic.h file.

I'm getting readings from the BME680 sensor now (along with a load of "error 263" in the logs that don't seem to be causing any harm!), and I can hear the SDS011 spinning up and taking readings so I'll leave it for a while and see if the zeros that it's sending back change after a few readings.

What is error 263, from where? BME680 lib/driver?

Yes, seems to be, but the readings are getting through:

The Ground had disconnected from the BME680 🤦

For referece these were the errors:

13:03:24.771 > I (9585549) src/cyclic.cpp: BME680 Temp: 15.97°C | IAQ: 50.00 | IAQacc: 0
13:03:27.740 > E (9588514) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: i2cRead returned Error 263
13:03:30.740 > E (9591514) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: i2cRead returned Error 263
13:03:33.740 > E (9594514) /home/mmw/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: i2cRead returned Error 263
13:03:49.665 > I (9610444) src/lorawan.cpp: 8 byte(s) sent to LORA
13:03:53.734 > I (9614511) src/cyclic.cpp: BME680 Temp: 15.60°C | IAQ: 50.00 | IAQacc: 0

Still nothing from the SDS011, but I'm wondering if that's a dodgy connection - I'm going to try some new wires in a bit

image

Please carefully check your wirings and correct settings of you sensors, before opening issues here. Thank you.

OK, I'll close this for now. The SDS011 still isn't working as expected (The fan starts/stops, but no readings are sent), and when I reboot the TTGO v2.1 with the BME680 ground pin connected then it sometimes fails to read the values, but I'll get it moved over onto a PCB that I'm designing specifically for this and see if that makes a difference.

Thanks again for your patience and help.

For anyone else hitting similar issues, check the output voltage pins and GND pins on your board with a multimeter.

I found that on the board I ordered, the 5VDC pin was non-functional, and the GND closest to the 3.3v pin was also non-functional.

Once I'd moved the power supplies for the BME680 and SDS011 off the board and direct to the source, with the battery connector providing the power/GND for both, then everything sprang into life and started working.

Where did you purchase that board, from original LilyGo Shop, or elsewhere? Can you post a high resolution picture of that board here?

Sure, https://www.aliexpress.com/item/32915894264.html is the item I purchased, looks like it's from the official LilyGo store.

I've just zoomed right in and I can see that not all of the pad has solder on it where I was trying to avoid burning the OLED cable whilst attaching the pins, so it could well be that causing the issue here rather than a manufacturing fault - if anyone has advice on how to solder underneath that ribbon without damaging it I'd love to hear it! :)

2024-03-11 20 56 55
2024-03-11 20 57 47

This is the "original", and problems with non functional GND / 5V pins were - yet - never reported here, so a good point to check your soldering.