I’d like to add a 12002 real time clock (RTC) module to my RAK Meshtastic node.
All I’ve seen for docs are Arduino programs to set and read out the time.
I’m looking for how to make Meshtastic use the RTC for a time reference similar to a GPS module.
It’s an I2C module, so will require some modifications to src/detect/ScanI2CTwoWire.cpp for it to be detected. There are some other RTC chips in there you may be able to copy.
Feel free to jump on meshtastic discourse if you’d like help editing the code
Actually, looks like it boils down to a “RV3028_RTC”, which is already supported.
Try connecting it to I2C and see how you go!
Thanks for the reply!
I’m expecting delivery of a RAK meshtastic 4361 and RAK 19007 base shortly and I have the RTC module, I should be able to test your theory.
I’ll be back with the results.
I received the RAK hardware today and put everything together including the RTC in slot “A”.
Powered up on the USB and connected the Bluetooth to my tablet running Meshtastic.
Everything seems to be normal - how would I tell if the system is using the RTC?
I assume the node gets the time from my tablet when I connect?
Glad it seems normal
There should be a line in the debug logs* starting with “RV3028_RTC setTime”. If you see that, it’s detected fine and working.
*if you’re unfamiliar with these, just go to flasher.meshtastic.org and click “Open Serial Monitor”
It appears to recognize the RTC.
Here’s a grab of the serial monitor output.
//\ E S H T /\ S T / C
DEBUG | ??:??:?? 3 Filesystem files:
DEBUG | ??:??:?? 3 MODE (1 Bytes)
DEBUG | ??:??:?? 3 RAK (108 Bytes)
DEBUG | ??:??:?? 3 channels.proto (57 Bytes)
DEBUG | ??:??:?? 3 module.proto (112 Bytes)
DEBUG | ??:??:?? 3 config.proto (91 Bytes)
DEBUG | ??:??:?? 3 db.proto (320 Bytes)
DEBUG | ??:??:?? 3 Using analog input 5 for battery level
INFO | ??:??:?? 3 Scanning for i2c devices…
DEBUG | ??:??:?? 3 Scanning for i2c devices on port 1
DEBUG | ??:??:?? 3 I2C device found at address 0x52
INFO | ??:??:?? 3 RV3028 RTC found
INFO | ??:??:?? 3 1 I2C devices found
DEBUG | ??:??:?? 3 acc_info = 0
INFO | ??:??:?? 3 Meshtastic hwvendor=9, swver=2.2.24.e6a2c06
DEBUG | ??:??:?? 3 Reset reason: 0x0
DEBUG | ??:??:?? 3 Setting random seed 1726960842
INFO | ??:??:?? 3 Initializing NodeDB
INFO | ??:??:?? 3 Loading /prefs/db.proto
INFO | ??:??:?? 3 Loaded saved devicestate version 22
INFO | ??:??:?? 3 Loading /prefs/config.proto
INFO | ??:??:?? 3 Loaded saved config version 22
INFO | ??:??:?? 3 Loading /prefs/module.proto
INFO | ??:??:?? 3 Loaded saved moduleConfig version 22
INFO | ??:??:?? 3 Loading /prefs/channels.proto
INFO | ??:??:?? 3 Loaded saved channelFile version 22
INFO | ??:??:?? 3 No /oem/oem.proto preferences found
DEBUG | ??:??:?? 3 cleanupMeshDB purged 1 entries
WARN | ??:??:?? 3 Using nodenum 0x605ec93f
DEBUG | ??:??:?? 3 Expanding short PSK #1
INFO | ??:??:?? 3 Wanted region 1, using US
DEBUG | ??:??:?? 3 region=1, NODENUM=0x605ec93f, dbsize=2
DEBUG | ??:??:?? 3 Using GPIO09 for button
DEBUG | ??:??:?? 3 Read RTC time from RV3028 as 536902332
What do you think?
That looks good to me.
Based on the lack of time in the log, I expect it will need to first get the time from elsewhere but should keep it after that
After a few minutes with a GPS on a nearby node.
DEBUG | ??:??:?? 5 Read RTC time from RV3028 as 536902332
INFO | 13:56:17 5 Setting GPS power=1
Thanks for the help Sir!
To summarize, a RAK 4361 module running Meshtastic will recognize the installed RAK 12002 real time clock module.
It will use it as soon as it sees GPS time on the network and sets the time.
Ffield describes how to check further back in this thread.
Will this give the time to other nodes in the network as well?
I have a couple rak rtc’s on the way for my solar repeater nodes. But if I can get away with installing it in only one repeater that would be great.
I’m inclined to tell you yes with what I’ve seen, however I’d like to hear from Tom Fifield on the matter.
I missed the chance to test whether the Rak mesh nodes would share RTC today while turning up my operating RAK 4631 with new firmware and a RTC module in slot A.
Sorry.
However, I did capture the serial output of when the node sees GPS time from another and applies it.
Mesh Node Ringo with it’s new RTC. Serial output when T-Echo broadcasts it’s GPS position.
INFO | 00:23:45 172 [Router] Received position from=0xa289781, id=0xeb6c20e6, portnum=3, payloadlen=27
DEBUG | 00:23:45 172 [Router] POSITION node=0a289781 l=27 lat=452302586 lon=-950219536 msl=366 hae=0 geo=0 pdop=408 hdop=0 vdop=0 siv=7 fxq=0 fxt=0 pts=0 time=1724777569
DEBUG | 00:23:45 172 [Router] Upgrading time to quality Net
DEBUG | 16:52:49 172 [Router] RV3028_RTC setTime 2024-08-27 16:52:49 0
DEBUG | 16:52:49 172 [Router] Read RTC time from RV3028 as 536904948
Upon closer inspection and more testing later I’ve discovered the RTC isn’t storing the time correctly.
I suspect the RTC isn’t in the 24 hr mode, but I don’t know enough to be dangerous around the Meshtastic code.
I’m hoping someone who knows way more than I will chime in with who we need to ask about getting it fixed.
I just put in a RTC in my new Router node as well. Still looking into if this helps to keep time in my network. Now that the Android app can show metrics this has become a lot easier to keep track of.
Unfortunately, there was no action taken that I am aware of on the RTC 12002 issue.
I assume they had bigger fish to fry. I have removed the modules from my RAK 4361 nodes until they get them working.