Getting Started

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:

  • an Arduino Uno board (or any other)
  • Processing 1.5
  • Arduino 0022 (or the latest stable release)
  • the simpleML library for Processing
  • a server able of running PHP scripts

1. Processing + Processing Libraries

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.

Variables in the example

  • receiving: when false your Processing sketch will be reading one byte at the time and printing it to the STDOUT. When true it will send one byte coming from the serial port at the time up to the website via a PHP request (it will require the useSerial to be true)
  • useSerial: when true the example will be reading/writing from/to the serial port. You need to make sure the right name to the port is being used at the declaration within setup. Remember that it will look like “/dev/ttyACMXX” for Linux, “/dev/cu.usbmodemXXXX” for Mac, and “COMXX” for Windows
  • url: this is the URL for the PHP code that we will use to store data online

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:

  • theKey: this one contains the variable’s name
  • theValue: this one contains the variable’s value

2. Arduino 0022

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.

How does the Arduino code work?

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.

3. PHP-able server

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.

How does the PHP cell work?

It is a piece of code that will store the variables you pass to it. Let’s check an example:

  • you can send data to the script using the GET method. An example would be like this: http://address.toYourServer.com/php_mem_cell.php?f=4
  • that will make the script add a block of HTML markup to the top of the PHP code including the variable and its value in the following form:
<div ID='0'>
  <div ID='key-0'>f</div>
  <div ID='val-0'>4</div>
<!-- EOF DATA -->
  • if you just want to read the data posted to the PHP memory cell, check the website on your browser:


  • the Processing example will be sending just one variable at the time to the website, you can be refreshing the website on your browser to see how the value changes


A good way of working could be to:

  1. write you Arduino sketch for sending data to the net first
  2. make sure you are sending the data properly by taking a look to your website in a browser
  3. write your Arduino sketch for getting data from the net
  4. make sure the receiving board is updating at the same speed you are sending data