Working on this project to control an air conditioner. Came across Circuitpython and thought I like Python, Adafruit has a bunch of useful libraries, looks like a good thing.
I've almost completed the Python code and have seen comments about how Circuitpython is intended mostly as a learning tool and is not appropriate for a "real" deployment.
And... just last night, the Circuitpython core crashed
I may need to translate to Arduino/C/C++. Translating the basic code is probably not such a big deal. I'm worried about the availability of Arduino/C/C++ for the Adafruit Circuitpython libraries.
I've got an Adafruit display with touchscreen. A temperature monitor. An RS232/Modbus port. A Wiznet network interface.
I tried searching the forum and didn't see much on this topic. Surely others have been down this path. Any helpful advice would be welcome.
As someone who has done many 'ports', I don't remember any that didn't end up as just well-guided rewrites. In other words, the old sketch is your design doc, just write new C/C++ code to perform the same functionality.
I don't understand the concern re libraries, they will be written in C++, just search the library manager for an Adafruit Display library, temperature monitor, RS232/Modbus, etc.
I did this on VS Code on top of the Circuitpython file system. No Arduino.
I have zero Arduino experience, so I do have the Arduino learning curve to climb. I don't think it will be too bad. I'm just hoping there are Arduino libraries with very similar functionality.
Depends on what you mean by 'Arduino'. The Arduino IDE is similar but different from VS Code. I know nothing about Python, though I plan to study it later this year.
Arduino has thousands of Libraries, the issue isn't that there isn't one, it's figuring out the 'best ' one to use.
Each library comes with sample code so it is easy to get up to speed quickly.
Although it is beginner friendly, I would not neccessarily class CircuitPython (or MicroPython) as just a learning tool. CircuitPython, MicroPython and C++ are programming tools, but the C++ language is different in that the source code first needs to be compiled before it can be uploaded to a micro-controller and run. Python code does not, but does require the CitcuitPython or MicroPython core to be uploaded to the micro-controller along with the Python program. C++ also has a different syntax and way of handling things like variables and loops, but may also have a performance advantage. Compiled code can also run on MCUs that have far less flash memory. It really depends on whether that extra performance is actually needed. You can choose to use whatever tool suits so long as the hardware supports it and has the features needed for your project.
What do you mean that “the Circuit Python core crashed”? Was it the Vscode CircuitPython plugin that crashed? Or did it somehow get corrupted on your board?
Translating the code would, of course, be a great learning experience.
Information about Adruino and MicroPython, including supported Arduino boards, can be found here:
I do think that C++ would generally be given preference in the case of creating a mass produced consumer device due to the resource overhead of the Python interpreter resulting in the need to use a more resource rich (and thus more expensive) microcontroller.
However, that is in an application where every penny of BOM cost matters. This is not a significant consideration for experimentation, one-off, or even small run devices.
I wouldn't give too much credence to such statements as applied to the latter use case, unless you see evidence that they are backed with verifiable facts. People tend to be highly opinionated/biased about programming languages.
C++/Arduino is a very nice language. If you want to start using it, then definitely go for it! However, if you would generally prefer to stick with CircuitPython or MicroPython then I'm sure you will be able to accomplish amazing things with that language as well.
One thing in favor of C++/Arduino is that you have a larger variety of supported boards to pick from. The 8-bit microcontrollers that are much beloved in the Arduino community simply don't have the resources to run the Python interpreter, so they are conclusively off the table for CircuitPython and MicroPython. However, you are in a situation where you are already using a CircuitPython-compatible board, so that might not even be a factor for you.
I second @sonofcy's advice to just take a look. If you aren't sure whether you want to install Arduino IDE or some alternative Arduino development tool yet, you can just use your favorite search engine with a query like <part model number> arduino library (where <part model number> is the model of the accessory you want an Arduino library for.
Alternatively, you can search all the libraries in the Arduino Library Manager here:
What did you do to crash the core? I’ve used CircuitPython in a small number of deployed projects and it's been very stable. I’d certainly be interested in knowing of any failures.
That's a good question. And I'm not really sure what I did.
Best guess is I was not properly deallocating this "simple-pid" class. I have been using gc.memfree() to identify any memory leak issues, but did not notice any worrisome gc.memfree() reports.
But I independently figured out my abuse of the simple-pid class. I haven't seen any crashes since I put an end to the abuse.
I looked for and didn't notice any core dump like report out of Circuitpython. There must be some way to convince Circuitpython to drop a tombstone when it crashes? I'm using an Adafruit ESP32-S3 board. It has this mysterious debug output. I haven't seen any description of how to use it?
And finally, its good to hear of successful Circuitpython deployments. My interest in porting to Arduino is diminishing. Although it would be interesting to see how well AI can port my Python to C/C++.