parent
6f89c8f73a
commit
d6c0cec463
8
main.py
8
main.py
|
@ -58,8 +58,8 @@ def get_water_level():
|
|||
|
||||
TimeElapsed = StopTime - startTime
|
||||
distance = (TimeElapsed * 34300) / 2
|
||||
|
||||
return int(distance)
|
||||
rounded_distance = int(distance)
|
||||
return str(rounded_distance)
|
||||
|
||||
#temperature
|
||||
def get_temperature():
|
||||
|
@ -71,13 +71,13 @@ def get_temperature():
|
|||
print(get_water_level())
|
||||
print(get_temperature())
|
||||
|
||||
def mqtt_on_connect(client):
|
||||
def mqtt_on_connect(client, userdata, flags, rc):
|
||||
client.subscribe("strawberry-pi-greenhouse/relay/channel/1")
|
||||
client.subscribe("strawberry-pi-greenhouse/relay/channel/2")
|
||||
client.subscribe("strawberry-pi-greenhouse/relay/channel/3")
|
||||
client.subscribe("strawberry-pi-greenhouse/relay/channel/4")
|
||||
|
||||
def mqtt_on_message(msg):
|
||||
def mqtt_on_message(client, userdata, msg):
|
||||
print("topic: " ,str(msg.topic))
|
||||
print("payload: " ,str(msg.payload.decode("utf-8")))
|
||||
topic = str(msg.topic)
|
||||
|
|
Loading…
Reference in New Issue