-->
Page 1 of 1

HELP: ESP and Alarms

PostPosted: Thu Mar 31, 2016 8:39 am
by Ribeiro Santos
Hi,

I want to use ESP (and a relay) to control my curtains: open at 7:30 and close at 20:00. Like arduino, without a RTC, after some days I will have the curtains opened at 7:32 (example), next 7:34... at 8:01 ... and some day will be late at work (9:41 or even more)

What accuracy have the ESP timers or what should I use, without any RTC or Internet connection, to have the curtains opening allways at the same time.

Thanks a lot,
Ribeiro

Re: HELP: ESP and Alarms

PostPosted: Thu Mar 31, 2016 12:30 pm
by onehorse
You'll probably need a more accurate RTC added to your project like a DS1307 or maybe something like this:

https://www.tindie.com/products/onehors ... teensy-3x/

Re: HELP: ESP and Alarms

PostPosted: Thu Mar 31, 2016 5:53 pm
by PostmanPrat
I found this code from a quick google on the subject and it explains how to send a query to google to get the time - you could use this if your ESP has an internet connection

-- retrieve the current time from Google
-- tested on NodeMCU 0.9.5 build 20150108

conn=net.createConnection(net.TCP, 0)

conn:on("connection",function(conn, payload)
conn:send("HEAD / HTTP/1.1\r\n"..
"Host: google.com\r\n"..
"Accept: */*\r\n"..
"User-Agent: Mozilla/4.0 (compatible; esp8266 Lua;)"..
"\r\n\r\n")
end)

conn:on("receive", function(conn, payload)
print('\nRetrieved in '..((tmr.now()-t)/1000)..' milliseconds.')
print('Google says it is '..string.sub(payload,string.find(payload,"Date: ")
+6,string.find(payload,"Date: ")+35))
conn:close()
end)
t = tmr.now()
conn:connect(80,'google.com')


code courtesy of http://benlo.com/esp8266/esp8266Project ... googleTime

Re: HELP: ESP and Alarms

PostPosted: Thu Mar 31, 2016 8:45 pm
by martinayotte
Of course, there is several ways to sync up with real time !
You can also sync up with an NTP server once every hour ...