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_subscriber.py 500B

12345678910111213141516171819202122232425
  1. import paho.mqtt.client as mqtt
  2. import time
  3. from software.defines import Topics
  4. def on_message(client, userdata, message):
  5. print("received message: ", str(message.payload.decode("utf-8")))
  6. def on_connect(client, userdata, flags, rc):
  7. if rc == 0:
  8. print("Connected")
  9. else:
  10. print("Connection failed")
  11. mqttBroker = "192.168.178.182"
  12. client = mqtt.Client()
  13. client.connect(mqttBroker, 1883)
  14. client.on_message = on_message
  15. client.subscribe("TEST")
  16. client.loop_forever()