-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added time() and sleep() functions #28
Added time() and sleep() functions #28
Conversation
From the documentation: "This command sets the real-time clock by synchronizing with the time server specified with the time server (set time) parameters. This command sends a UDP time server request packet."
Added the sleep() command. Calling it with (seconds) will set the system wake timer before putting the module to sleep.
Added time() and sleep() functions
Hi guys! Just wanted to clear something up. Does the wifi module/shield have an rtc? But it is not battery powered like a DS1307 or DS3231? So it only keeps time while the unit has power, correct? I have a project that uses an external ds1307 breakout to keep time and together with timealarms library, I call measurements every 30 minutes. I wanted to eliminate the external ds1307 breakout and see if I could keep the alarm-measurement functionality using the wifi module's rtc. But I guess that if the wifi module reboots, which it sometimes does, it would loose its time? But it would sync again on setup, right? |
If my memory serves me correct, the module does not have a battery backup, so the time would be lost if power is lost (until a time resync is performed). I'm honestly not sure what the status of the WiFly's RTC would be after a soft reboot. |
Oh ok but it does have a clock? And on reboot I could probably call a function to sync the clock again. Who knows. Do you know of any examples using the rtc functions? MV
|
Yes, it does have an RTC (see section 3.11 in the command reference). And yes, you can call the time() function that was added in this to commit to re-sync. Here's some old code that (I believe) should work:
|
Thanks. I was trying a slightly different code and it didnt work. The 2 main differences are the setTimeEnable which I had at 1 and you have at 5, and the ntp which I had at ...28 and you have at ...30. Im guessing it might have had to do with the setEnableTime? What does 5 do vs 1? Here is my code: char dataBufferToReceive[bufferSize]; //for the time Serial.print("uptime: "); //Get time from wifi module |
In the section (3.11) of the datasheet I mentioned above, they explain the value for set time enable:
So, |
Yeah I read that section. So that wouldn't have been the issue. Anyway, thanks because with your code it worked. MV
|
From the documentation: "This command sets the real-time clock by
synchronizing with the time server specified with the time server (set
time) parameters. This command sends a UDP time server request packet."
Also added sleep() function per mgrey's recommendations: #9