Code works when I press play but not when I download on device
-
I am super impressed with m5flow coding blocks. Only problem is that on the m5core my code below only works when I press play, but not when I download the code on the device (it fails to connect to MQTT when code is downloaded but works fine when I just press play). Any help will be appreciated!
from m5ui import * from uiflow import * from m5mqtt import M5mqtt setScreenColor(0x222222) mqcount = None angle = None label0 = M5TextBox(8, 215, "Alive", lcd.FONT_Default, 0xFFFFFF, rotate=0) alivecount = M5TextBox(69, 215, "0", lcd.FONT_Default, 0xFFFFFF, rotate=0) circle0 = M5Circle(15, 113, 15, 0xFFFFFF, 0xFFFFFF) label1 = M5TextBox(138, 156, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0) from numbers import Number def fun_f3f2_(topic_data): global mqcount, angle mqcount = (mqcount if isinstance(mqcount, Number) else 0) + 1 alivecount.setText(str(mqcount)) pass @timerSch.event('timer1') def ttimer1(): global mqcount, angle m5mqtt.publish(str('f3f2'), str('alive'), 0) pass @timerSch.event('timer2') def ttimer2(): global mqcount, angle angle = (angle if isinstance(angle, Number) else 0) + 0.1 label1.setText(str(angle)) pass m5mqtt = M5mqtt('f3f2', 'broker.emqx.io', 1883, '', '', 300) m5mqtt.subscribe(str('f3f2'), fun_f3f2_) m5mqtt.start() mqcount = 0 angle = 0 timerSch.run('timer1', 1000, 0x00) timerSch.run('timer2', 10, 0x00)```
-
you need to configure you wifi in code. at least a wifi connect has to be set in the beginning of your code to use the wifi configured in firmware.
-
You need to set up the WIFI functions to connect to a local network in program mode whereas, in test mode it uses the active default wifi setting the memory Is already using.
-
Have the same problem here. If I run the UiFlow Code over the web (Play-Button) it works fine, but if I try to download the code to the Core2 it shows just a black screen and no reaction from the device.
Now, I even tried to add the suggested WIFI connection:
But with no success. Even after a reboot or power-loss (removed the battery because of using the Extension Port Module), everything remains black...
-
@dagloom Did you actually fill in the Wifi SSID and password?
-
@ajb2k3 sure, but I‘m not going to show the credentials here 😉
-
it is possible to have more than one script on the device. In the firmware menu it is possible to choose the default one. Maybe you have a wrong one set as default? It may help to clear the flash and burn the latest firmware. If the download still not work try some demo code to see if this runs as intended.
-
Well for a start, I can’t see any GUI functions in that screenshot to show on screen
-
I was able to figure it out.
It seems, that my setup with two ENVIII sensors connected (1st port A, 2nd Port B via ExtPort 2) does not load the sensors properly and the program crashes.
As comparison the program runs without a problem if the 2nd sensor is not connected into the Extension Port Module...
What are your experiences to connect two ENVIII sensors to a Core2 at the same time?
I found some hubs which could maybe help in that situation:
Any recommendation? Do you have experiences with some of them?
-
@dagloom the PaHub 2 works beautifully with several ENVs.
I made a GitHub repository with an Arduino example, here:
https://github.com/teastainGit/Simple-PaHub-example.
Cheers, TerryP.S. the other two hubs will NOT work at all with ENV
-
@dagloom Ok, now we are getting somewhere.
In UIFLow You can't connect the ENVIII sensor to PortB. ENVIII is an I2C device and has a red connector, PortB is for analog devices and has a black connector.
Both ENVIII sensors have to be connected to PortA via the PAhub2 and then you need to make sure in the config that there are set to the individual PaHub ports not the Cores ports.
The you need GUI labels to show the incoming data from the ENVIII sensors.
The 1to3 mini hub is only usable if the I2C devices have different I2C hubs and the PortBHub is only usable for devices with the black "analog" connector.