arduino iot programming

Learn how to use DHT11 and BMP180 with Arduino to monitor the temperature and pressure storing the data the

This tutorial describes how to use DHT11 and BMP180 to monitor the temperature and the pressure with Arduino connected to

In more details, this Arduino tutorial describes how to connect and use a temperature sensor (DHT11), a pressure sensor (BMP180), and a humidity  (DHT11) sensor.

Moreover, this tutorial covers another important aspect of Arduino programming such as how to send sensor data to an IoT cloud platform so that we can store these values and analyze them later. To send data to the cloud,  Arduino will be integrated with At the end of this tutorial, you will master all the details related to Arduino programming and how to use sensors in your next Arduino IoT project.

The final result is shown below:

DHT11 and BMP180: Monitor the temperature and pressure with Arduino

The image above shows the IoT dashboard based on the values sent by sensors, DHT11 and BMP180,  connected to Arduino.

In more details, sensor data are used to build a real-time dashboard using three different environment parameters:

  • Temperature (DHT11)
  • Humidity (DHt11)
  • Pressure (BMP180)

This Arduino programming tutorial is useful if you want to implement an IoT project that uses Arduino and collects information displaying it using dashboards. Moreover, it is possible to use different sensors connected to Arduino because you can apply the same steps described in this Arduino project.

How to connect temperature sensor (DHT11) and the pressure sensor (BMP180) to Arduino

In this IoT Arduino programming tutorial, the Arduino board connects to a set of sensors and an ethernet shield:

  • 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!!).

Temperature and humidity DHT11 sensor

DHT11 is a very cheap sensor that is able to measure the temperature and the humidity. It is a digital sensor with the digital output signal proportional to the temperature and humidity measured.  DHT11 has only one output pin where the temperature and the humidity values are serialized. It is really simple to connect the DHT11 to Arduino because only three different pins are required.

Pressure BMP180 sensor

The Pressure BMP180 sensor is a low-cost pressure sensor used for measuring barometric pressure. It can measure the temperature also even if this Arduino tutorial uses DHT11 sensor to measure the temperature. It is a I2C sensor so it requires four different wires: Vcc, Ground, Clock and Data.

Implementing the Arduino code to read data from DHT11 and BMP180

The Arduino code to use in our sketch 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 Arduino Library Manager feature in Arduino IDE and look for the BMP180 sensor:

Arduino BMP180 sensor library

How to program Arduino to send data to

Let us focus our attention one of the most important part of this Arduino programming tutorial: how to send data to a IoT cloud platform. Before sending data to the IoT cloud platform, it is necessary that Arduino connects to the network. To this purpose, it is necessary to have an ethernet shield or WiFi shield if you are using an Arduino Uno. if you use another version of Arduino (i.e. Arduino MKR1000) you do not need to use an Arduino shield.

Find out how to use Arduino to monitor other parameters: Monitor air quality using Arduino. is a IoT cloud platform easy to use.  Moreover, it has interesting features as creating a dashboard with received data.
You can create a free account and try it for free. This platform supports Rest services, therefore, it is possible to invoke 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 as described previously.
Once the library is ready, it is important to set up the Ethernet connection 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 a physical object that sends data. Below a screenshot of a thing created for this tutorial:

Arduino programming with DHT11 and BMP180
The important thing is the TOKEN. This is the unique ID to identify our thing (like Arduino board). The Arduino sketch must send this TOKEN 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));

Visualize the data using IoT dashboard: Temperature, Humidity and Pressure dashboard

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

IoT Arduino pressure sensor graph

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 Arduino Programming tutorial, you gained the knowledge of how to connect Arduino to several sensors. Moreover, this Arduino tutorial showed how to send data to an IoT cloud platform ( to create a dashboard using values acquired from sensors.  Once you have configured your IoT dashboard you can access it from everywhere and check remotely the sensor parameters. There are several scenarios where this Arduino project can be used and it is important you gain the knowledge how to connect sensors to Arduino and how to acquire data from sensors so that Arduino can send this information to the cloud.



Please enter your comment!
Please enter your name here