A networked Arduino, a couple wires, copy/paste some code and in less than 10 minutes you’ll see your sensor values graphed in real-time and be able to see all past values you’ve ever published.
This example contains two “modes” of operation: Provisioning & Normal modes. When the device is started in provisioning mode it publishes a message to the m2m.io portal which associates the device to a user’s account. This allows the m2m.io developer portal to recognize data published from a specific device and display the data in a meaningful way (graphs, maps, gauges and other widgets). Provisioning only needs to be done once and a device can be entered again if the need arises to provision the device to a different user.
Normal mode means the device is in a continuous loop, reading data values from a sensor and publishing them to the m2m.io platform. After a device is provisioned it can be started, powered down and restarted without provisioning. This is the “normal” state of the device doing its job as a temperature monitor, light sensor or whatever other application it is designed to perform.
Prerequisites
- Arduino (Uno in this example)
- Ethernet/Wireless Shield & Library
- MQTT Library (PubSubClient) - see here for an explanation on installing Arduino libraries
- A free account on the m2m.io platform developer portal (more detail below)
Circuit
Below is a diagram and picture of the circuit used for this example.
Arduino with Ethernet Shield, potentiometer, jumper wire
Circuit Diagram - note the circuit diagram assumes an Ethernet / WiFi shield attached
The circuit contains two notable features. First, a jumper wire (the white wire above, attached to analog pin 0). This allows switching between device modes without a change of software. With pin 0 jumpered to ground, the device will start in “provisioning mode”. With the input floating or tied to +5V, the device is in “normal mode”.
The second feature is the use of a potentiometer as a sensor. This allows for easy manipulation of the “sensor” value to see changes when initially setting up the circuit. This portion of the circuit could easily be swapped for many of the sensor examples found online.

Note the Domain field as this is used when configuring the software below. Also note the Devices tab. This is where your list of devices associated with the current account can be found.
Software
The Arduino sketch for this example can be downloaded from GitHub. Note that this sketch relies upon the Ethernet Shield and library installed. A future blog post will include support for the WiFi shield and corresponding library.
Once downloaded, the sketch needs to be updated with your credentials and domain from the m2m.io portal.
The username is the username (email) you used to create an account on the developer portal.
The password is the password for your developer portal account. This value is not the clear text password, rather the MD5 hash of the password. An MD5 string can be generated through command line tools such as md5 on Mac OS X and md5sum on Linux. Online generators are also available by searching “md5 generator” with an online search engine. To validate your chosen tool, the correct MD5 hash of “helloworld” is MD5 (“helloworld”) = fc5e038d38a57032085441e7fe7010b0.
Note the Domain is the 32 character MD5 hash found on the Account page:
The Device ID should be chosen to be a unique value between all of your devices. Serial numbers, MAC addresses or any other unique value can be used.
Operation
Next the device will be provisioned to your m2m.io account. Login to the portal and click on the Devices tab. You should see a device list which may be blank if you have not yet provisioned any devices.
Click on “Register a device” to start listening for a provisioning message from the Arduino device.
With the jumper wire connected between Analog 0 and Ground, validate the sketch and download it into your Arduino. You should see a successfully found device message after the Arduino connects to your network and publishes a registration message. Common errors at this point are not connecting the ethernet cable to the ethernet shield and not having the jumper wire connected to ground.
The serial monitor can be used to help debug device mode (provisioning vs normal).
At this point the device has been successfully provisioned to your account and shows up in your device list. The Arduino can now be started in normal mode and sensor values will be published to the m2m.io platform. Simply disconnect the jumper wire from ground and press the reset button on the Arduino board. The device will connect and publish sensor readings. The potentiometer can be turned to vary the “sensor” values to see changes in real-time.
To see real-time values click the Go to button next to the device. This displays an embedded MQTT client showing values published by the device:
Note that whenever the board starts up without the jumper attached to ground it will publish sensor values to the platform. If needed, the device can be reprovisioned at any time by inserting the jumper wire again and pressing the reset button on the Arduino.
Platform Features
A key feature of the m2m.io platform is the ability to recall previously posted values through a REST API. Every message posted to the platform is stored in our backend data store so an application can pull the complete history of every device. The developer portal provides several intuitive ways to visualize past / present stored values from the platform.
Present
The screenshot below shows a data tree showing the most recently published values:
And the same values as JSON. The JSON view gives an example of the data returned when making an API call to the platform programmatically.
Notice that because the user is logged into the portal that domain does not need to be entered. Arduino is the “stuff” parameter and Device1 is the “thing”. In this way multiple Arduinos could be connected as Device1, Device2, and so on and this call could be used to query the most recent value from those devices.
Past
The screenshot below shows a graphical timeline of published sensor values. The query is built using Arduino as the “stuff”, Device1 as the “thing” and t as the “whatever”. In this way multiple values could have been published (e.g. temp, altitude, light) and each value could be queried.
Again the JSON view shows what would be returned from the API:
For more information on calling the API programmatically, see the blog post here.