Blog Home

Node.js on the Arduino Yún via the Bridge library

Zoe RomanoJuly 7th, 2014

ArduinoYun

Tom Igoe some days ago wrote an interesting post about Arduino Yún on his blog.  We post it here as it could be useful to the Arduino Community.

————————–

Recently, Federico Fissore added node.js to the package repository for the Arduino Yún. Here’s how you get node to communicate with the Arduino processor on the Yún via the Bridge library.

To do this, you’ll need an Arduino Yún, a microSD card, a microUSB cable and a wifi connection. You should be familiar with the basics of the Arduino Yún and node.js in order to get the most out of this post.

All of the code for this post can be found on my GitHub repository.

First you’ll need to install node on the Yún. Make sure you’ve upgraded to the current Yún software image and have connected to the internet via wifi. Then ssh into your Yún, or connect to the command line interface using the the YunSerialTerminal sketch, and issue the following commands:


$ opkg update
$ opkg install node

That’s it. Now you have node.js onboard. You can check that it’s okay by checking the version:

$ node -v

You should get the version number in reply.

Once you’ve got that working, you’ll undoubtedly want to communicate with the Yún’s Arduino processor from node. You can do this using the Bridge library. On a microSD drive, make a directory for your node scripts. I called mine /arduino/node. Then insert it into your Yún. For reference, its path from the command line is /mnt/sda1/arduino/node.

Note: The Yún automatically treats the microSD card’s /arduino/www/ directory as a public web directory. Anything you put in there will be served out as static HTML. So you may not want to put your node scripts in this directory, so they’re not visible via the browser. That’s why I created a node directory at the same level as the www directory, but outside it.

Read the complete post at this link>>

3 Responses to “Node.js on the Arduino Yún via the Bridge library”

  1. Feedback Says:

    Thanks for sharing. This was exactly what I was looking for!

  2. angeldimitrov Says:

    Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

  3. HashimKahily Says:

    Hello sir,
    I followed your tutorial on how to use Node.js on Arduino Yun. I’m able to get values from my server using node.js and successfully pass on those values to the arduino side. But I’m not able to send values from Arduino side to the node.js side.
    For example…Serial.println(“Hello from Arduino”); doesn’t evoke this line
    lineReader.on(‘line’, function (data) { console.log(‘You sent me: ‘+ data); });
    even nodejs.write(“Hello from Arduino \n”); doesnt send any data to echo.js
    I’m referring to the BridgeToNode codes. Please Help!
    Thank you for your time.

Leave a Reply

You must be logged in with your Arduino account to post a comment.