diff --git a/device_info.py b/device_info.py index 77ea2d1..65ab51a 100644 --- a/device_info.py +++ b/device_info.py @@ -17,14 +17,22 @@ class DeviceInfo: { 'type': 'moisture', 'pin_int': 26 - }, + }, { - 'type': 'dht22', - 'pin_int': 15 - } + 'type': 'ambilight', + 'pin_int': 8, # for compatibility only + 'pin_int_sda': 8, + 'pin_int_scl': 9 + }, + + + # { + # 'type': 'dht22', + # 'pin_int': 15 + # } ] - read_secs = 60 + read_secs = 5 # Device Infos End wlan = network.WLAN(network.STA_IF) diff --git a/grow_system.py b/grow_system.py index aeaf915..3528ea9 100644 --- a/grow_system.py +++ b/grow_system.py @@ -1,6 +1,7 @@ import time from moisture_sensor import MoistureSensor from dht22 import TemperatureHumiditySensor +from ambilight_sensor import AmbilightSensor from sensor_data_manager import SensorDataManager from grow_system_api import GrowSystemApi from device_info import DeviceInfo @@ -35,6 +36,9 @@ class GrowSystem: elif sensor_type == 'dht22': print("Found sensor of type DHT22") self.sensors.append(TemperatureHumiditySensor(sensor)) + elif sensor_type == 'ambilight': + print("Found sensor of type GY302/BH1750") + self.sensors.append(AmbilightSensor(sensor)) else: print("No sensor type configured for: " + sensor['type']) diff --git a/sensors.py b/sensors.py index 04beaaa..23ad803 100644 --- a/sensors.py +++ b/sensors.py @@ -2,9 +2,12 @@ class Sensors: # this is a parent class for the Sensor classes sensor_pin_int = -1 + sensor = None + type = "unset" def __init__(self, settings): self.type = settings['type'] + print("Initialize " + self.type + " sensor. Sensor pin is: " + str(settings['pin_int'])) \ No newline at end of file