Skip to content Skip to sidebar Skip to footer

Publishing Mqtt Messages From A Python Script On A Raspberry Pi

I am trying to configure a Raspberry Pi (Raspbian, Jessie) to send temperature data from a DS18B20 sensor to my MQTT broker. I have installed mosquitto, mosquitto-clients, and pyth

Solution 1:

As mentioned in the comment, the code you posted does work, but for publishing a single message this form is better

#!/usr/bin/env python
import paho.mqtt.publish as publish

publish.single("test/test", "Hello world!", hostname="192.168.0.21")

Post a Comment for "Publishing Mqtt Messages From A Python Script On A Raspberry Pi"