Post


DHT11 with Raspberry PI

To install the Adafruit DHT11 library:

1. Enter this at the command prompt to download the library:

git clone https://github.com/adafruit/Adafruit_Python_DHT.git

2. Change directories with:

cd Adafruit_Python_DHT

3. Now enter this:

sudo apt-get install build-essential python-dev

4. Then install the library with:

sudo python setup.py install

OUTPUT TO AN SSH TERMINAL

 

This Python program will output the temperature and humidity readings to an SSH terminal

 

 

 Example Code:

 

#!/usr/bin/python
import sys
import Adafruit_DHT

while True:

humidity, temperature = Adafruit_DHT.read_retry(11, 4) #DHT11, GPIO4

print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity)

 

Download ready example, you must run this from Adafruit_Python_DHT/examples

Download

 

 

 

 
 

 

Posted in Workshop 04 Oct 2019