diff --git a/sensors/ky015_data.json b/sensors/json/ky015_data.json similarity index 100% rename from sensors/ky015_data.json rename to sensors/json/ky015_data.json diff --git a/sensors/ky018_data.json b/sensors/json/ky018_data.json similarity index 100% rename from sensors/ky018_data.json rename to sensors/json/ky018_data.json diff --git a/sensors/ky037_data.json b/sensors/json/ky037_data.json similarity index 100% rename from sensors/ky037_data.json rename to sensors/json/ky037_data.json diff --git a/sensors/lichtwiderstandsSensor.py b/sensors/lichtwiderstandsSensor.py index 876b2dc..bcaea6a 100644 --- a/sensors/lichtwiderstandsSensor.py +++ b/sensors/lichtwiderstandsSensor.py @@ -13,7 +13,7 @@ light_pin.direction = digitalio.Direction.INPUT data_template = { "id": "sensor_004", "type": "light", - "unit": "state", + "unit": "bool", "reading": [] } @@ -32,10 +32,7 @@ def capture_and_store(state): timestamp = int(time.time()) data = load_data() - data["reading"].append({ - "ts": timestamp, - "state": state - }) + data["reading"].append({"ts": timestamp,"value": state}) if len(data["reading"]) > MAX_ENTRIES: data["reading"] = data["reading"][-MAX_ENTRIES:] @@ -45,13 +42,13 @@ def capture_and_store(state): try: while True: if light_pin.value: - light_state = "hell" + light_state = True else: - light_state = "dunkel" + light_state = False print(f"Lichtzustand: {light_state}") capture_and_store(light_state) time.sleep(2) except KeyboardInterrupt: - print("Programm beendet.") \ No newline at end of file + print("Programm beendet.") diff --git a/sensors/mikrofonSensor.py b/sensors/mikrofonSensor.py index 81f2be9..bddda80 100644 --- a/sensors/mikrofonSensor.py +++ b/sensors/mikrofonSensor.py @@ -33,12 +33,9 @@ def save_data(data): def capture_and_store(): state = GPIO.input(SENSOR_PIN) timestamp = int(time.time()) # Unix-Zeitstempel (int) - noise = 1 if state == 0 else 0 + noise = True if state == 0 else False - entry = { - "ts": timestamp, - "value": noise - } + entry = { "ts": timestamp, "value": noise} data = load_data() data["readings"].append(entry) @@ -56,4 +53,4 @@ if __name__ == "__main__": except KeyboardInterrupt: print("Stopped by user.") finally: - GPIO.cleanup() \ No newline at end of file + GPIO.cleanup() diff --git a/sensors/temperaturSensor.py b/sensors/temperaturSensor.py index dd41f15..7ff2017 100644 --- a/sensors/temperaturSensor.py +++ b/sensors/temperaturSensor.py @@ -7,7 +7,7 @@ import os dhtDevice = adafruit_dht.DHT11(board.D23) -json_file = "ky015_data.json" +json_file = "json/ky015_data.json" datatemphum = { "id": "sensor_002/3",