var data = [];
function storeData() {
var newData = E.getTemperature(); // for instance...
data.push(newData);
}
setInterval(storeData, 10*60*1000); // call every 10 minutes
If you upload that, after 10 minutes you'll have your first data element (the temperature), then another 10 minutes later, the next, etc.
You can read the data just by typing data and enter on the left-hand side of the IDE. However once you've got quite a bit of data, it'll be too much to fit on a line.
If you type data.forEach(a=>print(a)) then it'll print all the data items, one per line - which you could copy & paste into a spreadsheet. You could also turn that into a function that you can call:
function getData() {
data.forEach(a=>print(a));
}
To clear out all the old data you can also just write data=[].
This way's simple but isn't very efficient with memory so you'll only be able to store around 1000 data items (still, that's 150 hours recording every 10 minutes).
So... to get that on your mobile, you can run the same code on https://www.espruino.com/ide/ on an Android phone (or an iPhone with the WebBLE app).
Or... you could write your own Web Bluetooth webpage. This one will grab the data and just print it to the page:
But once you have it loaded onto the page you could (for instance) display it in some fancier way, allow it to be downloaded, or maybe publish the data to Google Sheets.
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! Yes, no problem at all.
For something really simple, you can do:
If you upload that, after 10 minutes you'll have your first data element (the temperature), then another 10 minutes later, the next, etc.
You can read the data just by typing
data
and enter on the left-hand side of the IDE. However once you've got quite a bit of data, it'll be too much to fit on a line.If you type
data.forEach(a=>print(a))
then it'll print all the data items, one per line - which you could copy & paste into a spreadsheet. You could also turn that into a function that you can call:To clear out all the old data you can also just write
data=[]
.This way's simple but isn't very efficient with memory so you'll only be able to store around 1000 data items (still, that's 150 hours recording every 10 minutes).
So... to get that on your mobile, you can run the same code on https://www.espruino.com/ide/ on an Android phone (or an iPhone with the WebBLE app).
Or... you could write your own Web Bluetooth webpage. This one will grab the data and just print it to the page:
There's some more info on using Web Bluetooth pages here: http://www.espruino.com/Puck.js+Web+Bluetooth
But once you have it loaded onto the page you could (for instance) display it in some fancier way, allow it to be downloaded, or maybe publish the data to Google Sheets.