July 12th, 2024

Embedded Python: MicroPython Is Amazing

MicroPython, turning 11, enables interactive microcontroller control with REPL. Offers libraries for networking and JSON. User-friendly for projects, not ideal for high-performance needs. Popular for Python-based embedded programming.

Read original articleLink Icon
Embedded Python: MicroPython Is Amazing

MicroPython, celebrating its 11th birthday, offers a versatile platform for hacking and development. With its REPL feature, users can interactively explore and control their microcontrollers, making tasks like debugging and prototyping more efficient. The platform provides access to a wide range of libraries, simplifying tasks such as network requests and JSON parsing. While MicroPython may not be suitable for all scenarios, especially those requiring extreme performance or low power consumption, it offers a user-friendly environment for developing projects. The platform's flexibility and ease of use have attracted users to experiment with interactive coding and hardware exploration. Additionally, MicroPython's compatibility with various microcontrollers and its support for additional functionalities like PIO and USB-HID make it a valuable tool for diverse projects. Despite some limitations and personal preferences, MicroPython continues to be a popular choice for embedded programming enthusiasts looking to leverage the power of Python in their projects.

Related

What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

Several Python updates include Django's background task integration, a new lightweight Python REPL, Uvicorn's multiprocessing support, and PyPI blocking outlook.com emails to combat bot registrations, enhancing Python development and security.

Show HN: ViperIDE – An Innovative MicroPython IDE for Web and Mobile

Show HN: ViperIDE – An Innovative MicroPython IDE for Web and Mobile

ViperIDE is a modern MicroPython IDE for web and mobile platforms. It offers features like no installation required, cross-platform connectivity, file editor, package manager, terminal/REPL, and device support. Explore on ViperIDE's website or GitHub.

Python Modern Practices

Python Modern Practices

Python development best practices involve using tools like mise or pyenv for multiple versions, latest Python version, pipx for app running. Project tips include src layout, pyproject.toml, virtual environments, Black, flake8, pytest, wheel, type hinting, f-strings, datetime, enum, Named Tuples, data classes, breakpoint(), logging, TOML config for efficiency and maintainability.

Summary of Major Changes Between Python Versions

Summary of Major Changes Between Python Versions

The article details Python updates from versions 3.7 to 3.12, highlighting async/await, Walrus operator, Type hints, F-strings, Assignment expressions, Typing enhancements, Structural Pattern Matching, Tomllib, and useful tools.

Own $20 MicroPython Smartwatch

Own $20 MicroPython Smartwatch

A Hacker News post highlighted running MicroPython on a $3 smartwatch, showcasing MicroPython's simplicity for microcontrollers. WASP-OS introduced as an affordable alternative for PineTime. Colmi P8 smartwatch at $16.29 enables MicroPython usage with 240x240 screen and long battery life. Users can set up the watch using an Android device with BLE capabilities for custom app development.

Link Icon 7 comments
By @ranger_danger - 4 months
I just want a simple SMALL embeddable python library for my C programs... but I have yet to find a good one.
By @fermigier - 4 months
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.
By @fake-name - 4 months
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.

By @consp - 4 months
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.
By @th0ma5 - 4 months
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.