Page 1 of 1

umqtt

Posted: Sun Jan 19, 2020 8:22 pm
by johnv
hi, i installed mosquitto to the raspberry pi,

and umqtt is up and running on the esp8266,

but frankly i have no idee how to publish sensor data, and i seem unable to find any documentation or somesort,

i can write text messages from pub to sub

mosquitto_pub -m ... -t ...
mosquitto_sub -t ...

but i want to learn to publish sensor data; (do i do this wit a print function or something),

help please; i'm kinda lost on this one,

cheers!

Re: umqtt

Posted: Mon Jan 20, 2020 9:24 am
by pythoncoder
MQTT sends and receives strings so you need to convert between your data and strings. Any online Python tutorial will explain how this is done. The following is an example of one approach:

Code: Select all

>>> my_sensor = 98.4
>>> message = '{:4.1f}'.format(my_sensor)
>>> print(message)
98.4
>>> 
>>> type(message)
<class 'str'>

Re: umqtt

Posted: Mon Jan 20, 2020 11:03 am
by johnv
Tnx mate!