Putting them all together
I wrote about
installing Drupal 7 on the Raspberry Pi and about
installing node.js on the Raspberry Pi. Now I am writing about adding an Arduino. The Arduino will communicate with the Raspberry Pi over Ethernet. My setup uses an Arduino Uno with an Ethernet Shield. I imagine you could use any of the Ethernet capable Arduino variants as well.
The Hardware List
Raspberry Pi and node.js
Load the Raspbian "wheezy" image on your Raspberry Pi. (You can find directions for this on the
Raspberry Pi website.) I suggest installing a
LAMP stack and Drupal 7, you will at least need to install MySQL. Install node.js on the Raspberry Pi as I outlined in
this earlier post. Then create a new file named server.js and copy the node.js code from my
Arduino and node.js post. Install MySQL if you haven't and setup the required database and user as outlined in the Arduino and node.js post. Run the node.js program with the command
node server.js This will start the node.js server listening on port 8080. Note the Raspberry Pi's IP address so you can edit the Arduino code to point to it. I use the command
ifconfig to get the Raspberry Pi's IP address.
Arduino and Ethernet Shield
If this is your first time programming an Arduino then head over to
arduino.cc and read the
Getting Started Section. Create a new sketch and copy and paste the arduino code from my previous post about
Arduino and node.js. Edit the server IP address and name to match that of your Raspberry Pi. If you are not using a DNS server then you can bypass that code by commenting out the line that assigns the DNS IP address to the receiver IP address. The Arduino code samples the analog input pin A0 and writes it to a node.js server every 10 seconds. During start-up the arduino will write its IP address and the server IP address to the USB serial communication port. With the Ethernet shield installed on the Arduino Uno connect it to the Ethernet network. Load the sketch to the Arduino over a USB cable and then open the serial port monitor. If your network is setup with a router that servers up DHCP addresses then the Arduino should print its address to the serial port monitor.