Embedded Python: MicroPython Is Amazing
hackaday.comI just want a simple SMALL embeddable python library for my C programs... but I have yet to find a good one.
You may want to consider Asp. It is python like language thats interpreter is designed for embedded usage. https://www.asplang.org/
Also fully fuzzy tested to not ever crash regardless of the bytecode given to it.
Thanks, it does look neat, and relatively small I guess, but I should have clarified my definitions.
By small I meant like, at most only a few files in a single folder I can just drop into a project and be off running quickly and easily. Seeing cmake in that repo for example was a big sign that it's still way too big for what I want.
Yes it is. Also, not only for embedded / IoT stuff. There are some use cases where the quick startup time and low overhead of MicroPython can be useful. Unfortunately, support from mainstream distros (e.g. Debian and derivatives) is perfectible.
I've tried to use micropython a few times, and it just didn't gel for me.
All the examples I've found seem to center around doing things interactively in the CLI. Do people write code like that? I write a lot of python and I maybe interact directly with a REPL for 5 minutes in a month.
There was no good tooling for managing a set of script files on the embedded device, and as soon as I had something mildly complex (on a ESP32, consuming from MQTT and writing to a serial device), I started hitting OOM errors. I rewrote a bunch of stuff to not use classes, which helped a bit, and then wound up giving up.
Have you tried `mpremote`? It's the standard tool by the MicroPython team that allows - among other features - you to mount your PC filesystem on a MicroPython device. It's a very productive way to develop! Update code on your PC, mount, try it out. Rinse, repeat. No compilation/deploy cycle makes for fast iterations.
But to answer your questions directly, yes, I do use the REPL quite a lot to experiment and figure out how the system works.
I'm surprised that you had OOM errors, especially on an ESP32 where there's usually plenty of headroom. I haven't seen an OOM error - except when I've made a mistake - in years.
On the note of testing I2C devices: hook them up to any VGA or HDMI port and you are good to go with a complete OS. I even have some sensors running that way on my server for domotica needs.
I don't get it. How does one use vga or HDMI to hook up i2c?
You literally just hook a device up to pin 15/16 on an HDMI port.
https://mitxela.com/projects/ddc-oled
DDC is how your OS reads the list of supported resolutions from your display and is present on VGA ports as well. It's just a low speed i2c bus and can be used for other things :)
That's so cool. I just recently saw a more recent impl of this: copying fb over spi on rpi. This approach is much more clever and equally useless
Is memory fragmentation still a thing? I'm sure it is as there are no free lunches as it were. But I agree Micro Python is amazing just have to think about memory usage a little more maybe on smaller devices that run a long time.
I mean does it matter these days? I expect an IOT device to reboot at least once a day and take 2 seconds to boot up at max.
There is absolutely a low double digit percentage of systems that do not power cycle the hardware. We can't assume anything