UiFlow 2.0 AirQ support, Custom Code will not work...
-
Hi, New to M5Stack here, I am trying to wrap my head around the way things work with ESP32 devices and get some data flowing to a mosquitto MQTT broker, I have tried to get the MQTT publish to work via UIFlow 2.0 but so far absolutely no luck get anything at all to work on the device, The Demo works fine, Lets me connect WiFi then exposes the sensor data via its pre-configured web-page view, This all works without any issue, As soon as i flash it with a UIFlow custom config all i get from the monitor is:
_ ()/ | | _____ __
| | | | | || |/ _ \ \ /\ / /
| || | | | | () \ V V /
_,||| ||___/ _/_/[INFO] Syncing resources...
[WARN] WiFi not connected.
[WARN] quit sync.
MicroPython v1.24.0-dirty on 2024-11-21; M5STACK AirQ with ESP32-S3-FN8
Type "help()" for more information.I have tried even basic setups to just get a label to appear on the screen but all i get is this.
Here is the code for my blocks:
import os, sys, io
import M5
from M5 import *
import time
import network
from umqtt import *
from hardware import *wifiStatus = None
mqttStatus = None
rssiStatus = None
ipAddress = None
wlan = None
mqtt_client = None
scd40 = Nonedef setup():
global wifiStatus, mqttStatus, rssiStatus, ipAddress, wlan, mqtt_client, scd40M5.begin()
wifiStatus = Widgets.Label("wifiStatus", 4, 5, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)
mqttStatus = Widgets.Label("mqttStatus", 3, 109, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)
rssiStatus = Widgets.Label("rssiStatus", 5, 25, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)
ipAddress = Widgets.Label("ipAddress", 5, 47, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)time.sleep(5)
wifiStatus.setVisible(True)
mqttStatus.setVisible(True)
rssiStatus.setVisible(True)
ipAddress.setVisible(True)
scd40 = SCD40()
wlan = network.WLAN(network.STA_IF)
while not (wlan.isconnected()):
wlan.active(False)
wlan.active(True)
wlan.config(reconnects=5)
wlan.config(dhcp_hostname='m5stackAirQ')
wlan.connect('SPARK-S7K39H', '<MyPassword>')
time.sleep(3)
wifiStatus.setText(str('WiFi Connected..'))
mqtt_client = MQTTClient('AirQ-Test', '192.168.1.83', port=1883, user='admin', password='<MyPassword>', keepalive=5334)
mqtt_client.connect(clean_session=True)
mqttStatus.setText(str('MQTT Connected..'))
mqtt_client.publish('signal-test/temperature', 'Hello World From Setup Complete!!', qos=0)def loop():
global wifiStatus, mqttStatus, rssiStatus, ipAddress, wlan, mqtt_client, scd40
M5.update()
if wlan.isconnected():
wifiStatus.setColor(0x33ff33, 0x000000)
rssiStatus.setColor(0x33ff33, 0x000000)
ipAddress.setColor(0x33ff33, 0x000000)
rssiStatus.setText(str(wlan.status('rssi')))
ipAddress.setText(str(wlan.ifconfig()[0]))
else:
wifiStatus.setColor(0xff0000, 0x000000)
rssiStatus.setColor(0xff0000, 0x000000)
rssiStatus.setText(str('--'))
wlan.active(False)
wlan.active(True)
wlan.config(reconnects=5)
wlan.config(dhcp_hostname='m5stackAirQ')
wlan.connect('SPARK-S7K39H', '<MyPassword>')
mqtt_client.publish('/test/temp', str((scd40.temperature)), qos=0)
time.sleep(5)if name == 'main':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")All I am trying to do here is make sure the device attempts to connect to the WiFi, Then try a connection to the MQTT Broker, Initialize the sensors for scd40 and send a value to my broker, The broker is working and I have been able to connect using MQTT Explorer and send messages to topics, The issue here is the hardware will not accept custom UIFlow code, Im completely stuck dead in the water here and struggling to find any decent support.
Much appreciation in advance, Thanks!
-
@ViperNZ Take it back to the basics of just a label, test and then add each block untill the error happens and then post the error message from the console.