Wi-Fi temperature and humidity sensor – Arduino / DHT22 / ESP8266 / LCD

1. Introduction

The goal is to prototype a temperature and humidity sensor that will be able to send data through Wi-Fi using the open-source platform ThingSpeak.

connected-sensor-1

thingspeak

2. Hardware

We’ll detail the wiring step by step. It’s strongly recommended to use a breadboard for an easier wiring. The final result should be close to the picture shown in the introduction.

2.1 Sensor : DHT22

Wire as shown below :
DHT22_bb

2.2 Wi-Fi module : ESP8266

Wire as shown below :
ESP8266_bb

2.3 LCD : 16×2 HD44780 based

The LCD is from sparkfun.
Wire as shown below :
lcd_bb

lcd-datasheet

2.4 Final result

connected-sensor-2

3. Software

3.1 ESP8266 library installation

An open-source library is available on Github :
https://github.com/itead/ITEADLIB_Arduino_WeeESP8266

1 – Download ZIP :
github-download-zip

2 – Import the new library :
arduino-import-library

3 – Configure the new library :
As we use the ESP8266 module with a SoftwareSerial connection, we need to edit the ESP8266.H file.
This file is available in :
C:\Users\MyUser\Documents\Arduino\libraries\ITEADLIB_Arduino_WeeESP8266-master :

Uncomment the following line as below :

3.2 DHT22 library installation

An open-source library is available on Github :
https://github.com/adafruit/DHT-sensor-library

1 – Download ZIP :
github-download-zip

2 – Import the new library :
arduino-import-library

3.3 LCD library

The LCD library is available directly from the Arduino software :
Sketch > Include library > LiquidCrystal

3.4 Program

The code is available on Github :
https://github.com/ronan-fontenay/arduino-wifi-sensor

The following information must be filled up :

The code :

3.5 Program footprint

program-footprint

8 thoughts on “Wi-Fi temperature and humidity sensor – Arduino / DHT22 / ESP8266 / LCD”

  1. dear sir, your work is really useful for newbie like me. But unfortunately i got msg “WiFi setup [AP ERR]”. What should i check. TQ in advance.

    1. Selamat pagi!

      This means that the module is not able to connect to your WiFi access point. Double check you SSID (space, characters…) and your password (WiFi key).

      You can try closer as well…

        1. Hi, There were a mistake in the diagram, I’ve just updated it :). Do you see the difference ?

  2. Arduino:1.6.13 (Windows 7), PÅ‚ytka:”Arduino Pro or Pro Mini, ATmega328 (3.3V, 8 MHz)”

    C:\Users\Marcin\Documents\Arduino\Ardu_LCD_DHT_ESP\sketch_feb06a\sketch_feb06a.ino: In function ‘void loop()’:

    sketch_feb06a:86: error: ‘gt’ was not declared in this scope

    while(count_down >= 0){

    ^

    sketch_feb06a:86: error: expected ‘)’ before ‘;’ token

    while(count_down >= 0){

    ^

    sketch_feb06a:86: error: expected primary-expression before ‘=’ token

    while(count_down >= 0){

    ^

    C:\Users\Marcin\Documents\Arduino\Ardu_LCD_DHT_ESP\sketch_feb06a\sketch_feb06a.ino: In function ‘bool update_thingspeak()’:

    sketch_feb06a:187: error: ‘gt’ was not declared in this scope

    if (len > 0) {

    ^

    sketch_feb06a:187: error: expected ‘)’ before ‘;’ token

    if (len > 0) {

    ^

    sketch_feb06a:187: error: expected ‘;’ before ‘)’ token

    if (len > 0) {

    ^

    sketch_feb06a:219: error: expected ‘}’ at end of input

    }

    ^

    sketch_feb06a:219: error: expected ‘}’ at end of input

    sketch_feb06a:219: error: expected ‘}’ at end of input

    Znaleziono wiele bibliotek w “DHT.h”
    Wykorzystane: C:\Program Files (x86)\Arduino\libraries\DHT
    Niewykorzystane: C:\Users\Marcin\Documents\Arduino\libraries\DHT-sensor-library-master
    exit status 1
    ‘gt’ was not declared in this scope

    HELP :<

      1. Yes, it’s compiling now and flashing correctly. But every time I have Wifi ERR – AP. SSID and password are 100% ok. I connected my USB-TTL converter to 3 and 4 pins to arduino Pro mini and it’s not sending any data to ESP8266. That’s the problem. I uncommented the line in ESP8266.H file but still don’t know why it’s not working.

Leave a Reply

Your email address will not be published. Required fields are marked *