cyberman54 / ESP32-Paxcounter

Wifi & BLE driven passenger flow metering with cheap ESP32 boards
https://cyberman54.github.io/ESP32-Paxcounter/
Other
1.73k stars 405 forks source link

When GPZDA time-of-day is considered valid by TinyGps lib, the date is also valid, though not indicated by return value of isValid() #708

Closed HouzuoGuo closed 3 years ago

HouzuoGuo commented 3 years ago

This is a rather strange issue from TinyGps library, though I am unsure if this issue is isolated to using TinyGps with TTGO T-Beam v0.7 board. I have previously observed the same issue in a hobby project:

https://github.com/HouzuoGuo/esp32-wifi-gps-tracker/blob/master/gps.cpp#L46

Picture proof, with this patch applied: IMG_1330

Ignore the unusually high reading of number of GPS satellites which resulted from another wip experiment of mine.

HouzuoGuo commented 3 years ago

With the patch applied, here's the serial output indicating successful time sync from GPS:

20:35:45.691 > ets Jun  8 2016 00:22:57
20:35:45.691 >
20:35:45.691 > rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
20:35:45.691 > configsip: 0, SPIWP:0xee
20:35:45.691 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:35:45.691 > mode:DIO, clock div:2
20:35:45.691 > load:0x3fff0018,len:4
20:35:45.691 > load:0x3fff001c,len:1044
20:35:45.691 > load:0x40078000,len:8896
20:35:45.691 > load:0x40080400,len:5828
20:35:45.691 > entry 0x400806ac
20:35:45.691 > [D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled
20:35:45.691 > [I][reset.cpp:81] do_after_reset(): Starting Software v2.1.1, runmode powercycle
20:35:45.691 > [I][main.cpp:159] setup(): This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external Flash
20:35:45.691 > [I][main.cpp:161] setup(): Internal Total heap 239192, internal Free Heap 213160
20:35:45.691 > [I][main.cpp:164] setup(): SPIRam Total heap 4194252, SPIRam Free Heap 4194252
20:35:45.691 > [I][main.cpp:167] setup(): ChipRevision 1, Cpu Freq 240, SDK Version v3.2.3-14-gd3e562907
20:35:45.691 > [I][main.cpp:169] setup(): Flash Size 4194304, Flash Speed 40000000
20:35:45.691 > [I][main.cpp:171] setup(): Wifi/BT software coexist version 1.1.7
20:35:45.691 > [I][main.cpp:175] setup(): IBM LMIC version 1.6.1468577746
20:35:45.691 > [I][main.cpp:180] setup(): Arduino LMIC version 3.3.0.0
20:35:45.691 > [I][macsniff.cpp:37] printKey(): DevEUI: 800E2BE63F4037DC
20:35:45.691 > [I][macsniff.cpp:37] printKey(): AppEUI: 800E2BE63F4037DC
20:35:45.691 > [I][macsniff.cpp:37] printKey(): AppKey: DC37403FE62B0E80E9040220E0F3FC3F
20:35:45.691 > [I][main.cpp:185] setup(): TinyGPS+ version 1.0.2
20:35:45.691 > [I][configmanager.cpp:101] loadConfig(): Loading device configuration from NVRAM...
20:35:45.691 > [I][configmanager.cpp:126] loadConfig(): Runtime configuration v2.1.1 loaded
20:35:45.691 > [I][i2c.cpp:44] i2c_scan(): Starting I2C bus scan...
20:35:45.691 > [I][i2c.cpp:75] i2c_scan(): Device found at 0x3C, type = SSD1306
20:35:45.691 > [I][i2c.cpp:78] i2c_scan(): 1 I2C device(s) found
20:35:53.890 > [I][main.cpp:226] setup(): PSRAM found and initialized
20:35:53.890 > [I][main.cpp:259] setup(): Starting LED Controller...
20:35:53.890 > [I][power.cpp:195] calibrate_voltage(): ADC characterization based on reference voltage stored in eFuse
20:35:53.890 > [I][main.cpp:294] setup(): Starting MAC processor...
20:35:53.890 > [I][macsniff.cpp:54] macQueueInit(): MAC processing queue created, size 3600 Bytes
20:35:53.890 > [I][main.cpp:298] setup(): Starting rcommand interpreter...
20:35:53.890 > [I][rcommand.cpp:488] rcmd_init(): Rcommand send queue created, size 55 Bytes
20:35:53.890 > [I][main.cpp:306] setup(): Starting Bluetooth...
20:35:53.914 > [I][blecsan.cpp:271] start_BLEscan(): Initializing bluetooth scanner ...
20:35:54.437 > [I][blecsan.cpp:229] register_ble_callback(): Register GAP callback...
20:35:54.438 > [I][blecsan.cpp:259] register_ble_callback(): Set GAP scan parameters
20:35:54.438 > [I][blecsan.cpp:279] start_BLEscan(): Bluetooth scanner started
20:35:54.438 > [I][gpsread.cpp:42] gps_init(): Using serial GPS
20:35:54.438 > [I][main.cpp:322] setup(): Starting GPS Feed...
20:35:54.438 > [I][lorawan.cpp:244] lmic_init(): LORA send queue created, size 530 Bytes
20:35:54.485 > [I][lorawan.cpp:294] lmic_init(): Starting LMIC...
20:35:54.485 > I (12431) wifi: wifi driver task: 3ffdfb78, prio:23, stack:3584, core=0
20:35:54.485 > I (25014) wifi: wifi firmware version: 7997e4b
20:35:54.485 > I (25015) wifi: config NVS flash: disabled
20:35:54.485 > I (25017) wifi: config nano formating: disabled
20:35:54.485 > I (25021) wifi: Init dynamic tx buffer num: 32
20:35:54.485 > I (25025) wifi: Init data frame dynamic rx buffer num: 32
20:35:54.485 > I (25030) wifi: Init management frame dynamic rx buffer num: 32
20:35:54.485 > I (25036) wifi: Init management short buffer num: 32
20:35:54.485 > I (25041) wifi: Init static rx buffer size: 1600
20:35:54.529 > I (25045) wifi: Init static rx buffer num: 16
20:35:54.529 > I (25049) wifi: Init dynamic rx buffer num: 32
20:35:54.529 > I (25054) wifi: set country: cc=EU␀ schan=1 nchan=14 policy=1
20:35:54.529 >
20:35:54.529 > W (25059) wifi: ap start fail
20:35:54.529 >
20:35:54.529 > I (25062) wifi: Set ps type: 0
20:35:54.529 >
20:35:54.529 > [I][main.cpp:426] setup(): Starting Wifi...
20:35:54.529 > I (25079) wifi: mode : null
20:35:54.529 > I (25079) wifi: ic_enable_sniffer
20:35:54.529 > [I][cyclic.cpp:141] reset_counters(): clearing 2 memorised items
20:35:54.529 > [I][main.cpp:441] setup(): Starting Interrupt Handler...
20:35:54.529 > [I][main.cpp:469] setup(): Starting Timers...
20:35:54.583 > [I][main.cpp:519] setup(): Starting Timekeeper...
20:35:54.583 > [I][timekeeper.cpp:152] timepulse_init(): Timepulse: internal (ESP32 hardware timer)
20:35:54.583 > [D][timekeeper.cpp:30] calibrateTime(): [12.524] calibrateTime, timeSource == 3
20:35:54.583 > [D][gpsread.cpp:139] get_gpstime(): no valid GPS time
20:35:54.583 > [D][timekeeper.cpp:113] setMyTime(): [12.536] Timesync failed, invalid time fetched | source: G
20:35:54.583 > [I][main.cpp:527] setup(): Features: OLED PSRAM LED BATT BLE GPS LORA PACKED WIFI BTN_PD TIME
20:35:55.248 > [D][timekeeper.cpp:30] calibrateTime(): [13.233] calibrateTime, timeSource == 3
20:35:55.692 > [I][timekeeper.cpp:89] setMyTime(): [13.669] UTC time: 1609698958.565 sec
20:35:55.692 > [D][timekeeper.cpp:109] setMyTime(): [13.669] Timesync finished, time was set | source: G
20:36:24.597 > [D][cyclic.cpp:30] doHousekeeping(): Heap: Free:107752, Min:99288, Size:236372, Alloc:87416, StackHWM:2180
20:36:24.598 > [D][cyclic.cpp:33] doHousekeeping(): IRQhandler 2180 bytes left | Taskstate = 0
20:36:24.598 > [D][cyclic.cpp:36] doHousekeeping(): MACprocessor 2440 bytes left | Taskstate = 2
20:36:24.598 > [D][cyclic.cpp:38] doHousekeeping(): Rcommand interpreter 2636 bytes left | Taskstate = 2
20:36:24.598 > [D][cyclic.cpp:41] doHousekeeping(): LMiCtask 3564 bytes left | Taskstate = 1
20:36:24.598 > [D][cyclic.cpp:44] doHousekeeping(): Lorasendtask 2584 bytes left | Taskstate = 2
20:36:24.617 > [D][cyclic.cpp:48] doHousekeeping(): Gpsloop 2316 bytes left | Taskstate = 1
20:36:24.617 > [D][cyclic.cpp:67] doHousekeeping(): LEDloop 492 bytes left | Taskstate = 2
cyberman54 commented 3 years ago

Thanks for your investigations and reports. I think we have to analyze this part of code of TinyGps++, regarding that paxcounter is using TinyGPSCustom NMEA sentence "GPZDA":

https://github.com/mikalhart/TinyGPSPlus/blob/master/src/TinyGPS%2B%2B.cpp#171

cyberman54 commented 3 years ago

Agreed. Since gpstime() and gpsday() both are based on same TinyGPS++ custom sentence term "GPZDA" the first commit of this sentence term is significant for all other informations (date etc.) conveyed by this term. Thus, we use gpstime() only.

cyberman54 commented 3 years ago

By the way: Your picture shows that you modified the display layout. Maybe anything worth to PR here, too?