import paho.mqtt.client as mqtt import random import time mqttBroker = "mqtt.eclipseprojects.io" client = mqtt.Client("Temperature") client.connect(mqttBroker) while True: randNumber = random.randint(0, 20) client.publish("TEMPERATURE", randNumber) print("Published " + str(randNumber) + " to topic TEMPERATURE") time.sleep(2)