IoT Arduino Programming: Monitor Environment Parameters

This IoT Arduino programming tutorial describes how to build an IoT project. This IoT project uses Arduino board to monitor the environment. Data collected using sensors is sent to the cloud using This IoT Arduino programming example shows how easy is it building an IoT project. The final result of this IoT project is shown below:

IoT Arduino Programming
This IoT Arduino programming tutorial builds a dashboard using three different environment parameters:

  • Temperature
  • Humidity
  • Pressure

If you are not familiar with IoT project is useful to read first this tutorial. This is an interesting project because it has several applications. For example, check your room air parameters or predict weather or know if the room air is in the comfort zone.

Build #IoT project using #arduino and sensors. Step by step guide. Click To Tweet

arduino iot programming

Arduino sketch

In this IoT Arduino programming tutorial, the Arduino board is connected to a set of sensors and an ethernet shield. Sensors used in this IoT Arduino programming project are:

  • DHT11 (Temperature and Humidity sensor)
  • BMP180 (Pressure sensor)

Both sensors are connected to +5V and they are perfect for Arduino Uno. The details of the sketch and the way the sensors are wired to Arduino are not important, so it will not be shown here (but it is very very simple!!).

The code to read data from DHT11 and BMP180 is shown below:

#include <Adafruit_BMP085.h>
#include "DHT.h"
#define DHTPIN 2 //Arduino PIN
#define DHTTYPE DHT11 // DHT11 Type

Adafruit_BMP085 bmp;

void setup() {

void loop() {
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  float presPa = bmp.readPressure();
  float presMb = presPa * 1013.25 / 101325;

One important thing to remember is importing the BMP180 library. You can do it using Library Manager feature in Arduino IDE and look for BMP180 sensor:
Arduino BMP180 sensor library

Send sensor data to the cloud in IoT Arduino Programming

Let us focus our attention on the most important part in IoT Arduino programming: how to send data to the cloud. Of course it is necessary an ethernet shield or WiFi shield. Arduino connects to internet through them.

Find out how to use Arduino to monitor other parameters: Monitor air quality using Arduino.

As cloud IoT platform, this IoT project uses This IoT cloud platform is easy to use.  It has interesting features as creating a dashboard with data sent.
You can create a free account and try it. This platform supports Rest services so that it is possible to invoke its services using an Arduino HTTP client.
You can create a free account and try it. This platform supports Rest services so that you can call its services using an Arduino HTTP client. Anyway provides an Arduino library to simplify the process. You can download it from its Github repository and install it in your IDE.
Once the library is ready, it is important to setup the Ethernet shield properly:

// Mac address
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // Arduino mac address
EthernetClient client;
IPAddress ip(192, 168, 1, 178); // Arduino IP Add
IPAddress dns1(8, 8, 8, 8);
IPAddress gw(192, 168, 1, 1);
void setup() {
  // You could use DHCP instead
  Ethernet.begin(mac, ip, dns1, gw);

The next step is configuring the platform to accept data coming from Arduino. In this case you have to create a “thing” that is like a physical object that sends data. Below a screenshot of a thing created for this tutorial:
Not arduino programming
The important thing is the TOKEN. This is the unique ID to identify our thing (like Arduino board). This TOKEN has to be sent when connecting to to identify your Arduino board. Once the platform is configured correctly, the final step is setting up the code for sending data:

// TheThings tkoken
#define TOKEN "_xxxxxxxxxxxxxxxxxxx"
// The thing server address
thethingsiOEthernet thing(TOKEN);
void sendValues(float temp, float hum, float pres) {
  Serial.print("Sending data to TheThigs...");
  thing.addValue("temp", String(temp));
  thing.addValue("hum", String(hum));
  thing.addValue("pres", String(pres));

You can check the value read from the sensors sent to the cloud:
IoT Arduino data cloud
Using dashboard feature you can create custom dashboard to show charts creating from the data:
IoT Arduino pressure sensor
IoT Arduino dashboard cloud data

It is possible to get real time value or historical values.

Have you ever thought to send temperature and pressure information via twitter? I suggest reading this tutorial about sending Tweets from Arduino.

At the end of this IoT Arduino Programming tutorial, you gained the knowledge how Arduino sends data to the cloud and create dashboard using this information.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.