Explication de la routine 14-mqtt_pub version mqtt
import time
import network
from mqtt import MQTTClient
SSID = ""
KEY = ""
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(SSID, KEY)
while not wlan.isconnected():
print('Trying to connect to "{:s}"...'.format(SSID))
time.sleep_ms(1000)
print("WiFi Connected ", wlan.ifconfig())
client = MQTTClient("openmv", "test.mosquitto.org", port=1883)
client.connect()
while True:
client.publish("openmv/test", "Hello World!")
time.sleep_ms(1000)