-
• #2
Hi! Do you disconnect the Espruino WiFi from power between connecting to your laptop and being disconnected?
While the Espruino WiFi does have an RTC (real time clock) there is no battery backup, so if you remove power then the date will get lost. It is possible to add a battery backup if needed (3v battery then diode to the 3.3v line) but since you're connected to the internet it should be pretty easy for you to grab up to date time at boot.
I've found it's pretty easy to just request a webpage from a webserver and then grab the date from the
Date
header:require("http").get("http://www.espruino.com", function(res) { console.log("HTTP Response: ",res); if ("Date" in res.headers) { console.log("Got Date ",res.headers.Date); var date = new Date(res.headers.Date); var d = date.getTime(); if (d>0) { setTime(d/1000); lastSuccess = getTime(); } else console.log("Unable to parse date!"); } res.on('data', function(d) { }); // chuck data res.on('close', function(d) { console.log("HTTP Closed"); }); });
Hi there,
Please excuse me if I'm missing something obvious since I'm a bit of a novice, but it looks like my espurino wifi does not retain the current Date when it boots up not connected to my laptop....
Here's the output for Date.now() when connected to my laptop vs not (as logged through sending a get request to a remote server)
Is this expected behavior? Thanks!
1 Attachment