Browse Source

Sensor Bug Fixes

master
Luis Waldhauser 1 year ago
parent
commit
1e4fb4c4b4
2 changed files with 8 additions and 5 deletions
  1. 3
    3
      software/roboter/raspy/functions.py
  2. 5
    2
      software/roboter/raspy/raspy_sensors.py

+ 3
- 3
software/roboter/raspy/functions.py View File

import json import json
import threading import threading
import os import os
import raspy_sensors as RaspySensors
import raspy_sensors as Sensors
from defines import Topics from defines import Topics


def measure_send_data(plantID, actionID, client: mqtt.Client): def measure_send_data(plantID, actionID, client: mqtt.Client):
actionID (_type_): current ID of driving action actionID (_type_): current ID of driving action
client (mqtt.Client): current mqtt client for publishing client (mqtt.Client): current mqtt client for publishing
""" """
sensor = RaspySensors()
sensor = Sensors.RaspySensors()
sensorData = sensor.readSensors() sensorData = sensor.readSensors()
sensorData["PlantID"] = plantID sensorData["PlantID"] = plantID
sensorData["ActionID"] = actionID sensorData["ActionID"] = actionID
plantID = dictMessage["PlantID"] plantID = dictMessage["PlantID"]
actionID = dictMessage["ActionID"] 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 = threading.Thread(target= drive_plant_thread, args=(plantID, actionID, clients), daemon=True)
thread.start() thread.start()

+ 5
- 2
software/roboter/raspy/raspy_sensors.py View File

_type_: _description_ _type_: _description_
""" """


def __init__(self) -> None:
def __init__(self):
""" """
Init all Sensors Init all Sensors
""" """
break break


#read TSL2561 #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 #TODO SoilMoisture Sensor



Loading…
Cancel
Save