Skip to content

How to use Node.js and Socket.io labratories with Raspberry Pi and Arduino

eliosr edited this page Jul 25, 2014 · 9 revisions

General

To use these laboratories you need:
-A Raspberry Pi board (Model A or B)
-An Arduino UNO board (Rev. 3)
-An Internet connection

Connecting Raspberry Pi to Internet

The easy way is reading and following this tutorial https://learn.adafruit.com/downloads/pdf/adafruits-raspberry-pi-lesson-3-network-setup.pdf

Setting up Raspberry Pi

Raspberry Pi Firmware and Software Update
Firmware (https://github.com/raspberrypi/firmware):


To update the firmware of Raspberry Pi
follow the instruction of https://github.com/Hexxeh/rpi-update


Restart when finish.
Verified firmware version:
/opt/vc/bin/vcgencmd version
The date of the version should be after of 1st of June


To Update the Kernel and Distributions:
Write on shell:
sudo apt-get update
sudo apt-get dist-upgrade


Verified software version
uname -a
the date of software should have changed to more recent date

Install Node.js sockets.io and libraries in Raspberry Pi

From Raspbian:
Install Node.js: You should use the official tutorial
https://github.com/joyent/node/wiki/Installation
Install Node Package Manager https://www.npmjs.org/. Use “sudo apt-get install npm”
Once it is installed, you should install the libraries socket.io and serialport
The libary socket.io is developed in JasvaScript and supports realtime web applications.
The Robotic Arms will be connected to Raspberrypi by an USB port, therefore the library serialport must be installed to communicate Raspberry Pi with Arduino.

  • Install Socket.io, https://www.npmjs.org/package/socket.io). Use “sudo npm install socket.io”.
  • Install “serialport” to use Arduino via serial port (https://www.npmjs.org/package/serialport). Again “sudo npm install serialport”.

Connecting Arduino UNO board

These laboratories only work with an Arduino UNO board. So you can to connect your Arduino UNO board to the USB port of Raspberry Pi.

Bootstrap libraries for download into Apache server (or into Raspbian)

Project folder into Apache server: “C:\....\www\Node_LabX” (your folder in Apache server)
Project folder into Raspbian: “\var\www\Node_LabX” (your folder in Raspbian)
Download bootstrap from: https://github.com/twbs/bootstrap/releases/download/v3.1.1/bootstrap-3.1.1-dist.zip
Download bootstrap slider from: http://www.eyecon.ro/bootstrap-slider/slider.zip

Cloning the Github repository

For use each laboratory you can download the files into repository of Github. You can use 3 different laboratories:
-Led RGB laboratory. You can go to the tutorial of this laboratory here (Led RGB)
-Robotic Arm laboratory. You can go to the tutorial of this laboratory here (Robotic Arm)
-Servo laboratory. You can go to the tutorial of this laboratory here (Servo)