Basic example code
This commit is contained in:
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Adafruit-DHT==1.4.0
|
||||||
17
src/main.py
Normal file
17
src/main.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Adafruit_DHT
|
||||||
|
import time
|
||||||
|
|
||||||
|
DHT_SENSOR = Adafruit_DHT.DHT11
|
||||||
|
DHT_PIN = 4
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
|
||||||
|
if humidity is not None and temperature is not None:
|
||||||
|
print(f"Temperature: {temperature}C, Humidity: {humidity}%")
|
||||||
|
else:
|
||||||
|
print("Sensor failure")
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user