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.

send_json.py 504B

1234567891011121314151617181920
  1. import paho.mqtt.client as mqtt
  2. import random
  3. import time
  4. import json
  5. mqttBroker = "mqtt.eclipseprojects.io"
  6. client1 = mqtt.Client("RobotData")
  7. client1.connect(mqttBroker)
  8. dataDict = {
  9. "Temperature" : 0,
  10. "Humidity" : 0
  11. }
  12. while True:
  13. dataDict["Temperature"] = random.randint(0, 20)
  14. dataDict["Humidity"] = random.randint(0, 100)
  15. client1.publish("Robot/Data", json.dumps(dataDict, indent= 4))
  16. print("Published " + json.dumps(dataDict) + " to topic Robot/Data")
  17. time.sleep(5)