Hi, forgive me for my bad english. I'm using a sonoff module that have a relay and a led. I have falsh firmware with espruino v1.87 and I have wrote a code to control the relay and the led from a we page.
If I use the board connected on USB, it works well. But when I add the save() function, I can't control anymore the relay and the led. If I plugg off the usb and connect the board to 220V (france), the board is not responding on wifi. So I think that the board doesn't store my code:
var relay = D12;
var led = D13;
function toggleDevice(toggle){
digitalWrite(relay, toggle);
digitalWrite(led, toggle);
}
function startServer() {
var http = require('http');
var httpServer = http.createServer(function(req, res) {
var params = url.parse(req.url, true);
if (params.query !== null && params.query.device !== "") {
var status = params.query.device;
toggleDevice(status);
}
res.end("<h1>Hello world</h1>");
});
httpServer.listen(80);
print('HTTP server is running');
}
function onInit() {
var wifiSSID = "xxxxxx";
var wifiPass = "xxxxxxxx";
var wifi = require('Wifi');
wifi.connect(wifiSSID, {password:wifiPass}, function(err, data){
if (err) {
print('Error while connecting to access point' + wifiSSID);
return;
}
print("connected? err=", err, "info=", wifi.getIP());
startServer();
});
wifi.stopAP();
wifi.save();
}
E.on('init', onInit());
//save();
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, forgive me for my bad english. I'm using a sonoff module that have a relay and a led. I have falsh firmware with espruino v1.87 and I have wrote a code to control the relay and the led from a we page.
If I use the board connected on USB, it works well. But when I add the save() function, I can't control anymore the relay and the led. If I plugg off the usb and connect the board to 220V (france), the board is not responding on wifi. So I think that the board doesn't store my code:
Any idea please ?