7 ms·
CircuitPython – The easiest way to program microcontrollers
- lagrange77 4y agoWhat i learned too late is, that it does not support interrupts for user code.
- Ecco 4y agoLame fork of MicroPython by Adafruit...
- major505 4y agoI used Circuit python in a Raspberry PI Pico. It's ok for prototyping, I would not use it on production. Still recommend using C++, and Platformio for most things. But it helped me with quick hacks and proofs of concept. For example, my company build a laser warning system that would be triggered when someone cut through the laser. I build a quick remote control to trigger the system without having to get on a ladder and put the hand in front of the laser to diagnose problems.
- nkozyra 4y agoWhat was the downside? Why only prototyping? I've not used a pico but other microcontrollers with c++ interfacing tools, and my thoughts are these things don't have interpreters onboard so the language choice is likely not that important. But I'm limited to TI boards.
- coupdejarnac 4y agoIn general with the the embedded Pythons, they are 2 or 3 orders of magnitude slower than C (big surprise) and they don't support all the hardware features. By necessity, they have a one-size-fits all approach that works fine for hobbyists but might not be sufficient for production. That all said, I love to bang out a prototype or one-off project with CircuitPython or MicroPython. Or Arduino if it makes sense.
- major505 4y agoI never had to do something that could not be done with python. Probably some libs for more exotic hardware, but depending of how you program you can loose events like button presses if you do not consider the slow response time in python.
- temperateregi 4y ago> I never had to do something that could not be done with python. Do you write embedded code professionally?
- major505 4y agoThis days I`m more an android dev. But I do as a side gig. Me and a friend to small projecrts for smartcities like interative propaganda totens, wifi access points, smart traffic warnings. Things like that. I also programed some small scale things in my last to job. One of them was a tamagotchi. I did not filmed the completed version, but I done a video testing the animations: https://youtu.be/fltoTmUJPBE https://youtu.be/fltoTmUJPBE
- deleted 4y ago[deleted]
- nkozyra 4y agoSee I'm surprised Python is not just a convenience that's ultimately transpiled before making its way to the MCU. C++ is high level enough that I always assumed much of that work was already happening for microcontroller work.
- matt_trentini 4y agoThey're slower if you spend cpu-intensive time in the interpreter. If you're calling wrappers for C functions then there's little difference. For example, sending SPI or I2C data are effectively identical. Same too if you want to render a QR code using a C library for example [1]. So if you ever find that you need more performance you can drop into C, write a user module, and get the benefit of easier Python syntax and C performance. The only reason some hardware features aren't supported is a lack of effort to expose those features. Come help us fill in the gaps! :P [1] https://www.youtube.com/watch?v=437CZBnK8vI https://www.youtube.com/watch?v=437CZBnK8vI (Not my best presentation, I'm sorry; I was running on very little sleep and a high degree of stress!)
- major505 4y agoMostly I'm more experienced with C++. But it all depends of what you need to do with it. Like would I put python in something that someone can get hurt if it dosen't work ? Not. For things like just printing information in a OLED display? Sure, why not. Its easier to mess around with strings in python.
- zoom6628 4y agoOn the website: "CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards." That is it in a nutshell. Its a Adafruit fork to conjoin the best of both worlds - adafruits simple boards and python as a easy language with which to get started. or to PoC something quickly.
- SlicerDicer 4y agoI find it impossible due to my edge cases. I stick with C++
- matt_trentini 4y agoWhat are your edge cases?
- ale42 4y agoHow 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 justifiable. 8-bit microcontrollers are still around for some reason...
- traverseda 4y agoBeing able to load extensions at run-time could be a pretty big advantage. Have "apps" you can install on the micro-controller. >but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language With micropython you can mark a function to be compiled, or even write a function as inline-assembly. Like normal python develop quickly and optimize the expensive parts. Micropython makes it quite easy to optimize the expensive parts with the viper code emitter and inline-assembly options.
- cozzyd 4y agoIt can "work" on smaller microcontrollers (where "work" means you have to constantly restart the microcontroller because you run out of RAM...)
- tssva 4y agoFrom the top of the webpage, "CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards." It targets beginner hobbyists and the lower grade education market. The changes from MicroPython are designed to make getting code on to the board and executing easier for those users. When a microcontroller board with CircuitPython is connected to a computer it appears as a USB drive. To install your code and any supporting files on the board you just drag and drop them on the drive vs having to upload them using something like Thonny with MicroPython. Also when you drop your code on the drive the board automatically resets and begins executing the code. It also has some changes to make code more portable across the different microcontroller boards it supports.
- 4y ago
- the__alchemist 4y agoMy 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 this time, they're C, C++, Rust, Zig, and ADA. For example, on my embedded projects, I use Python to handle the webite framework, and to generate filter coefficients using Scipy, and plot data with MPL. I use Rust for the firmware.
- tssva 4y agoCircuitPython is designed for beginner hobbyists and the lower grade education market. Basically those with none to little programming experience.
- traverseda 4y agoIt'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 instead of python. Of course to be fair if it was javascript they'd be twice as snobby and I'd agree with them... [1]: https://thenewstack.io/nasa-programmer-remembers-debugging-lisp-in-deep-space/ https://thenewstack.io/nasa-programmer-remembers-debugging-l...
- the__alchemist 4y agoIt'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 most popular configs won't work etc.
- spaintech 4y agoHi, 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?
- rcarmo 4y agoI’m building a custom MIDI controller and it took me no time at all to get a prototype going with a linear pot and an I2C display: https://taoofmac.com/space/blog/2022/06/05/0025 https://taoofmac.com/space/blog/2022/06/05/0025 Extremely impressive in that regard, although I might switch to C++ later if the response seems slow. Altogether, I think CircuitPython (and MicroPython, of which I own the original development board) is an amazing achievement given the number of boards it currently runs on and the state of affairs we were in a decade ago…