Como usar um sensor DHT para mostrar valores de umidade e temperatura em um display OLED

How to use a DHT sensor to show humidity and temperature values ​​on an OLED display

In Part I and Part II of this series, we learned how to use an analog sensor – including a potentiometer (POT), a light dependent resistor (LDR), and a soil moisture sensor – to present values ​​in organic light. emitting diode (OLED) display.

In Part III, we will also present the data on an OLED display, but this time using a digital temperature and humidity sensor, the DHT11.

See Part I for a discussion of the basics of an OLED display and how to properly interface it with the Arduino.

DHT11
The DHT11 is a low-cost digital sensor that detects temperature and humidity. Humidity is a measure of the water vapor present in the air.

There are two types of humidity sensors, based on their units of measurement:

  • An absolute humidity sensor – a measurement of water vapor in the air, regardless of temperature, expressed in grams of humidity per cubic meter of air.
  • A relative humidity sensor – the measurement of water vapor in the air in relation to temperature, expressed as the amount of water vapor in the air as a percentage of the total amount that can be held at its current temperature.

The DHT11 measures the relative humidity of the environment. To measure temperature, this sensor uses a thermistor. It also has a built-in chip (IC) that provides analog-to-digital conversion and digital signal output such as temperature and humidity.

Working principle of DHT11
Together with the thermistor, the The DHT11 sensor has a capacitive humidity sensing element. This capacitor has two electrodes with a moisture-retaining substrate that serves as a dielectric, which is an electrical insulator, between the two.

A change in capacitance value occurs when there is a change in humidity levels. The built-in chip measures the change in the capacitor and converts it into a digital relative humidity value.

To measure temperature, the The DHT11 uses a thermistor with a negative temperature coefficient, which causes a decrease in the resistance value when there is an increase in temperature. Typically, the sensor is made of semiconductor ceramic or polymer to ensure a higher resistance value even when there is a slight change in temperature.

The built-in chip measures this change in resistance and converts it into a digital value in Celsius.

Specifications

  1. Voltage Ratings: 3 – 5V
  2. I/O voltage range: 3 – 5 V
  3. Current ratings: 2.5 mA (maximum current usage during conversion – during data request)
  4. Humidity range: 20-80% (5% accuracy)
  5. Temperature range: 0-50°C (accuracy ±2°C)
  6. Sampling rate: 1 Hz maximum (output readings are updated every second)
  7. Dimension: 15.5 x 12 x 5.5 mm

Pinouts and functions

For this project, we used the DHT11 module, which can be connected easily and directly to the Arduino. This sensor has a 10K pull-up resistor, which connects between the VCC and the data output pins. It only has three pins instead of the typical four. It also has a power-on LED indicator.

Circuit Diagram

Circuit Connections
The circuit is built using just three components:

1. The Arduino NANO board
2. An OLED display
3. The DHT11 module

  • The DHT11 module has three pins: the +V pin, GND and the signal (op) pin. The +V and GND pins are connected to the +5 V and GND pins of the Arduino. The signal pin is connected to digital pin 13 of the Arduino.
  • The OLED has four interface pins (as discussed in Part 1): VCC, GND, SDA, and SCL. The VCC and GND pins are connected to the +5 V and GND pins on the Arduino, providing power to the display. The SDA and SCL pins are connected to the Arduino pins A4 (SDA) and A5 (SCL) for data communication.
  • The Arduino receives its power supply from a computer's USB port. The integrated voltage regulator chip provides a 5V supply to the DHT11 module and OLED display.

Circuit operation

  • The DHT11 module detects ambient temperature and humidity, providing direct values ​​of temperature in ºC and humidity in % RH.
  • These values ​​are read by Arduino, which used the DHT.h library to read temperature and humidity.
  • The Arduino then displays the temperature and humidity values ​​on the OLED display

Software program
The Arduino board microcontroller (ATMega328) performs these tasks due to the program below:

1. Reads temperature and humidity values ​​from the DHT11 sensor.
2. Displays temperature and humidity values ​​on the OLED display.

This program was written in C/C++ language using Arduino IDE software. It is also compiled and loaded into the Arduino microcontroller using the same software.

The program…

Video

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.