Hi, I am using the Time Library in my IoT Nodes to set two alarms and all works on the Base Node which has an RTC.
All Nodes are connected to the Base by an RF24Network. When a Node calls home (Base) the Base handles whatever the call wanted and returns the Seconds-Since-Midnight (SSM) to that Node.
The Nodes have a rudimentary millis() ticker that updates it's internal fake-SSM to give a pretty close approximation of the real Base-time in SSM. All good as they hear from the Base roughly every 60-Seconds.
The Alarms code is working so well in the Base, I want to add some to a few of the Nodes but they do not have the valid time, only the SSM.
How do I set the Time-Library "Time" using those SSM to fake it for the Nodes without the RTC?
Thanks
p.s. So far, the faked SSM on the Nodes have never been out of line with the Base's RTC time as all transmissions back to the Base include their faked-SSM so I can check for discrepancies.
How do I set the Time-Library "Time" using those SSM to fake it for the Nodes without the RTC?
You don't, since seconds from midnight is not a date/time. You can make a time from seconds since midnight, but you have no idea which midnight, so you can't create a date, so you don't have all the information needed.
To synchronize nodes, you need to have time messages propagated around the network. The method described in this project works pretty well: http://www.instructables.com/id/Simple-Arduino-Wireless-Mesh/.
However, that example makes extensive use of Strings. Since it is hard to imagine how that could have worked for any length of time, I went through and removed them. If interested, I will post the cleaned up version.
PaulS:
You don't, since seconds from midnight is not a date/time.
know that and that's why I am posting here.
BUT when trying to set the Node Time I could fake the Date as in the following for 30-seconds past midnight.
(SSM, Year, Month, Day)
(30,2010,10,10)
The Nodes do not care what day it is. I am not an idiot Paul, I could just have easily been sending the actual seconds sine 1970 instead of the SSM but it is just easier to handle the code for SSM in the Nodes.
jremington:
I went through and removed them. If interested, I will post the cleaned up version.
Thanks JR, that Mesh is an interesting approach, but just using the SSM that I am already transmitting to all Nodes would be a lot easier if it is possible to fool the Node's Time Library into setting the time with the SSM and a fake Date.
The RF24 Network already handles a lot of what that Mesh code does. No need for time slots etc. I am pretty impressed with the two guys who developed the RF24 Library set. Although, I hate working with the Octal Node IDs, but I understand why it must be used.