Connect Raspberry Pi to DHT11 Temp Humidity Sensor

We’ll be working with this existing project code.

https://github.com/adafruit/Raspberry_Pi_SQLite_Sensors

Video overview long version:

Project instructions long version – 

https://github.com/adafruit/Raspberry_Pi_SQLite_Sensors

Hooking up the DHt 11 sensor to the Raspberry Pi visual –

https://www.techcoil.com/blog/how-to-read-temperature-and-humidity-from-a-dht11-sensor-that-is-connected-to-a-raspberry-pi-3/

Be sure to watch the YouTube videos and run through all 4 parts!

Get to the Terminal.  CTRL-T if you are on the desktop version will bring up the terminal

cd /
cd opt
sudo git clone https://github.com/adafruit/Raspberry_Pi_SQLite_Sensors.git

cd /
cd opt/Raspberry_Pi_SQLite_Sensors
cd Part_3

FLASK_APP=webapp.py flask run –host=0.0.0.0

cd Raspberry_Pi_SQLite_Sensors
cd Part_3
sudo sqlite3 dht.db

CREATE TABLE readings (time DATETIME, name TEXT, value REAL);
CREATE TABLE sensors (name TEXT, type TEXT, pin INTEGER);

INSERT INTO sensors VALUES (‘DHT1’, ‘DHT11’, 4);

CTRL-Z to exit the SQL prompt. Edit dht_read and update to DHT11. Then run the file.

Download the app code –
Let the above report on the Temp/Humidity and write to the database. Open a new Putty/Terminal window
Lets go to the Lesson 3 folder –
Open a brown a navigate to http://IpAddress:5000

sudo apt-get install git
sudo apt-get update
sudo apt-get install -y python3 python3-dev python3-pip git sqlite3
cd /
cd opt
sudo git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo python3 setup.py install
sudo pip3 install flask flask-admin wtf-peewee

sudo nano dht_read.py

FIND:
data.define_sensor(‘DHT1’, Adafruit_DHT.DHT22, 18)
data.define_sensor(‘DHT2’, Adafruit_DHT.DHT22, 25)

UPDATE TO:

data.define_sensor(‘DHT1’, Adafruit_DHT.DHT11, 4)

sudo python3 dht_read.py