This topic shows how to build a simple temperature & humidity measurement station using Arduino uno board and Seeed Studio Grove DHT11 sensor module.
The values of temperature (in °C) and humidity (in %) are printed on Grove LCD (1602 I2C LCD) and Arduino IDE serial monitor.
To see how to interface the Arduino with Grove I2C LCD, visit this post:
Interfacing Arduino with Seeed Studio Grove LCD
About the Grove DHT11 sensor:
It’s a low cost digital temperature and humidity sensor module which based on the new DHT11 sensor. The Grove DHT11 sensor requires only one I/O pin for the communication with the master device.
The Grove DHT11 temperature & humidity sensor uses the upgraded version of DHT11. In this version, resistive humidity components is replaced by capacitive humidity components, temperature and humidity measurement ranges are wider and temperature resolution is higher.
The following image shows the basic differences between old (AOSONG) and new (ASAIR) versions:
Grove DHT11 Features:
- Full range temperature compensation Calibrated
- Single bus digital output
- High precision capacitive humidity sensor
- Long transmission distance and excellent long-term stability
- Low power consumption
- Cost-effective
Grove DHT11 hardware overview:
The following image shows a basic hardware overview of the Grove DHT11 sensor board.
Hardware Required:
- Arduino/Genuino UNO board
- Grove base shield —> official page
- Grove DHT11 sensor —> official page
- Grove LCD screen (1602 I2C LCD)
- 2 x Grove 4-pin cable
Arduino with Grove DHT11 sensor and 1602 LCD circuit:
The following image shows the connection of the 3 Grove modules (base shield, 16×2 LCD and DHT11 sensor module) using 4-pin Grove cables.
Note that the base shield is directly mounted to the Arduino UNO board.
The Grove 16×2 LCD display is connected to base shield I2C port where:
GND pin is connected to Arduino GND,
VCC pin is connected to Arduino +5V pin,
SDA is connected to Arduino analog pin 4 (A4),
SCL is connected to Arduino analog pin 5 (A5).
The Grove DHT11 module is connected to base shield port D2 with:
GND pin is connected to Arduino GND,
VCC pin is connected to Arduino +5V pin,
NC is a not connected pin (it looks as it is connected to pin D3),
SIG (signal) pin is connected to Arduino digital pin 2.
Arduino with Grove DHT11 sensor and 1602 LCD code:
Seeed Studio provides a nice open source library for their LCD module which can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “grove lcd” and install the one from Seeed Studio).
Or it can be installed manually, first download library compressed file from the following link:
Grove LCD display Library —> direct link
They (Seeed Studio) also provide a library for their Grove DHT11 sensor but I recommend to use the one given by Adafruit Industries which can be installed also through library manager (in the search box write “dht sensor” and choose the one written by Adafruit) or manually, download links are below:
Adafruit DHT library —> direct link
After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
The same thing for the 2nd library file.
In the Arduino code there are 3 libraries which are included as shown below:
1 2 3 | #include <Wire.h> // include Arduino Wire library #include "rgb_lcd.h" // include Seeed Studio LCD library #include "DHT.h" // include adafruit DHT library |
Definition of sensor type, its data pin connection and the initialization of the DHT library:
1 2 3 4 5 6 7 8 9 | // define DHT11 data pin connection #define DHTPIN 2 // define sensor type as DHT11 #define DHTTYPE DHT11 // initialize DHT11 library with the previous defined // sensor type and data pin DHT dht11(DHTPIN, DHTTYPE); |
Rest of code is described through comments.
The resolution of temperature and humidity measurements are respectively is 0.1°C and 1%.
Full Arduino code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /************************************************************************* * * Interfacing Arduino with Seeed Studio Grove LCD (I2C 16x2 LCD) * and DHT11 digital humidity and temperature sensor. * Values of temperature (in °C) and humidity (in %) are printed on * the 1602 LCD and Arduino IDE serial monitor. * This is a free software with NO WARRANTY. * http://simple-circuit.com/ * ************************************************************************/ #include <Wire.h> // include Arduino Wire library #include "rgb_lcd.h" // include Seeed Studio LCD library #include "DHT.h" // include adafruit DHT library // define DHT11 data pin connection #define DHTPIN 2 // define sensor type as DHT11 #define DHTTYPE DHT11 // initialize DHT11 library with the previous defined // sensor type and data pin DHT dht11(DHTPIN, DHTTYPE); // initialize LCD library rgb_lcd lcd; void setup() { // open serial communication Serial.begin(9600); // initialize the LCD with 16 columns and 2 rows: lcd.begin(16, 2); // initialize the DHT11 sensor dht11.begin(); } // main loop void loop() { char _buffer[14]; // read humidity int humi = dht11.readHumidity() * 10; // read temperature int temp = dht11.readTemperature() * 10; // print temperature (in °C) if(temp < 0) // if temperature < 0 sprintf(_buffer, "TEMP =-%02u.%1u%cC", abs(temp)/10, abs(temp) % 10, 223); else // temperature >= 0 sprintf(_buffer, "TEMP = %02u.%1u%cC", temp/10, temp % 10, 223); lcd.setCursor(0, 0); lcd.print(_buffer); // print temperature on LCD Serial.println(_buffer); // print temperature on serial monitor // print humidity (in %) sprintf(_buffer, "RH = %02u.%1u %%", humi/10, humi % 10); lcd.setCursor(0, 1); lcd.print(_buffer); // print humidity on LCD Serial.println(_buffer); // print humidity on serial monitor delay(1000); // wait a second } // end of example code. |
Discover more from Simple Circuit
Subscribe to get the latest posts sent to your email.