Arduino – Node.js

Testing Arduino Uno – Node.js

Serial Monitor messages to terminal.

First download and install node.js on your computer.

Then build Node.js server

Install serialport. Open terminal and type:

npm install serialport

Create a java script file named server1.js and use the code below:

var serialport = require('serialport');
var portName = '/dev/tty.usbmodem1421';
var sp = new serialport(portName, {
    baudRate: 9600,
    dataBits: 8,
    parity: 'none',
    stopBits: 1,
    flowControl: false,
    parser: serialport.parsers.readline("\r\n")

sp.on('data', function(input) {

Make sure that the portName is the right one. To check this go to Arduino IDE and navigate to Tools->Serial Monitor

Then open terminal and cd to the directory of the server1.js file and execute the file using the below code:

node server1.js

and voila!

Author: Vasilis Agiomyrgianakis

Created: 2016-12-04 Sun 21:10

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s