This commit is contained in:
2026-07-13 15:46:44 +02:00
commit 1df9d878ca
1729 changed files with 326867 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""Small MicroPython MQTT example for ESP32.
Edit BROKER_HOST so it points to the broker machine IP address.
Do not use localhost from the ESP32.
"""
from shared.mqtt import BrokerClient
BROKER_HOST = "192.168.50.1"
TOPIC = b"smartwave/demo"
CA_FILE = "/certs/ca.crt"
def on_message(message):
print("received:", message)
def main():
client = BrokerClient(
host=BROKER_HOST,
client_id="smartwave-esp32-demo",
use_tls=True,
cafile=CA_FILE,
keepalive=30,
)
client.set_callback(on_message)
client.connect()
client.subscribe(TOPIC, qos=2)
client.publish(TOPIC, b"hello from MicroPython", qos=2, retain=False)
for _ in range(30):
client.poll()
client.close()
main()