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");
});
});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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: