M5Stack Dial with Micropython and M5 libraries, without UIFlow 2?
-
Is it possible to program the M5Stack Dial directly in Micropython, and have the device load that .py file (e.g. main.py) from boot when connected to battery, without messing around with UIFlow 2?
I'll need access to the M5Stack libraries still, to display things on the screen, make beepboops, read the touchscreen, read BtnA etc..
I'm going in circles. There are many confusing posts from 5-7 years ago. There's a deprecated Github folder that looks promising, but then says to use the new Github for UIFlow 2, with no instructions on how to just do Micropython from Thonny or ideally VSCode, without the buggy graphical UI Flow 2 interface.
I feel this is simple, since all UI Flow 2 is create Micropython code, but I can't quite figure it out?
Many thanks,
Adam
-
@PharkieB Yes, I use Thonny for programming and uploading Micropython.
Thonny makes it easier to upload images and libraries to M5Stack devices.
https://thonny.org -
@ajb2k3 That's great to hear that it's an option!
So do you flash your M5Stack device with the M5Burner and UIFlow build, or is there a more "normal" Micropython build that works (the Dial is an ESP-32 S3 "Stamp").
Can you make your M5Stack device run your Micropython code directly, without the bootloader that shows Wifi settings etc?
Any help or tips appreciated.
-
@PharkieB I will have to check because I've been so busy that I have actually forgotten!
-
@PharkieB MicroPython is a distinct programming language for ESP32.
Thonny IDE is an Integrated Development Environment that allows you to develop your own programs in MicroPython. It is not graphic as is UIFlow, but text based.
It also allows you to download (burn) directly.
Check it out!https://randomnerdtutorials.com/micropython-ides-esp32-esp8266/#thonny-ide
-
@teastain Thanks, but I'm still unclear how to navigate the bootloader on the M5Stack Dial. What I'm used to are ESP32 or Pico devices that are flashed with standard Micropython builds, and start main.py or boot.py on startup.
The firmware on the official Micropython site only support a couple of M5Stack devices and not the Dial. Would the one for the Atom S3 Lite work on the Dial https://micropython.org/download/M5STACK_ATOMS3_LITE/ ?
Otherwise, with the "UI Flow 2" firmware, the M5Stack Dial has its own mysterious bootloader, which allows OTA updates and configuring Wifi etc. On boot, this takes several seconds longer, and starts my Micropython script if connected to USB-C cable. I want this to work just on battery power, so I have connected the Lipo battery to the battery connector on the Dial. If I start the program with USB-C connected, I can then remove the USB-C cable and the program continues fine. I can also use Thonny to start the program, and see the REPL console.
What doesn't work is, with only the battery connected, turning on the device with long-press of the front bezel button (BtnA). After a successful download of my program from UI Flow 2, it's supposed to run my program, but just.. doesn't. The device turns on (red LED on underneath) but nothing on the screen. Pressing reset turns it off (red LED goes off). Pressing BtnA turns it back on again. But it's not running the program I made in UIFlow 2.
Is there a guide somewhere to using a M5Stack device on battery, configuring the bootloader, to make them run a Micropython program on boot? I'd really prefer to get rid of that bootloader - it's not helping me.
I can't figure out what I'm doing wrong, the documentation is fragmented and low on detail, and I haven't found any good guides to programming and using the Dial.
Thanks in advance,
-
@PharkieB
You should stick with UIFlow for a while and examine the MicroPython files that are generated to get an understanding of how they work!
The Dial is just a ESP32S3 (M5StampS3) on the inside but there may be difficulty getting a screen driver in MicroPython.
This is a kind of Do-It-Yourself hobbyist tech.
It can be very rewarding learning and getting in to it!
FYI every ESP32 has a permanent built in BootLoader that is indestructible. You should figure out how to 'erase all' and start over. The BootLoader will still be there ready to download your next program. -
I can be more specific.
When I "Download" from UI Flow 2 to the device, it works:
Press BtnA to switch on.
Press BtnA to switch off, once my program allows, with custom MPY:hold_pin = Pin(46, Pin.OUT) hold_pin.value(0)
But a problem is if I LONG press (6 secs) BtnA, the device FULLY resets. It goes to the QR code and device Mac screen. That menu crashes almost immediately, meaning I can't rotate the dial to run my Python script. The only way to get it back working is to redownload from UI Flow 2?
Is there a way to turn off that long-press reset function? Or to stop the QR code menu from crashing, so I can at least run my program?
These details about long press BtnA or the reset button on the back don't seem to be covered by the main reference, https://docs.m5stack.com/en/core/M5Dial