AlexPuts / stm32dntp

Ntp time server based on stm32duino
https://alexputz.github.io/projects/en/stm32duino-ntp-server/
7 stars 3 forks source link

Check if GPS Time is usefull #3

Closed bobybobybob closed 6 years ago

bobybobybob commented 6 years ago

Hello,

after sync with the stm32dntp it say that today is 28.03.1930 16:34 o clock lol

Poweroff and Poweron it is 19.1.2017 14:50 o clock then GPS set it back to 1930

Maybe the code should add that no time is OK if time is lower then compiletime

What GPS Receiver do you recommend? Current i use a ublox Neo6m

Here a sample output from GPS

$GPZDA,222156.000,03,05,2018,00,005B $GPGGA,222156.000,6273.8505,N,00971.2110,E,1,05,2.5,813.9,M,0.0,M,,6D $GPRMC,222849.000,A,6273.8565,N,00971.2073,E,0.63,96.53,030518,,,A*58

AlexPuts commented 6 years ago

Hi, I use NEO M8N M8 MINI GPS Module. (this module additionaly supports GLONASS, BAIDU etc.) There is a handler function ntp_recv_and_respond() which handles these packets, you can modify it if you like ( e.g. check if time is not valid and dont respond on a ntp packet). I did ignored this issue back then because I use linux and linux have checks inside time daemon (uses NTP instead of SNTP (without checks) for windows.

It seems that GNRMC of my GPS fits my code, probably you have to do few modifications for it to work.

STM32 have RTC (real time clock) function inside of chip (3VB pin). It was intended to use 18650 battery to power up RTC circuit, so even while offline clock will still tick.

In my statements (GNRMC) there is no value in place like 96.53 in your statement. I think you can modify in function processGNRMC in file sntp_utils.cpp, like in line 141 add skips for non used values, or remove skips.

Look closer at the 96.53 region in stetement, after it comes 030, thats where you supposedly got a 1930. I think you have to add a skip or two before reading date, 141 line.

When I developed it I just used functions to output date in serial, so I send GNRMC via serial and it responds via serial with date, so I was able to quickly adjust it in proper position.

bobybobybob commented 6 years ago

Thank you for Information. I will try my best otherwise i need to buy a Neo M8N :-)

AlexPuts commented 6 years ago

You really don't need to. What I did back then :

  1. Make a dump of statements that GPS sends in normal state.
  2. Disconnect GPS, connect usb to serial at gps pins.
  3. Insert a bunch of prints like the one in 143 line in sntp_utils.cpp
  4. Imitate gps behaviour, e.g. send GPRMC messages, and see what is printed out, what is on the clock, e.t.c
  5. Adjust code.

Have fun.

AlexPuts commented 6 years ago

OFFTOPIC(stability): I did this project for the arduino nano in the first place, but then when arduino nano ran out of memory, I've moved to the STM32. The interesting thing is that arduino was super stable(ran 2 month in a row before I switched it off) (perhaps because i bought high grade hardware and ran nearly the same code, with same gps, but on STM 32 I had issues with eventual freezing, ethernet adapter freezes sometimes ( a wide known issue ) . There is solution for that like using watchdog, writing additional functions to check ethernet status, etc.