Thanks Felix. That worked like a dream. I had though of doing that and then strayed to the dark side of Tasmota and Berry UI! Which is a pity because the UI Flow web GUI is superb! Enjoy your day and thanks again! :) I guess a newbie error in that "run" mode makes use of the fact the boot firmware brings it online to use the Web GUI whereas when you "download" you must do everything yourself! Happy coding.
Posts made by kilnageer
RE: UI Flow MQTT code on M5Stack Core works when run from flow.m5stack.com but not (MQTTException -> 128) when downloaded to device
UI Flow MQTT code on M5Stack Core works when run from flow.m5stack.com but not (MQTTException -> 128) when downloaded to device
I used a Win 11 laptop for development and using M5Burner burned the v1.10.9 UI Flow firmware to M5 Core device and configure its WiFi to my local SSID.
I next connected to the device (which is successfully online in internet mode) to xxxxxxxx from https://flow.m5stack.com/
I then made a minimal MQTT connect and publish program to a public test MQTT broker and published a message.
from m5stack import *
from m5ui import *
from uiflow import *
from m5mqtt import M5mqtt
m5mqtt = M5mqtt('kilnageer', 'test.mosquitto.org', 1883, '', '', 300)
m5mqtt.publish(str('kilnageer/test'), str('hello'), 0)
I tested the public broker with the following code..
pi@tola-smarthome-v3:~ $ mosquitto_sub -h test.mosquitto.org -t kilnageer/test &
pi@tola-smarthome-v3:~ $ mosquitto_pub -h test.mosquitto.org -t kilnageer/test -m "hi"
pi@tola-smarthome-v3:~ $ hi
pi@tola-smarthome-v3:~ $ hello
pi@tola-smarthome-v3:~ $ date
Mon 28 Nov 09:50:57 GMT 2022
So seeing "hello" proves the running the code works..
Also running a web terminal to the device at this time showed no errors:
Next I downloaded the code (main.m5f) to the device and so changed it from "internet" mode to "app" mode.
Now I now longer see the message published and the terminal shows and MQTT error:
MicroPython 77320d1de-dirty on 2022-11-24; M5Stack with ESP32
Type "help()" for more information.
>>>  MQTTException -> 128
reconnect start ...
reconnect finish ...
Also when I was developing the real code and connecting to a local Pi based MQTT broker I could see that the connection was never made (in the failing case) by looking at the mosquitto logs.
pi@tola-smarthome-v3:~ $ sudo tail -f /var/log/mosquitto/mosquitto.log
1669623877: New connection from 192.168.3.15 on port 1883.
1669623877: New client connected from 192.168.3.15 as mqttdash-10aaf3d5 (c1, k30, u'tola').
1669624454: Socket error on client mqttdash-10aaf3d5, disconnecting.
But I could see the connecting being made by the M5Stack client when I just ran the code from the web console.