Update to use new data from feather m0 express (UART->MQTT)
This commit is contained in:
parent
b7205f397f
commit
be8d28a2f9
@ -15,7 +15,7 @@ mqtt_client_id = cameteo
|
|||||||
mqtt_user = arofarn
|
mqtt_user = arofarn
|
||||||
mqtt_pass = WaKaW9XMGUZ3rRJD
|
mqtt_pass = WaKaW9XMGUZ3rRJD
|
||||||
mqtt_qos = 2
|
mqtt_qos = 2
|
||||||
mqtt_topic = huzzah0/#
|
mqtt_topic = feather0/#
|
||||||
|
|
||||||
[FLASK]
|
[FLASK]
|
||||||
http_host = 0.0.0.0
|
http_host = 0.0.0.0
|
||||||
|
@ -61,11 +61,11 @@ def on_message(client, userdata, msg):
|
|||||||
top=msg.topic[len(mqtt_topic)-1:].strip()
|
top=msg.topic[len(mqtt_topic)-1:].strip()
|
||||||
subtopics = top.split("/")
|
subtopics = top.split("/")
|
||||||
|
|
||||||
if subtopics[0] == "AdaBME280_1":
|
if subtopics[0] == "BME":
|
||||||
payload = msg.payload.decode()
|
payload = msg.payload.decode()
|
||||||
print(payload)
|
|
||||||
val = json.loads(payload)
|
val = json.loads(payload)
|
||||||
|
|
||||||
|
|
||||||
#Test présence et cohérence de la valeur
|
#Test présence et cohérence de la valeur
|
||||||
try:
|
try:
|
||||||
val['value'] = float(val['value'] )
|
val['value'] = float(val['value'] )
|
||||||
@ -79,14 +79,20 @@ def on_message(client, userdata, msg):
|
|||||||
#Affichage des données
|
#Affichage des données
|
||||||
coord_type = { 'AT' : (12, 50),
|
coord_type = { 'AT' : (12, 50),
|
||||||
'RH' : (137, 50),
|
'RH' : (137, 50),
|
||||||
'MSLP' : (12, 72),
|
'AP' : (12, 72),
|
||||||
'ALTI' : (137, 72),
|
'ALTI' : (137, 72),
|
||||||
}
|
}
|
||||||
|
print(val)
|
||||||
if val['type'] in coord_type:
|
if val['type'] in coord_type:
|
||||||
#erase former text
|
#erase former text
|
||||||
draw.rectangle(coord_type[val['type']] + (coord_type[val['type']][0] + 112, coord_type[val['type']][1] + 20), fill=white)
|
draw.rectangle(coord_type[val['type']] + (coord_type[val['type']][0] + 112,
|
||||||
|
coord_type[val['type']][1] + 20),
|
||||||
|
fill=white)
|
||||||
#draw new values
|
#draw new values
|
||||||
draw.text(coord_type[val['type']], "{:6.1f}{} ".format(val['value'], val['unit']), font=font20_bold, fill=black)
|
draw.text(coord_type[val['type']],
|
||||||
|
"{:6.1f}{} ".format(val['value'], val['unit']),
|
||||||
|
font=font20_bold,
|
||||||
|
fill=black)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Callback managing date and time from MQTT broker
|
Callback managing date and time from MQTT broker
|
||||||
@ -195,4 +201,3 @@ print(mqtt_host + ":" + str(mqtt_port))
|
|||||||
mqtt_client.connect(mqtt_host, int(mqtt_port), 60)
|
mqtt_client.connect(mqtt_host, int(mqtt_port), 60)
|
||||||
|
|
||||||
mqtt_client.loop_forever()
|
mqtt_client.loop_forever()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user