Skip to content

Instantly share code, notes, and snippets.

@badri
Created December 29, 2022 10:21
Show Gist options
  • Save badri/9e4af14f46ec45275c533f7542ffb9af to your computer and use it in GitHub Desktop.
Save badri/9e4af14f46ec45275c533f7542ffb9af to your computer and use it in GitHub Desktop.
import paho.mqtt.client as mqtt
from random import randrange, uniform
import time
mqttBroker ="vernemq.itransz.in"
client = mqtt.Client("Temperature_Inside")
client.connect(mqttBroker, 443)
while True:
randNumber = uniform(20.0, 21.0)
client.publish("H1", randNumber)
print("Just published " + str(randNumber) + " to topic H1")
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment