General > General Technical Chat
Cheapest way to get date/time from GPS
peter-h:
AFAIK the RMC packet is very standard - it is the most basic bit of NMEA.
What I do (above code) is check for the year being 2021 or higher. Well, I should now change that to 2024 :)
I am using the NEO-M9N which should be very similar to your M8.
dietert1:
Yesterday i happened to connect a MnO2/Li cell to the VBAT pin of a Nucleo64-L476 evaluation board - after removing jumper SB45. When implementing the basic realtime clock functionality i found that the MCU includes a charger. After activation it slowly raised cell voltage from 2.80 to 3.18 V. The MCU also has an ADC circuit to measure cell voltage. Also the realtime clock includes a 128 byte memory ("backup memory"). So it's pretty easy to find out whether the time is reliable or the clock needs to be set. Accuracy appears to be about or better than 10 ppm out of the box without additional tuning. The STM32 RTC logic supports continuous digital tuning. It has some reference clock input, so tuning may be automatic, but i didn't try that yet.
A nice result and i think i will add those MnO2 cells to some other projects, too.
If USB (as a replacement of ethernet) had the actual time in its protocols, that could be a convenient way to set the realtime clock automatically.
Regards, Dieter
peter-h:
Yes this seems to be a feature of a lot of STM 32F4 chips.
There is actually no way to be sure the RTC time was not corrupted by a power failure. The method I use is to store a 32 bit "magic number" in that memory area and if corrupted then the RTC is re-initialised. Same if the date/time is obviously silly. This method works for my common scenario of selling a product with a supercap which lasts only a few days, so every unit the customer gets will get re-initialised.
The RTC draws of the order of 1uA which is too much for a lithium battery like a 2032, however.
You can charge a battery or a supercap with a resistor
dietert1:
The MnO2/Li cells i found in our junk collection or the Vanadium-Lithium cells offered nowadays have a capacity of about 20 to 100 mAh. Those batteries also appear at ebay (DIY repair of car remotes).
The RTC circuit of the L476 i mentioned takes about 400 nA, so a 50 mAh cell will last about 125000 hours or 14 years. Optimistic due to self discharge, yet this demonstrates the correct solution. As the battery is rechargable it should last "forever". For many consumers it's acceptable to replace the complete device after 5 or 10 years (except a car).
At 10 ppm accuracy the clock deviation after 5 years would be 26 minutes, so a method to readjust the time is still required.
Regards, Dieter
tooki:
--- Quote from: alex_ on February 27, 2024, 10:39:54 pm ---
--- Quote from: peter-h on February 27, 2024, 11:46:52 am ---To get date/time.
Or to periodically sync a standard 32768Hz xtal RTC.
--- End quote ---
What about a wifi module (ESP32 or other)? Get the header of a webpage to get a UTC time and date.
That's how I resync daily my scheduling devices. Not ns accurate of course, but cheap and 0 power between polls.
--- End quote ---
Why do this when you can use NTP (or SNTP) instead? NTP on ESP32 takes just a few lines of code.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version