The DHT11 is a commonly used Temperature and humidity sensor that comes with a dedicated NTC to measure temperature and an 8-bit microco...
The DHT11 is a commonly used Temperature and humidity sensor that comes with a dedicated NTC to measure temperature and an 8-bit microcontroller to output the values of temperature and humidity as serial data.
DHT11 Pinout Configuration
No: | Pin Name | Description |
For DHT11 Sensor | ||
1 | Vcc | Power supply 3.5V to 5.5V |
2 | Data | Outputs both Temperature and Humidity through serial Data |
3 | NC | No Connection and hence not used |
4 | Ground | Connected to the ground of the circuit |
For DHT11 Sensor module | ||
1 | Vcc | Power supply 3.5V to 5.5V |
2 | Data | Outputs both Temperature and Humidity through serial Data |
3 | Ground | Connected to the ground of the circuit |
DHT11 Specifications
- Operating Voltage: 3.5V to 5.5V
- Operating current: 0.3mA (measuring) 60uA (standby)
- Output: Serial data
- Temperature Range: 0°C to 50°C
- Humidity Range: 20% to 90%
- Resolution: Temperature and Humidity both are 16-bit
- Accuracy: ±1°C and ±1
To be able to easily communicate with some sensors, CircuitPython has been developed .So, before installing the specific DHT-library, we have to do dome work:
Open a terminal window and write followinf commands:
sudo apt update
sudo pat full-upgrade
sudo apt install python3-pip
sudo pip3 install --upgrade setuptools
it will take 10 min in raspberry pi 3B
Then install and run a script developed by Adafruit:
sudo pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
sudo python3 raspi-blinka.py
Install the CircuitPython-DHT Library
Open a terminal window and write following commands
pip3 install adafruit-circuitpython-dht
sudo apt-get install libgpiod2
To enable dht11.py script run automatic copy temperature.service file inside /etc/systemd/system of raspberry pi
Enjoy!!
Output will be on log file inside /var/log of raspberry pi
All python code , service file and bash code are available on my github
https://github.com/sushildurlov/DHT11-with-raspberry-pi
https://github.com/sushildurlov/DHT11-with-raspberry-pi
COMMENTS