Created
May 29, 2019 15:06
-
-
Save tofl/71bddade0b8394e9c39edd0b2add0b66 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import threading | |
import random | |
host = "192.168.99.100" | |
port = 1883 | |
# Connexion | |
client = mqtt.Client("TomFlitterman") | |
client.connect(host, port) | |
# Publier des messages : | |
def setInterval(func,time): | |
e = threading.Event() | |
while not e.wait(time): | |
func() | |
def envoyerMessage(): | |
randInt = random.randint(1, 50) | |
client.publish("test", randInt, 0, False) | |
setInterval(envoyerMessage, 2) | |
#client.publish(topic="test", payload="Hello world", qos=0, retain=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment