For use with the ESP8266 can anyone convert either the LUA code that retrieves the Google HEAD data which includes the current time...
https://geonomad.wordpress.com/2015/01/ ... n-esp8266/
or this NTP.c code which gets network time?
https://github.com/shantanugoel/esp8266 ... user/ntp.c
Network time
Re: Network time
In the Examples-ESP8266 subdirectory of the ZBasic installation directory you'll find a project named ClientTCP which could easily be modified to make a request for the Google page. Then, when the response is received it is a fairly simple matter to extract the time from the text.dlh wrote:For use with the ESP8266 can anyone convert either the LUA code that retrieves the Google HEAD data which includes the current time...
Change lines 36 and 37 to
Code: Select all
Const domain as String = "google.com"
Const request as String = "GET / HTTP/1.1" & CRLF
In the same examples directory, the ClientUDP project queries an NTP server and displays the returned time.dlh wrote:or this NTP.c code which gets network time?
- Don Kinzer
re: Network time
I have an application where I want to use an ESP8266 to act as a serial connection via WiFi and also get NTP time periodically, updating the RTC as needed. I plan to use a TPS2110 MUX to automatically switch the ESP8266 to 3V battery power when the main power is lost, record the time and date to RTC flash (RTC.MemWrite), and go into DeepSleep. When main power is restored the ESP8266 will wake, get NTP time, update the RTC and report the length of the outage.
How do I signal the ESP8266 to wake up?
How do I signal the ESP8266 to wake up?
Re: re: Network time
As indicated in the description for DeepSleep, GPIO16 will go low when the deep sleep period expires. Connect GPIO16 to reset (using a diode, cathode to GPIO16), et voila!dlh wrote:How do I signal the ESP8266 to wake up?
- Don Kinzer
Re: Network time
I need external control. Ideally, I'd like to use a single pin to signal the ESP8266 when the switch to battery has occurred and when the main power has been restored (which may not occur until long after the battery is exhausted).dkinzer wrote:As indicated in the description for DeepSleep, GPIO16 will go low when the deep sleep period expires. Connect GPIO16 to reset (using a diode, cathode to GPIO16), et voila!
I'm trying to duplicate the functionality of the M41T81 RTC IC which senses when it switches to battery power and writes the time/date to a register which can be read once the main power is restored.
I do have a 328P (not battery backed) in the mix so it can reset the ESP8266 at power-up, if needed.
Re: Network time
I'm not sure what the power consumption of the ESP8266 will be when it comes out of Deep Sleep with GPIO16 not connected to reset. If it just sits there at a low power level, perhaps you could just reset it from an external source when power is restored. I suspect that you'll want to use Persistent Memory rather than the RTC memory because when the battery is exhausted the RTC contents disappears.dlh wrote:I'd like to use a single pin to signal the ESP8266 when the switch to battery has occurred and when the main power has been restored (which may not occur until long after the battery is exhausted).
So, when the "on battery" signal occurs, write the current time to Persistent Memory and go into Deep Sleep. Later, when the "not on battery" signal is present when the device is reset and there is a valid time stored in Persistent Memory, reset the RTC using that data.
- Don Kinzer
Network time
After gnawing it over I've come to the confusion that sticking with the M41T81S for an RTC is the simplest way to go. It can keep time for 10+ years powered by a coin cell battery. And, there's no significant difference in cost or board space.