repository to manage all files related to the makeathon farm bot project (Software + Documentation).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mqtt_publish1.py 516B

123456789101112131415161718
  1. import paho.mqtt.client as mqtt
  2. import random
  3. import time
  4. mqttBroker = "mqtt.eclipseprojects.io"
  5. client1 = mqtt.Client("Temperature")
  6. client1.connect(mqttBroker)
  7. while True:
  8. randNumber = random.randint(0, 20)
  9. client1.publish("TEMPERATURE", randNumber)
  10. print("Published " + str(randNumber) + " to topic TEMPERATURE")
  11. time.sleep(2)
  12. randNumber = random.randint(0, 100)
  13. client1.publish("HUMIDITY", randNumber)
  14. print("Published " + str(randNumber) + " to topic HUMIDITY")
  15. time.sleep(2)