Arduino to ThingSpeak Channel

1. Description

A previous IoT article (MQTT Node with Arduino Uno and W5100 Ethernet Shield) presented a basic system monitoring sensor data in local area network environments, using a locally installed MQTT broker (server). This tutorial presents the possibility of using an open-source cloud-based server (ThingSpeak) that could offer the advantage of remote accessing the collected data, graphical representations and analytics.

Difficulty level: intermediate.

ThingSpeak offer a free web service that allows collecting and storing sensor data in the cloud in order to develop IoT applications. It uses channels to store data sent from apps or devices. Data could be written to channels in two different ways:

– using HTTP calls from the REST API:

o channel data writing (updating) through GET or POST requests;
o channel data reading through GET requests;

– using MQTT publishing:

o channel data writing (updating) through MQTT Publish method;
o channel data reading through MQTT subscribe method.

Channels could be accessed publicly and/or privately and could be visualized in real-time using charts. Data analytics could be done through MATLAB functions.
For additional information please consult the online documentation at

2. Parts

– 1 x Arduino Uno R3;
– 1 x Arduino Ethernet shield (W5100);
– 1 x DHT11 temperature and humidity sensor;
– 1 x BMP180 barometric pressure sensor;
– Breadboard + wires.

3. Schematics

(click to enlarge)

4. Assembly (breadboard)

(click to enlarge)

5. Code

5.1. Update channel data using HTTP (POST) calls from the REST API

arduinoToThingSpeakREST.ino – to be uploaded to Arduino:

5.2. Update channel data using MQTT publishing

arduinoToThingSpeakMQTT.ino – to be uploaded to Arduino:

5.3. Graphical view of channel data

The image below shows a capture screen of the channel data graphical representation; part of the data has been sent through REST API, part of it using MQTT publishing.

(click to enlarge)

6. Additional resources

– Adafruit Unified Sensor Driver:
– DHT-sensor-library:
– Barometric Pressure Sensor Breakout – BMP180:
– SPI, Ethernet and SD standard libraries (included with the Arduino IDE)
– Arduino Client for MQTT:

– DHT11 datasheet:
– BMP180 datasheet:
– Arduino Ethernet shield (WT5100) datasheet:
– ThingSpeak REST API:
– ThingSpeak REST API:

Leave a Reply