|
|
@@ -1,5 +1,6 @@ |
|
|
|
#from picamera import PiCamera |
|
|
|
import adafruit_dht |
|
|
|
import adafruit_tsl2561 |
|
|
|
import board |
|
|
|
import json |
|
|
|
|
|
|
@@ -8,15 +9,20 @@ class RaspySensors: |
|
|
|
def __init__(self) -> None: |
|
|
|
'''Init all Sensors''' |
|
|
|
#Message if Error |
|
|
|
|
|
|
|
|
|
|
|
#Air Temperature & Humidity |
|
|
|
self.dht22 = adafruit_dht.DHT22(board.D4, use_pulseio=False) |
|
|
|
|
|
|
|
#Brightness |
|
|
|
self.tsl2561 = adafruit_tsl2561.TSL2561(board.I2C()) |
|
|
|
|
|
|
|
#global Variables |
|
|
|
self.sensorData ={ |
|
|
|
"Air Temperature" : 0, |
|
|
|
"Air Humidity" : 0, |
|
|
|
"Earth Humidity" : 0, |
|
|
|
"Brightness" : 0 |
|
|
|
"Air Temperature [°C]" : 0, |
|
|
|
"Air Humidity [%]" : 0, |
|
|
|
"Earth Humidity [%]" : 0, |
|
|
|
"Brightness [Lux]" : 0 |
|
|
|
} |
|
|
|
|
|
|
|
def readSensors(self): |
|
|
@@ -26,13 +32,16 @@ class RaspySensors: |
|
|
|
#if Error reading Data try again |
|
|
|
while True: |
|
|
|
try: |
|
|
|
self.sensorData["Air Temperature"] = self.dht22.temperature |
|
|
|
self.sensorData["Air Humidity"] = self.dht22.humidity |
|
|
|
self.sensorData["Air Temperature [°C]"] = self.dht22.temperature |
|
|
|
self.sensorData["Air Humidity [%]"] = self.dht22.humidity |
|
|
|
except: |
|
|
|
continue |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
#read TSL2561 |
|
|
|
self.sensorData["Brightness [Lux]"] = round(self.tsl2561.lux, 2) |
|
|
|
|
|
|
|
return self.sensorData |
|
|
|
|
|
|
|
def takePicture(self): |