Added Lab 10
This commit is contained in:
parent
5f40f4c866
commit
b0d1253215
18 changed files with 885 additions and 0 deletions
22
Lab10/MicroPython/Code/ReadDht11.py
Normal file
22
Lab10/MicroPython/Code/ReadDht11.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import machine
|
||||
import utime
|
||||
import dht
|
||||
|
||||
# Set up the DHT11 sensor on GPIO 14
|
||||
sensor = dht.DHT11(machine.Pin(14))
|
||||
|
||||
while True:
|
||||
try:
|
||||
sensor.measure()
|
||||
temp = sensor.temperature()
|
||||
hum = sensor.humidity()
|
||||
|
||||
print("Temperature: {}°C".format(temp))
|
||||
print("Humidity: {}%".format(hum))
|
||||
print("------------------------")
|
||||
|
||||
except OSError as e:
|
||||
print("Sensor error:", e)
|
||||
|
||||
# Wait 60 seconds
|
||||
utime.sleep(60)
|
||||
Loading…
Add table
Add a link
Reference in a new issue