Skip to content

Instantly share code, notes, and snippets.

Last active July 29, 2016 22:40
What would you like to do?

#Punch through bean info

  1. download the arduino program to write arduino code -

  2. download whichever bits on here you need

  3. 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. 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.

  1. 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 -

void setup() {
Serial.begin(9600); // initialize serial

void loop() {
    float currTemp = Bean.getTemperature();
  1. 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 () {

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment