First day with the Esrpuino Wifi. I'm not sure what to expect, and I realize that it's an embedded platform. I have a lot of experience with Arduinos, the Esquilo, etc.
The following code will load and run if I comment out either the "startServer" or the "startLogging" functions. But if I try to run the whole program it fails with the following:
> 1v95 Copyright 2017 G.Williams
> >
> =undefined Erasing Flash... Writing....................... Compressed 114368 bytes to 21007 Checking... Done! Running onInit()...
> >ERROR: Prompt not detected - upload failed. Trying to recover... ERROR: Error processing Serial data handler - removing it. Execution
> Interrupted during event processing. New interpreter error: CALLBACK
> New interpreter error: BUFFER_FULL
> >echo(1)
> =undefined
var WIFI_NAME = "oddballpeak";
var WIFI_OPTIONS = { password : "mule$bacon44" };
var wifi;
var now = null;
var sample_array = [];
var arr_ptr = 0;
var tempF = 32;
var sampleCnt = 0;
var date = new Date();
var maxSamples = 672;
var ow = new OneWire(B0);
var sampleSec = 900;
var http = require("http");
function onInit() {
wifi = require("EspruinoWiFi");
wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
if (err) {
console.log("Connection error: "+err);
return;
}
console.log("Connected!");
initProcess();
});
}
function initProcess() {
http.get("http://www.pur3.co.uk/hello.txt", function(res) {
now = res.headers.Date;
epoch = Date.parse(now);
setTime(epoch/1000);
console.log("Now: ", date.toString());
setTimeout(startLogging, 3000);
setTimeout(startServer, 5000);
});
}
function startServer() {
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
page = "<h3>Logging</h3><br>";
for (var i in sample_array) {
page += sample_array[i].ts;
page += "\t";
page += sample_array[i].degF;
}
res.write(page);
}).listen(80);
}
function startLogging() {
var sensor = require("DS18B20").connect(ow);
setInterval(function() {
sensor.getTemp(function (temp) {
now = Date.now() / 1000;
floor = parseInt(now);
mod = floor % sampleSec;
if (!mod) {
tempF = ((temp * 9) / 5) + 32;
sample_array[sampleCnt] = { "ts" : floor, "degF" : tempF };
if (++sampleCnt == maxSamples) {
sampleCnt = 0;
}
}
});
}, 1000);
}
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.
First day with the Esrpuino Wifi. I'm not sure what to expect, and I realize that it's an embedded platform. I have a lot of experience with Arduinos, the Esquilo, etc.
The following code will load and run if I comment out either the "startServer" or the "startLogging" functions. But if I try to run the whole program it fails with the following: