EasyManua.ls Logo

SunFounder TS-10 - Page 92

Default Icon
213 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder TS-10 10.1-inch Touch Screen
Code Explanation
dht11 = DHT11.DHT11(17)
Instantiate a dht11 object.
def getTem():
result = dht11.get_result()
while True:
if result:
break
else:
result = dht11.get_result()
return result[1]
The temperature (result[1]) is obtained by this function, and the function will not be interrupted until the reading
is successful.
def getHum():
result = dht11.get_result()
while True:
if result:
break
else:
result = dht11.get_result()
return result[0]
The humidity (result[0]) is obtained by this function, and the function will not be interrupted until the reading is
successful.
variables = {
'Room Temp': {
(continues on next page)
88 Chapter 5. PROJECTS AND ACTIVITIES

Related product manuals