Skip to content

Instantly share code, notes, and snippets.

@roboticboyer
Created May 29, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roboticboyer/61e4e09526fd89287d63122d3a23b756 to your computer and use it in GitHub Desktop.
Save roboticboyer/61e4e09526fd89287d63122d3a23b756 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import paho.mqtt.client as mqtt
import time
mqttc = mqtt.Client("python_pub")
#mqttc.connect("192.168.1.103", 1883)
mqttc.connect("192.168.4.1", 1883)
'''
Publish loop
'''
i=0
while i<30:
mqttc.publish("temperatura", i)
print(i)
mqttc.loop(2) #timeout = 2s
i=i+1
time.sleep(5) # delays for 5 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment