Last active
May 21, 2022 19:52
-
-
Save tolgahancepel/9e81cf90493994afd6c2114ac7d5a628 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import paho.mqtt.client as mqtt | |
| def on_connect(client, userdata, flags, rc): | |
| print("Connected with result code "+str(rc)) | |
| mqttc.subscribe("myroom/temperature") | |
| def on_message(client, userdata, msg): | |
| print("Received:", msg.payload.decode()) | |
| mqttc = mqtt.Client() | |
| mqttc.connect("mqtt.eclipseprojects.io", 1883, 60) | |
| mqttc.on_connect = on_connect | |
| mqttc.on_message = on_message | |
| mqttc.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment