#Punch through bean info
-
download the arduino program to write arduino code - https://www.arduino.cc/en/Main/Software
-
download whichever bits on here you need https://punchthrough.com/bean/guides/everything-else/downloads/
-
I had problem trying to get the serial port to read correctly, can’t remember which magical incantation i had to do, but it was on the punchthrough forums, i can go back and look if you need it.
http://beantalk.punchthrough.com/t/heres-how-to-access-bean-serial-data-in-processing/751 this may have been it, but i'm pretty sure the npm package below fixed it too, might be useful if the npm package doesn't work.
- Arduino Script - you need to make sure the board is setup to be a LightBlue Bean
Info on how to get all the values etc are from here - https://punchthrough.com/bean/guides/features/temperature/
void setup() {
Serial.begin(9600); // initialize serial
}
void loop() {
float currTemp = Bean.getTemperature();
Serial.println(currTemp);
Bean.sleep(10000);
}
- NodeJS Script (need to install moment + serialport)
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var fs = require('fs');
var moment = require('moment');
var port = new SerialPort('/dev/tty.LightBlue-Bean', {
baudrate: 9600,
parser: serialport.parsers.readline('\r\n')
});
port.on('open', function () {
console.log('open!');
});
port.on('error', function (err) {
console.log('error ' + err);
});
port.on('data', function (data) {
console.log('Data: ' + data);
var output = "" + moment().toISOString() + "," + data + "\n";
var fileName = moment().format('dddd-DD-MMM');
var filePath = fileName + ".csv" ;
fs.appendFile(filePath, output, function(err) {
if(err) {
return console.log(err);
}
});
});