Humidity and temperature are the common parameters to measure the environmental conditions of surroundings. This time we are going to build an Arduino based Weather Monitoring Device Using OLED Display where you can measure temperature and humidity in your surroundings. The value will show in the OLED display after sensing via a humidity sensor. DHT11 is used here as the purpose to sense the temperature and humidity level. The sensitivity of DHT11 is very good than others. This project is very cost-efficient and accurate working.
Must Read Temperature And Humidity Monitoring System Using ESP8266 NodeMCU
Principle Behind Weather Monitoring Device
Basically, the Arduino weather monitoring device has three parts. The first part senses the humidity and temperature of the surrounding by the DHT11 sensor. The second part is the time or delay when the DHT11 sensor’s output is read by the Arduino. Also, the data get extracted into temperature and humidity values in percentage form. We can measure the value on the Celsius scale as well as on the Fahrenheit scale. At last, the third part, where the Arduino displays humidity and temperature in the OLED display.
Project
Circuit Diagram
Components Required
- Arduino
- DHT11 Module
- 1KΩ Resistor
- OLED Display
- Breadboard
- Wires
- 9V Battery
About Parts
Arduino
For the compact build, I choose Arduino Nano despite Arduino UNO. Arduino Nano is a small, flexible microcontroller board using an Atmega328p chip. It can also use as a substitute for UNO. All the functions are the same in these two boards. The size of its PCB is 18×45 mm. The clock speed is 16Mhz. Its input voltage is 5-12V. There are 30 pins including power pins, data pins, analog pins, and serial pins on this board.
DHT11 Module
The DHT11 is a low-cost temperature and humidity sensor based on a capacitive humidity sensor and a thermistor. It can measure the surrounding air quality and take the data on the data pin. The use of this sensor is very easy but needs proper care when data is captured.
As we already explain, we use the DHT11 sensor because this module has a feature humidity and temperature complex with a digital signal. This module also gives us a precise value. So we can ensure the reliability and stability of the values. This sensor uses a resistive type humidity measurement and NTC type temperature measurement. DHT11 has an inbuilt 8-bit microcontroller that gives a very fast response. There is also a 4-pin single-row package available in this module.
DHT11 module works with single-wire communication. Data is sent in a specific time period in the form of a pulse. Before sending data to the Arduino, it needs some commands and a time delay. The time required for it is approx 4ms. 40-bit data transmission happens in this process. For example, 8-bit integral RH data + 8-bit decimal RH data + 8-bit integral T data + 8-bit decimal T data + 8-bit checksum.
OLED Display
The OLED is known as an organic light-emitting diode or Organic electroluminescent diode. This type of display is made of many layers. It is sealed on the top or bottom with plastic or glass. There are four pins in an OLED module. Those are GND, VCC, SDA, and SCL.
Circuit Connection
An OLED display is used here to show temperature and humidity which is connected to Arduino. The pin of the OLED display SDA and SCL is connected to pins A4, and A5 respectively. This display works on 5V so we connect the 5V pin of Arduino with it. The DHT11 sensor is also connected to digital pin 12 of Arduino with a 5K pull-up resistor (exceptional).
Arduino Nano | DHT11 Module |
---|---|
+5V | VCC |
GND | GND |
D2 | OUT |
Arduino Nano | OLED Display |
---|---|
+5V | VCC |
GND | GND |
A4 | SDA |
A5 | SCL |
Working Principle of Weather Monitoring Device
There are three main components used in this project that are Arduino (for processing) and the DHT11 sensor module (for sensing temperature and humidity), and the last is OLED display (for showing the output result). This project is processed with serial communication.
First, Arduino sends a signal to the DHT11 module and DHT11 gives the response. The DHT11 already contains humidity and temperature data with it in analog form.
Then Arduino collects the data from the DHT11 module and extracts it into two parts. The first one is humidity and the second is temperature. After extracting, Arduino sends the digital value to the OLED display for showing the result.
After sending a high or low signal to the DHT11 sensor, Arduino ensured that module detection works. This process happens with an 18 μs delay. Then it pulls the data line and holds for 30μs until the module responds. Then DHT11 sends a low voltage as a response after 80μs. Now the microcontroller of DHT11 pulls up the data and waits for 80μs until DHT11 arrange to send data.
A low voltage level indicates that DHT11 is sending a response signal. The data sent by the module starts with a 50μs voltage level. The data bit is 0 or 1. The last important thing is the resistor value. If we place the DHT sensor at a less than 20-meter distance, a 5KΩ pull-up resistor should be needed. If you use more than 20 meters of distance the resistor value must be correct according to the distance.
Advantages of Weather Monitoring Device
- This project can be used in heating, cooling, ventilation and air conditioning system.
- It can also be used as medical equipment.
- In-home automation system this system is very useful.
Disadvantages of Weather Monitoring Device
- The uses of this weather monitoring device are limited.
- It may not work for big areas.
- There is no detection of sudden changes in the environment sometimes.
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #include "DHT.h" #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define DHT11Pin 2 #define DHTType DHT11 DHT HT(DHT11Pin,DHTType); float humidity; float tempC; float tempF; #define SCREEN_WIDTH 128 // define OLED display width in pixels #define SCREEN_HEIGHT 64 // define OLED display height in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { // For DHT11 HT.begin(); // For OLED Display I2C if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64 Serial.println(F("SSD1306 Allocation Failed")); for(;;); } display.display(); // Display Logo delay(1000); display.clearDisplay(); } void loop() { delay(1000); humidity = HT.readHumidity(); // Read Humidity tempC = HT.readTemperature(); // Read Temperature in C tempF = HT.readTemperature(true); // Read Temperature in F display.clearDisplay(); oledDisplayHeader(); oledDisplay(3,5,28,humidity,"%"); oledDisplay(2,70,16,tempC,"C"); oledDisplay(2,70,44,tempF,"F"); display.display(); } void oledDisplayHeader() { display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 0); display.print("Humidity"); // Display Humidity display.setCursor(60, 0); display.print("Temperature"); // Display Temperature } void oledDisplay(int size, int x,int y, float value, String unit) { int charLen=12; int xo=x+charLen*3.2; int xunit=x+charLen*3.6; int xval = x; display.setTextSize(size); // Set Text Size display.setTextColor(WHITE); // Set Text Color if (unit=="%"){ display.setCursor(x, y); display.print(value,0); display.print(unit); } else { if (value>99){ xval=x; } else { xval=x+charLen; } display.setCursor(xval, y); display.print(value,0); display.drawCircle(xo, y+2, 2, WHITE); // Print Degree Symbol display.setCursor(xunit, y); display.print(unit); } } |
Frequently Asked Questions
DHT11 sensor has 4 pins VCC, GND, NC, and DATA. You can connect VCC with 5V of Arduino. Data pin with any of the 12 pins of the Arduino. There is no need to connect the NC pin. GND pin should be connected to the ground. And for the DHT11 module, this process is the same as what I said above.
The temperature measuring range of the DHT11 module is 0-50°C with +-2 degrees.
Because it is less costly and easy to use. Also, it provides humidity and temperature in both measurement systems in it.
It is a capacitive humidity sensor.
DHT22 is better than DHT11 because it has a greater range of measuring temperature. But it is quite expensive.
Firstly open Arduino IDE and go to sketch. Then click on include library and then manage the library. Now search for DHT. From there you can install the DHT library from Adafruit. After installation, you can search for Adafruit unified sensor and add it.
Yes. You just need to connect Arduino with LCD pins with the I2C module or manually.
No. You can use DS18B20.
A hygroscopic dielectric material is placed in between two electrodes forming a capacitor.
Is it accurate always?