From 1e4fb4c4b491b1e2c102f97050303008a548340c Mon Sep 17 00:00:00 2001 From: waldhauserlu78556 Date: Sun, 30 Apr 2023 12:12:11 +0200 Subject: [PATCH] Sensor Bug Fixes --- software/roboter/raspy/functions.py | 6 +++--- software/roboter/raspy/raspy_sensors.py | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/software/roboter/raspy/functions.py b/software/roboter/raspy/functions.py index ce8275d..177a5b4 100644 --- a/software/roboter/raspy/functions.py +++ b/software/roboter/raspy/functions.py @@ -2,7 +2,7 @@ import paho.mqtt.client as mqtt import json import threading import os -import raspy_sensors as RaspySensors +import raspy_sensors as Sensors from defines import Topics def measure_send_data(plantID, actionID, client: mqtt.Client): @@ -14,7 +14,7 @@ def measure_send_data(plantID, actionID, client: mqtt.Client): actionID (_type_): current ID of driving action client (mqtt.Client): current mqtt client for publishing """ - sensor = RaspySensors() + sensor = Sensors.RaspySensors() sensorData = sensor.readSensors() sensorData["PlantID"] = plantID sensorData["ActionID"] = actionID @@ -74,7 +74,7 @@ def drive_plant(clients: mqtt.Client, userdata, message: mqtt.MQTTMessage): plantID = dictMessage["PlantID"] actionID = dictMessage["ActionID"] - print(f"received drive to plant {plantID}") + print(f"Received Drive-request to plant {plantID}, ActionID: {actionID}") thread = threading.Thread(target= drive_plant_thread, args=(plantID, actionID, clients), daemon=True) thread.start() diff --git a/software/roboter/raspy/raspy_sensors.py b/software/roboter/raspy/raspy_sensors.py index 76103e7..7d7b1ac 100644 --- a/software/roboter/raspy/raspy_sensors.py +++ b/software/roboter/raspy/raspy_sensors.py @@ -12,7 +12,7 @@ class RaspySensors: _type_: _description_ """ - def __init__(self) -> None: + def __init__(self): """ Init all Sensors """ @@ -55,7 +55,10 @@ class RaspySensors: break #read TSL2561 - self.sensorData["Brightness"] = round(self.tsl2561.lux, 2) + if type(self.tsl2561.lux) == type(None): #Max Value 40.000 -> above error + self.sensorData["Brightness"] = 40000 + else: + self.sensorData["Brightness"] = int(self.tsl2561.lux) #TODO SoilMoisture Sensor