import paho.mqtt.client as mqtt import json from raspySensors import RaspySensors #region global Varaibles sensors = RaspySensors() #endregion #region MQTT callbacks def send_data_json(client, userdata, message): strIn = str(message.payload.decode("UTF-8")) dataDict = json.loads(strIn) print("Received data: ", json.dumps(dataDict)) def drive_plant_1(clients, userdata, message): print("Driving to plant 1") #endregion mqttBroker = "mqtt.eclipseprojects.io" client = mqtt.Client("Smartphone_temp") dataDict = {} client.message_callback_add("Robot/Data", send_data_json) client.message_callback_add("Robot/Plant/1", drive_plant_1) client.connect(mqttBroker) client.subscribe("Robot/Data") client.subscribe("Robot/Plant/1") client.loop_forever()