Skip to content

Instantly share code, notes, and snippets.

@maxfunke
Created December 4, 2014 19:46
Show Gist options
  • Save maxfunke/31f0f5de7b62ea330fa6 to your computer and use it in GitHub Desktop.
Save maxfunke/31f0f5de7b62ea330fa6 to your computer and use it in GitHub Desktop.
Serialport w/ Node.js. Parses Strings (send by Arduino).
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var port = "/dev/tty.usbmodem1411";
var sp = new SerialPort(port, {
parser: serialport.parsers.readline("\n")
});
sp.on("data", function (data) {
console.log(data);
// or do some Collection/DB stuff
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment