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.

receive_json.py 467B

1234567891011121314151617181920
  1. import paho.mqtt.client as mqtt
  2. import json
  3. def on_message_json(client, userdata, message):
  4. strIn = str(message.payload.decode("UTF-8"))
  5. dataDict = json.loads(strIn)
  6. print("Received data: ", json.dumps(dataDict))
  7. mqttBroker = "mqtt.eclipseprojects.io"
  8. client = mqtt.Client("Smartphone_temp")
  9. dataDict = {}
  10. client.message_callback_add("Robot/Data", on_message_json)
  11. client.connect(mqttBroker)
  12. client.subscribe("Robot/Data")
  13. client.loop_forever()