This tutorial describes how to connect an Arduino Uno board to the Internet via a computer. The technique here explained implies using a Processing application to act as a gateway between the Arduino board and the net.
Checking the example shown here require the following hardware and software:
Processing can be obtained from the following link:
Download the appropriate version for your OS and run the application. The first time Processing will ask you for the location you want to place your sketchbook. This is the way Processing defines your workspace and where it will be storing all your work by default.
We need to add the simpleML library to the standard installation. Download this file to your Processing sketchbook folder and uncompress it inside he libraries subfolder.
If you did the previous operation right, you should have the following subfolder within your sketchbook: “/Documents/Processing/libraries/simpleML”.
This library has no examples attached to it, you will need this code to act as proxy to send or receive data.
Note that the Processing code is going to read all the variables stored at the url and will be sending all of them through the serial port. If you are interested in just parsing one of them you need to look into the parseHTML method and use the variables:
Download Arduino’s IDE from the following links. Note this is the stable branch of Arduino 0022 (note that the image here used corresponds to Arduino 0022), you could also use the latest stable release:
By default Arduino does not bring a quick example to try this technique, you will need this code on your board.
If you look into the Arduino code within this example, you will see the program is at the same time receiving and sending data through the serial connection. If the value arriving through the port is bigger than 127 the LED on pin 13 will go on. In other words, the example shows how to turn the LED on/off depending on a value stored on a website.
At the same time, the Arduino sketch will be reading the analog pin 0 (A0) and will be sending it to the serial port remapped to fit into a byte (as you know the ADC on Arduino encodes in 10bits but the serial port sends data in bytes).
The Processing example works in one direction only, it will either be sending or receiving data to/from the net. The Arduino sketch and the PHP code remain untouched for both scenarios of use.
You need to have a server where to run the php code that will be reading/writing data from/to your Arduino board. If you don’t have access to a server space online, we can only recommend you install a MAMP (for Mac), WAMP (for Windows), LAMP (for Linux) server locally in your computer.
The installation of those is outside the scope of this document. The only thing left to do is uncompressing the code of the PHP memory cell in this file in the root folder to your http server. Make sure the file has read-write-execute permissions to allow it to rewrite itself.
It is a piece of code that will store the variables you pass to it. Let’s check an example:
A good way of working could be to: