May 2019
Intermediate to advanced
542 pages
13h 37m
English
To begin our sensor interface software, first, create another copy of your Qt application template and call it temp_humid_display.py.
The first thing we'll do is import the necessary libraries, as follows:
import Adafruit_DHTfrom RPi import GPIO
Adafruit_DHT will encapsulate all of the complicated bits required to talk to the DHT unit so that we only need to work with high-level functions to control and read data from the device.
Underneath the imports, let's set up a global constant:
SENSOR_MODEL = 11GPIO.setmode(GPIO.BCM)
We're setting up a global constant indicating which model of DHT we're working with; if you have the DHT 22, then set this value to 22. We're also setting up the Pi's pin mode. But this time, ...
Read now
Unlock full access