Live data from Hacker News

CircuitPython – The easiest way to program microcontrollers

circuitpython.org

31–40 of 46 posts

Re: CircuitPython – The easiest way to program microcontrollers

#31

My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting. Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At th…

A broad statement such as this inevitably gets it wrong.

I use micropython for developing embedded applications for industrial sensors. It is much faster to develop and I am fine using microcontrollers with enough memory that I do not need to optimize every last byte. Cost of the hardware is not the priority.

There are applications where there is not enough memory and python isn't the right tool. But in a world where microcontrollers keep getting more advanced and packaging more memory, claiming that languages like Python have no place is just as wrong as when people claimed Python had no place against C/C++ back when PCs were more resource constrained.

The economics for this type of question typically center around volume shipments. If you're shipping lots of hardware, optimizing hardware cost (and therefore minimizing software resource requirements) is the priority. If you're not, developer time is the main cost. There are a lot of products in the latter category.

Re: CircuitPython – The easiest way to program microcontrollers

#32

Earlier quoted context omitted.

It's really quite nice to be able to telnet into a running micro-controller (over wifi even!), play around with pins directly, all that. Being able to run code at runtime with no compile step also opens up the possibility of micro-controllers that can load "apps" or other user code at run time. Somehow I don't think people would be this snobby about the advantages of an interpreted language if it was running lisp^1 i…

It's not about being snobby - it's about choosing the right tool for the job. Challenge: Come up with a set of project requirements for a practical electronics device, and evaluate if Python is the right tool for the job. I'm suspicious you'll run into headaches with interrupts, DMA, concurrent processes interfering with each other due to taking up too much CPU time, onboard peripherals beyond the most popular in the…

We're getting lost in the weeds a bit. All the examples and "fast prototyping" mentioned in these threads are possible because someone wrote _C_ code to handle the 80% of common use cases then wrote python bindings to make it easier to write.

It's not really the Python that makes the difference, it's the fact that all the common peripherals and happy paths are pre-written for your board/mcu.

My impression about modern embedded devices is that it's much less about bit-banging together 14 barely-compatible components with high timing requirements than it is just getting a battery-powered, wifi-connected, USB-compatible handful of COTS sensors online and dumping to your dashboard. Circuit Python seems totally reasonable for that.

Re: CircuitPython – The easiest way to program microcontrollers

#33
Hi, what is really cool about micropython is, rapid prototyping on the CU, which allows for real time interactivity with the HW, see what you are doing on the board. All this without and IDE, just a shell command!

Wait, where have I heard this before, and with the capacity to expand your language to meet your needs at near close to the wire speed without the needs for all the resources needed by MicroPython... Forth any one?

Re: CircuitPython – The easiest way to program microcontrollers

#34

Earlier quoted context omitted.

It's not about being snobby - it's about choosing the right tool for the job. Challenge: Come up with a set of project requirements for a practical electronics device, and evaluate if Python is the right tool for the job. I'm suspicious you'll run into headaches with interrupts, DMA, concurrent processes interfering with each other due to taking up too much CPU time, onboard peripherals beyond the most popular in the…

We're getting lost in the weeds a bit. All the examples and "fast prototyping" mentioned in these threads are possible because someone wrote _C_ code to handle the 80% of common use cases then wrote python bindings to make it easier to write. It's not really the Python that makes the difference, it's the fact that all the common peripherals and happy paths are pre-written for your board/mcu. My impression about moder…

Yes, and using C++ based systems like Arduino and PlatformIO seems similar. Those of us who use them are hoping not to have to write our own device drivers, though it's certainly possible when needed.

These software platforms are sort of like little operating systems - from a practical standpoint a lot of the value comes from the hardware support. How useful it is depends on whether there is support for the boards and devices you want to use.

Re: CircuitPython – The easiest way to program microcontrollers

#35
post #10

How does it compare with MicroPython? In any case, can be good for PoC or similar things where your microcontroller is largely oversized for the application, but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language. For a hobby project you can get a microcontroller that has 10x the actual power you need and use Python on it, but on an industrial scale it's not…

On the other hand, with a Raspberry Pi Pico board selling for $4 and the chip going for <$1 in bulk, I'm guessing that for small-scale manufacturing, going cheaper isn't worth the hassle? It depends what the market is.

Re: CircuitPython – The easiest way to program microcontrollers

#36

My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting. Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At th…

As others have mentioned, you don't always need the full performance of these microcontrollers, and many are pretty powerful to start with. An ESP32-S3 has two cores running at 240 MHz, and boards that ship with 8 MB of RAM and 16 MB of flash for $22[1]. They also have WiFi, BLE, and tons of pins. This is more than enough to run many programs with CircuitPython, and the number of libraries available for it[2] makes it incredibly easy to get started building small projects.

In addition, connectors like Qwiic/STEMMA QT[3] make it possible to connect to a large number of sensors without needing a breadboard or having to solder anything. I've built a few projects with microcontrollers like these and Adafruit sensor boards and never had to resort to low-level languages.

[1] https://esp32s3.com/feathers3.html

[2] https://docs.circuitpython.org/projects/bundle/en/latest/dri...

[3] https://learn.adafruit.com/introducing-adafruit-stemma-qt/wh...

Re: CircuitPython – The easiest way to program microcontrollers

#37
post #10

How does it compare with MicroPython? In any case, can be good for PoC or similar things where your microcontroller is largely oversized for the application, but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language. For a hobby project you can get a microcontroller that has 10x the actual power you need and use Python on it, but on an industrial scale it's not…

CircuitPython is a fork of MicroPython, and they periodically bring in commits from MicroPython to stay up to date.

One advantage of CircuitPython is that your board gets mounted as a volume like a USB drive, and you can just copy code.py onto it to install your program; it's just a more user-friendly experience. For comparison MicroPython only exposes a file system through a tool called rshell[1], that you need to use to copy code over. CircuitPython also seems to have a lot more libraries due to Adafruit's investment in this ecosystem, although I suspect that most of them could easily be adapted to work with both.

[1] https://github.com/dhylands/rshell

Re: CircuitPython – The easiest way to program microcontrollers

#38

My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting. Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At th…

It's really quite nice to be able to telnet into a running micro-controller (over wifi even!), play around with pins directly, all that. Being able to run code at runtime with no compile step also opens up the possibility of micro-controllers that can load "apps" or other user code at run time. Somehow I don't think people would be this snobby about the advantages of an interpreted language if it was running lisp^1 i…

How about https://ulisp.com/?

It's a subset of common lisp, and seems to be able to do a fair bit. The Python interpreters probably have a lot more community traction though.

Re: CircuitPython – The easiest way to program microcontrollers

#39

Earlier quoted context omitted.

It's really quite nice to be able to telnet into a running micro-controller (over wifi even!), play around with pins directly, all that. Being able to run code at runtime with no compile step also opens up the possibility of micro-controllers that can load "apps" or other user code at run time. Somehow I don't think people would be this snobby about the advantages of an interpreted language if it was running lisp^1 i…

It's not about being snobby - it's about choosing the right tool for the job. Challenge: Come up with a set of project requirements for a practical electronics device, and evaluate if Python is the right tool for the job. I'm suspicious you'll run into headaches with interrupts, DMA, concurrent processes interfering with each other due to taking up too much CPU time, onboard peripherals beyond the most popular in the…

Requirement: when someone opens your front door, closing the contacts of a magnetic reed switch, send a (hard-coded) http message to a serverless function.
Post reply on HN