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:
parent
3226ed29ec
commit
9bf8f089b6
6 changed files with 9 additions and 15 deletions
|
@ -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.")
|
||||
print("Programm beendet.")
|
||||
|
|
|
@ -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()
|
||||
GPIO.cleanup()
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue