removed some ai garbage, moved json output to new json folder.

!!! temperaturSensor.py is incompatible with the webserver !!!
!!! fix asap !!!
This commit is contained in:
mia 2025-06-15 23:13:08 +02:00
parent 3226ed29ec
commit 9bf8f089b6
6 changed files with 9 additions and 15 deletions

View file

@ -13,7 +13,7 @@ light_pin.direction = digitalio.Direction.INPUT
data_template = { data_template = {
"id": "sensor_004", "id": "sensor_004",
"type": "light", "type": "light",
"unit": "state", "unit": "bool",
"reading": [] "reading": []
} }
@ -32,10 +32,7 @@ def capture_and_store(state):
timestamp = int(time.time()) timestamp = int(time.time())
data = load_data() data = load_data()
data["reading"].append({ data["reading"].append({"ts": timestamp,"value": state})
"ts": timestamp,
"state": state
})
if len(data["reading"]) > MAX_ENTRIES: if len(data["reading"]) > MAX_ENTRIES:
data["reading"] = data["reading"][-MAX_ENTRIES:] data["reading"] = data["reading"][-MAX_ENTRIES:]
@ -45,9 +42,9 @@ def capture_and_store(state):
try: try:
while True: while True:
if light_pin.value: if light_pin.value:
light_state = "hell" light_state = True
else: else:
light_state = "dunkel" light_state = False
print(f"Lichtzustand: {light_state}") print(f"Lichtzustand: {light_state}")
capture_and_store(light_state) capture_and_store(light_state)

View file

@ -33,12 +33,9 @@ def save_data(data):
def capture_and_store(): def capture_and_store():
state = GPIO.input(SENSOR_PIN) state = GPIO.input(SENSOR_PIN)
timestamp = int(time.time()) # Unix-Zeitstempel (int) timestamp = int(time.time()) # Unix-Zeitstempel (int)
noise = 1 if state == 0 else 0 noise = True if state == 0 else False
entry = { entry = { "ts": timestamp, "value": noise}
"ts": timestamp,
"value": noise
}
data = load_data() data = load_data()
data["readings"].append(entry) data["readings"].append(entry)

View file

@ -7,7 +7,7 @@ import os
dhtDevice = adafruit_dht.DHT11(board.D23) dhtDevice = adafruit_dht.DHT11(board.D23)
json_file = "ky015_data.json" json_file = "json/ky015_data.json"
datatemphum = { datatemphum = {
"id": "sensor_002/3", "id": "sensor_002/3",