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!
umqtt
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: umqtt
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'>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.