mqtt_10_publish.py

#! /usr/bin/python3
# ===================================================================
# MQTT Publish Demo
#
# publish two messages to two different topics
#
# From: https://www.youtube.com/watch?v=Pb3FLznsdwI
#       Raspberry Pi - Getting started with MQTT
# ===================================================================

import paho.mqtt.publish as publish

publish.single('CoreElectronics/test',  'Hello',  hostname='test.mosquitto.org')
publish.single('CoreElectronics/topic', 'World!', hostname='test.mosquitto.org')

print('Done')
print()