Humidity IoT


        This project allows you to check the humidity measured by a DHT11 humidity/temperature sensor on a mobile App. Although the sensor provides temperature as well we created this project to focus exclusively on humidity. For temperature measurements the DS18B20 chip (included in the Temperature IoT project) is a better option (better precision).



Project  Humidity Monitor
Time to build  1 hour
Cost $30
Arduino Code download
Cloud Device Code N/A
Mobile App Code download (for a user interface using a gauge use this download)



        Here you have the list of components required to build the hardware. We assume you have a computer, a router and a network cable. If you purchase the Arduino board from the specified source it comes with the USB cable. Otherwise you might need to provide a USB cable. You can find better options for hardware. Be careful what components you buy. For Ethernet boards there are many versions with different chip sets but only the standard Arduino Shield or equivalent works with the software provided here. The prices are just a guide. These are the values we found when we created this project.

Picture Name Price Source

Arduino Uno

 $13 Link
Arduino Ethernet Shield $10 Link
Humidity/Temperature Sensor $3 Link
Single Port Female to Female Jumper Wires $3 Link
Single Port Male to Male Jumper Wires $2 Link


        We recommend to buy an Arduino board with a smaller USB connector (mini or micro USB) because the Ethernet Shield will not insert properly most of the time if you do not use original Arduino boards.

        Here you have a picture with the components we used:




       This section shows the pinout of the components or provide a link to the specifications of the component.


Component Name Pins
Arduino Uno See:
Arduino Ethernet See:
Humidity/Temperature Sensor
Pin Description
GND Ground
Data Communication Channel
5V 5V



        This section shows you how to connect the components together. First you have a pin-out connection and below there are pictures showing how it's done on the real boards.


Humidity/Temperature Sensor Pin ArduinoUno
5V +5V
Data D8


Arduino Ethernet ArduinoUno
Just insert the Ethernet Shield into Arduino Uno

       Here you have pictures with the wiring





        The schematic is




        To run the system you need two software components. One is the software to run the hardware (Arduino Software) and the other one is the mobile App (Mobile App).


     Arduino Software

       To run the software you need the Arduino development environment. You have to load the software provided here and configure it. There is only one value you need to change in the code.


Field Description

This is a unique id you have to create for your hardware device to identify it from others in the cloud. Use this to generate GUID (Global Unique ID)

String devId      = "b5ebf7a7-e63a-4660-8f83-cf1e5d39cf5b";

This is the authentication string requred for basic authentication of the http requests. Create a string from <email_address>:<API_Password> and encode it base64. The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password"

String auth    = "dXNlcjpwYXNzd29yZA==";


       And here you have the sketch (download)


#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xDD };        // mac address for ethernet board
EthernetClient eth;                                         // the Ethernet client

char server[]  = "";                          // Wiring Cloud host name
int port       = 80;
String devId   = "111-222-333";                             // Device ID. CREATE YOUR OWN GUID; Use this
String auth    = "dXNlcjpwYXNzd29yZA==";                    // Authentication credentials Create a string from <email_address>:<API_Password> and encode it base64
                                                            // The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password"

#define  DHTPin 8                                           // pin to connect DHT11 chip's data pin
byte     DHTData[5];                                        // collect the data red from sensor

// Update HUMIDITY value on the server
void sendHumidity(String humidity)
  Serial.println("Send Humidity...");
  if (eth.connect(server, port)) {                               // initialize HTTP connection on port 80
    eth.println("GET http://" + String(server) + ":" + String(port) + "/Wire/connector/set?id=" + devId + "&HUMIDITY=" + humidity + " HTTP/1.1");   // submit HTTP request
    eth.println("Authorization: Basic " + auth);
    eth.println("Connection: close");
  else {
    Serial.println("Connection Error");


// Initializa DHT Chip
void initDHT() {
  pinMode(DHTPin, OUTPUT);
  digitalWrite(DHTPin, HIGH);

// read Data from DHT11 chip
byte readDHTData() {
  byte dht_in;
  byte i;
  digitalWrite(DHTPin, LOW);
  digitalWrite(DHTPin, HIGH);
  pinMode(DHTPin, INPUT);

  dht_in = digitalRead(DHTPin);
  if (dht_in) {
    return 1;

  dht_in = digitalRead(DHTPin);

  if (!dht_in) {
    return 2;

  for (i = 0; i < 5; i++)
    DHTData[i] = readDHTByte();

  pinMode(DHTPin, OUTPUT);
  digitalWrite(DHTPin, HIGH);
  byte dht_check_sum =
    DHTData[0] + DHTData[1] + DHTData[2] + DHTData[3];

  if (DHTData[4] != dht_check_sum)
    return 3;
  return 0;

// read next byte from DHT sensor
byte readDHTByte() {
  byte i = 0;
  byte result = 0;

  for (i = 0; i < 8; i++) {
    while (digitalRead(DHTPin) == LOW);
    if (digitalRead(DHTPin) == HIGH)
      result |= (1 << (7 - i));
    while (digitalRead(DHTPin) == HIGH);

  return result;

void setup() {


void loop() {
  String st;
  String sh;

  switch (readDHTData()) {
    case 0:
      sh = String(DHTData[0])  + "." + String(DHTData[1]);
      Serial.println("Humidity = " + sh);
    case 1:
      Serial.println("Error 1: DHT start condition 1 not met.");
    case 2:
      Serial.println("Error 2: DHT start condition 2 not met.");
    case 3:
      Serial.println("Error 3: DHT checksum error.");
      Serial.println("Error: Unrecognized code encountered.");


     Mobile App


        The mobile application to control the security system is built with "App Inventor" ( If you just want to import the .aia file you can download it here. Otherwise you have to create next components.


Component Name Description
Label HumidityMsg A text that shows the humidity.
Clock Timer A timer that will send regular requests to get the humidity from the Wiring Cloud.
Web APIGetHumidity

The HTTP request that will be sent to retrieve the humidity value. Set URL to:<device_id>&HUMIDITY

don't forget to put the device_id you set in the Arduino Code

        In the code you have to set a proper authentication string. Replace the string "Basic dXNlcjpwYXNzd29yZA==" with your authentication string. Create a string from <email_address>:<API_Password> and encode it base64. The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password". Make sure you append "Basic " at the beginning of it.

        And this is the logic you have to create in App Inventor. Once that is done you just build the APK and install it on your Android phone.


    Final Product

       Here you have a picture of the "final" product, hardware and screenshots from App.



Here you have the "fancy" App that uses a gauge to display humidity: