DHT11?Learn Temperature Humidity With DHT11 With Micropython
by irinak1 in Circuits > Raspberry Pi
401 Views, 2 Favorites, 0 Comments
DHT11?Learn Temperature Humidity With DHT11 With Micropython
Hi~ I'm irina but My nickname is "Y"
When we think of temperature/humidity sensors in IoT, DHT-11 comes to mind the most. So today, I would like to introduce the working principle of DHT11 to the source code.
Supplies
DHT11 x 1
W5100S-EVB-Pico x 1
What Is DHT11?
If you look for it, surprisingly, it is a temperature/humidity sensor that is often used when you want to check the temperature and humidity of products specialized for IoT such as Arduino or Raspberry Pi.
humidity : 20~95%
temperature: 0~50ºC
As explained in the figure, the pins are in order from left to right.
VCC,Signal, NC, GND
NC is an unused pin, so only 3 pins are actually used.
When using the above product, a normal value is output only when a resistor (5K) is connected between VCC and Signal.
If there is no resistor, you can also use a module.
Since the module already has a resistor connected to the signal, the wiring is simple and easy to use.
Operation Principle
When I first dealt with it, I didn't even know how it works and didn't write it.
As I write it, I wonder what kind of principle it is,
There are two types of electrical humidity measurement methods: capacitance sensing type nd resistance sensing type, but the capacitive sensing type sensor has high precision but is expensive.
So DHT11 uses resistance sensing type.
The two electrodes are not connected to each other, but a small amount of current flows due to the moisture in the air. So, when there is more moisture in the air, more current flows, so the resulting resistance value is measured as humidity.
In the temperature measurement of DHT11, the resistance value of the material changes according to the temperature, and a temperature sensor called thermistor is included in the DHT11 and is used together with the humidity sensor!
Source Code
Next, This code is micropython of DHT11.
Depending on the version of micropython, the corresponding code may be built-in.
If there is no error when "import DHT" enter to the code that is actually executed, you do not need to use the DHT code below.
Example Code
There is no need for the "pin clear" part, but depending on the board, there is a part where the pin is working, so I put it in.
I made it so that the temperature and humidity were well expressed, and I made it print out once every 2 seconds.
The output is as below...
I am using a tool called Thonny to easily compile and use MicroPython!!