I was wrong about CircuitPython 🤦
Vložit
- čas přidán 17. 10. 2023
- In this video I give a quick overview of the improved developer experience features provided by CircuitPython, it's a much better way to interact with these small arduino boards over using C in the normal Aduino IDE.
The main features include..
* Hot reloading of code
* Easy, intuitive Python API
* Value as a flash drive to hold source files
* Ease of updating
* and more!
I highly recommend this for beginner engineers! - Věda a technologie
Python's a great way to emulate a 1Mhz microcontroller on a 160Mhz microcontroller.
😂
Well o guess for a bit of LED blink blink it’s enough
Idk about 'great', but it's certainly doable and less difficult for the average person to comprehend and do.
@@jnharton I don't think you got the sarcasm :)
😂😂
That's good but remember arduino code runs faster than circuit python.
How much though
@@GG-be6coit depends on what you're doing but as a yardstick if you're using it to compute things, about 3x faster? But here's the thing - speed doesn't always matter. If I want to check some sensors every few seconds then run a motor depending on values, the time spent waiting means the difference in time between the two doesn't exist, they will execute equally fast. So it only really matters in computation heavy scenarios, and even then you gotta ask yourself if it matters to your applications.
@@GG-be6co it depends
Mostly when you're doing is relatively simple like doing automated plant watering system or simple house iot project it's probably doesn't matter, the real actually performance hit that actually can be look without looking any statistics is when you push the chip to it's limit and/or have multiple task to do like act as a server while also polling high bandwidth sensor while doing some little dsp on them and probably also data log the results
@@GG-be6cosupposedly python code runs 100x slower than c code
that gets more complicated when it starts running more optimized, native code sometimes, but still, python is *much* slower
Also, _python._ Something thats caused me headaches in the past. I kinda dislike the whole language because of that.
Now, do this with something like LUA, a language I'm much more open to personally, that'll be cool!
To be fair, circuitpython is basically the firmware and it's just reading+executing the code you wrote from storage. Whereas with an AVR microcontroller your code is compiled into a binary executable (i.e. machine cod).
It’s translated on the fly IIRC.
Machine cod, for those times when biological cod just doesn't hit the spot anymore.
@@gownerjones Haha. :P
Hmm, I might have to give it another shot! I also dismissed it as I’m not usually a big fan of writing with Python (pure personal preference), but I’ve been learning it more lately and just starting to get comfortable with it. Seems a lot smoother than the arduino IDE!
Python and js are 2 launages that programmers wanted to avoid, but endup using 70% of time
It's so much smoother, and it adds a lot of quality of life improvements. Like a easier to code language, garbage collector, easier debugging, much quicker upload speeds and more.
@@cosmin9144 With much quicker upload speeds, do you mean the lack of compilation or smaller uploads due to only needing to upload the interpreter with bundled stdlib once?
@@cosmin9144 you also lower your performance massively and make your program take up much more storage space, which is usually what you want to avoid when using microcontrollers.
Honestly modern JavaScript (and even more so TypeScript) is actually really good. It even performs really well with modern JIT compilers.
Thank! This was the last barrier for me to start playing with boards
NodeMCU: exists
People:
I really love gpiozero for raspberries. They make everything as simple as it needs to be imo
I have a load of Arduinos that aren’t what they claim to be, this might be THE solution - thank you so much!
Wow, thanks for this! It hadn’t sunk in on me previously that CircuitPython was interactive in real time (!)
That’s a gigantic difference for debugging, which is 98% of what I do because I’m just an occasional & not very good IoT programmer 👍
Even though I'm not a fan of python, circuitpython really is amazing, love the rerun on write feature!!!
That is very usefull information. Unlike MicroPython, you have direct access to the mcu's filesystem like a usb drive. Very cool
This is a firmware quirk more than anything! With Espressif MCUs and STM32 MCUs you can get this sorta behavior as well, if you want it (without using CircuitPython, I mean)
MCU's don't generally have a filesystem, let alone one you can modify. And the Atmel AVR line of chips are also a nearly pure Harvard architecture rather than a Von Neumann one. You simply cannot execute from data memory on an AVR. The only way around that is to make your program a virtual machine (e.g. a bytecode interpreter). Whereas the ESP32 is an SoC based around an XTensa LX processor which likely has either a modified Harvard architecture or some sort of hybrid design.
Definitely a great low barrier option for people starting with microcontrollers! Compiled code will always be better for efficiency and security, but its great to have the option now to just use python text files
Can you please tell us what are these two boards? Because the AVRs certainly can't run CircuitPython
The two specific boards in this video are a Seeed Studio XAIO RP2040 and an Adafruit QT PY ESP32-S3. There is less compatibility for CircuitPython than for programming via the Arduino IDE (which is the defacto), but there are a LOT of boards which have CircuitPython support. You can check CircuitPython.org and see the list of dozens and dozens of boards which are supported :)
CircuitPython is good for beginners to start, but micropython is more powerful
@@xanderpixel281circuitpython is a fork of mircopython. It just has a lot of extras built on top of it which makes it easier to start with and less you have to code.
@@parallacksg And the library system is more beginner friendly.
There is a special place in Hell for those who programming MCU with Python.
Wow that's amazing, can you install other libraries as well?
Yes
Yes! a lot of what Adafruit sells has Circuitpython libraries, and you can add your own. It also has plenty of the default python libraries added.
If you make speed demanding applications, c or c++ is the way to go. Micropython is great for learning or making simple projects and reduce development time
It’s very unlikely the difference will matter for any personal project you’ll ever make. There are entire APIs serving millions of requests a second running on Python.
@@skyleite synths.
you don't speed up your code by using C++, you use more powerful MCU. MCUs obey Morse's law but you don't.
@@xiaokangguo5444 c and c++ code will work faster than python code on the same cpu.
Yes!!!!!!!
I'm more accustomed to programming in Python 3 than Arduino's custom programming language, so I feel more at home with code that's easier for me to make out, and had been planning to use CircuitPython across 2 different projects that I'm not actually working on at the moment (as I'm currently working on projects of higher importance).
C++ with a C stdlib. Kinda needed for the slower chips with lower storage, but with the likes of RP2040 and esp32 you don't need that crazy optimisation as often and can afford to optimise for readability. Also let me recommend you esphome, where it's all yaml.
“Whatever programming language Arduino uses”
@@Deighvihd
I didn't bother to search at the time, but have edited my comment to correct it.
came here for this comment, exact reason this intrigues me. I use Python all the time and not really interested in learning arduino's. I'm sure it has it's benefits but for just a pick up and go Python is a much better option for me personally.
Arduino is not using a custom language. It's using c++ with the Arduino library
Two problems:
Lower speed on running codes.
Lower security due it is saved as a file not as binary codes in the micro controller
None of this is necessarily true. Machine code is not any more secure than a script file, because reverse engineering small programs like this is trivial either way. And the speed difference for Python specifically only really matters at this scale for startup (since the entire Python runtime needs to boot instead of just your code), but even that is likely negligible.
To say these points are problems is just ignorance.
@@skyleite write a FOC algorithm in circuitpython and say how well it worked.
1: doesn't matter for any intended application
2: binaries are no more secure than raw code, and it's for enthusiast projects, not a damn corporate production so who cares anyway. Besides, it doubles as it's own code backup this way, the fewer opportunities to lose your work the better.
@@akkudakkupldude it doesn't matter, I made 6dof trackers using a pi pico 16mb and it runs at a fixed 60hz using circuit python AND it's way easier to debug, I don't need anything faster than 60HZ
@@MemzDev YOU don't.
Oh wow. CircuitPython is way cooler than i thought it was. Thanks for sharing this!
wow! really cool. most of my projects aren't super resource intensive, and that kind of serial interactivity really makes this more than worth it for me.
I remwmber switching some code I wrote for a Raspberry Pi from Python to C++
It speed up by a factor of 5000
Terminator for the terminal. Good choice!
Probably for simple project i give it and micropython a try later, been trying it once before without reading any instructions on how to use it and quickly abandoned it for normal ide
Pi pico is probably the easiest and simplest board to upload a compiled code into without any additional hardware for the chip itself to automate the upload process
How is performance though? I am mostly worried about the arduinos limited on board storage and compute speed when using a interpreter language instead of C based compiled
It’s slower than C, guaranteed
@@jmsienerexactly and what about someone stealing your program if you used them in commercial projects...
Heya, I'm an embedded developer and I have some input.
The performance isn't a huge concern as long as you're not IO bit banging or running extremely complex code like an HTTPS capable webserver from the MCU. The main audience for CircuitPython is not the commercial market, it's for DIY and learning.
In a commercial product (assuming a reasonably sized one of 1,000 units or more) it's extremely unlikely you'd see CircuitPython in the first place.
It just makes more sense to dedicate developers to writing a more efficient firmware (usually in C/C++) and using a less powerful MCU. Saving $0.30/unit can be huge for commercial products.
@@DingleFlopAlso the whole easily being able to download the source code and clone the product thing
@@DingleFlop even if performance is not an issue, the battery life is.
Ok, you convinced me, I should try pyton.
Thonny Python IDE can directly connect to devices running micropython.
Would like to see some motor driving tests etc.
Started using micropython, and later circuitpython on my raspberry pico w. With the speed these boards nowadays, I've yet to find a negative trade-off over using C. Even pwm audio just works. Pretty cool.
the problem is that they each (MicroPython & CircuitPython) support about 70% of what you want to do, where the other supports a different 30%. For example, MP supports multithreading, but CP supports USB.
MicroPython is looking to add USB (more widely, it's available on some ports now) in the next release. Reason it's taken so long is that they've wanted to expose USB features (descriptors etc) in Python. @@unicodefox
lol it holds partly true. some devices are not live running like the galactic and cosmic unicorns, but the Keybow2040 is hot and fun to program on the fly since its a macro pad.
Thumbs-up for that cool dir trick.
Awesome. Thanks
That looks awesome. I need a few.
This is amazing. Thank you for sharing
REPL is a selling point all on its own!
OMG This is so good
Thank! That thing saved my time.
Thank you I shall move to circuit python now
These comments are full of incorrect information. The company I work for uses MicroPython for development of medical devices (up to class II). It's proven to be a very productive environment. AMA.
MicroPython offers excellent performance - don't forget you can easily drop into C to write a small module if better perf is required! - and typically reduces software development time by around 30% compared to a C-based solution.
You should use thingy to get a amazing experience with those boards only use a stable version the others are glitchy
How do you feel about ESPHome?
What operating system do you have
Here's a list of recommended editors for CircuitPython:
mu is an editor that safely writes all changes (it's also our recommended editor!)
emacs is also an editor that will fulIy write files on save
Sublime Text safely writes all changes
Visual Studio Code appears to safely write all changes
gedit on Linux appears to safely write all changes
IDLE, in Python 3.8.1 or later, was fixed to write all changes immediately
Thonny fully writes files on save
I didn't know about mu. Also, how about kate? Does it fully save always?
@@lua-nya Kate is not on the list of 'Recommended editors' or 'Recommended only with particular settings or add-ons.'
While it's not explicitly on the list of 'Editors that are NOT recommended' most modern, 'polite' editors don't explicitly flush the write buffer when they save. If it has a 'safe write' or 'fsync on save' or 'no swap' setting or add-on, you could try it. I don't think you would hard-brick the microcontroler, but you could lose all your work. (i.e. soft-brick it and have to wipe the storage and reinstall the OS)
So cute little controller
Great, I'll get on it right this instance.
The reduced amount of memory is more a pain than the speed.
You could put mp3 files on that flash drive. Imagine the fun projects!
Cool beans!
Shiny!!! 🤠👍
What about the absurd memory overhead and performance decrease?
You can insert a Morse code on that LED "red for space and green for words" and like that you can store a Message of course the "red should blink 3 times for the start of the messaje so you know when the message starts 😊
Is that the proprietary version of MicroPython?
It is not proprietary, just a fork with features aimed at beginners.
"It needs no compilation" well, it kinda needs everytime it runs, but we call that 'interpretation '
Imagine all the resources needed to run not just a Python interpreter, but also an entire _fine system_ onboard...
It's written very efficiently and on MicroPython it is, by default, LittleFS, a well-regarded embedded filesystem. Further, if you want to, you can build your own firmware and the filesystem entirely.
Is there any mcu that supports vscode debugging with breakpoints, getting setting values and full featured
I am tired of serial.print debug
there are a few mcus that have a debug port but you need to understand deep level stuff
and I'm 80% sure none can do breakpoints
you just have to get used to it, that's how it ALL works
Well ESP32 has JTAG debugging on GPIO 12-15. Not sure if vscode has a plug-in.
I've debugged stm32 microcontrollers through JTAG with vscode
As people already mentioned, keyword for you would be JTAG. But really, unless you need to debug very specific hardware issue, you don't need to debug anything on MCU. Debug your modules separately, use simulators, etc.
Oh cool! I didn't know you used Linux. What text editor did you use at around 60% through? Thanks in advance!
I have to admit that this is a very smooth experience developing on those boards with circuit Python. Just tried it when helping a friend of mine with his project.
It’s dead slow for sure but then again, what do we do with those arduinos and picos? I’m sure for most projects it’s sufficient.
I still do all those projects in C, though. Because it just feels so good to program in C
C++ Code compiles closer to the processor architecture, whereas python is interpreted so it'll be slower if you are doing complex stuff like interrupts or math calc
FINALY someone using Ubuntu!!!!!!!
Oh man there's probably a huge wrapper/interpreter on chip. (well I hope its at least compiled down to memory safe C). Just was programming an ATTiny85, man I needed as much RAM as possible - I don't think this workflow would be ideal. I use VScode, and deploy with arduino toolchain.
This might just be a game changer for me 😮
What about reassigning pin functions? I always assumed this is why we still need to compile on modern 32bit micros. Could see this as a nice move for 3D printers to make all mainboards truly universal. Running Klipper would be a sinch, Marlin code still sucks but maybe 150+ someone's could overhaul it.
You should try Espruino instead 🤩
😳 shoot ... need to update my learning now.
Abstraction on top of abstraction, performance be damned
Huh... all my use cases so far are things that require very little processing power, while I find C++ development an even bigger chore than writing Python code. I might actually give this a try.
It would be sick to replace a bios chip with one of these for easy flashing. Kinda sick of hooking up my eeprom flasher with a clip.
It just depends guys
Python is always the fast enough choice. If you going for maximum performance, don'r.
What's for maximum performance???
@@Naveen-bc9xk Assembly.
@@NoProblem76Only if you know more than the C compiler, which isn't true for most developers that ask what's the fastest, ;)
@@NoProblem76 Everything is open-source if you know assembly language.
Say goodbye to hard real time constraints
Ah yes, just what a resource constraint system needs: the slowest mainstream programming language on the planet.
Who cares? If it's fast enough for what you need to do, then _it doesn't actually matter._
Stock Python is slow _because rational people realized that raw speed is often just not that important or useful,_ and flexibility and ease of programming is actually what matters far more in the vast majority of cases. Modern microcontrollers are really no exception.
@@foogod4237modern people realized a torture of a syntax where fucking indentation matters is beneficial, to WHO?
@@supermaster2012 Oh, I dunno, maybe to the literally hundreds of thousands of people who actually use the language every day for all kinds of applications in pretty much all sectors, largely specifically because they find it very easy to learn and work with?
Seriously, please, let's not get into one of those stupid "I decided I wanted to hate the language so I latched on to one bullet point that I thought sounded dumb about it, even though I haven't actually tried it myself, so every other programmer on the face of the planet must be wrong if they disagree with my personal preferences" debates again. It will just make you look like a clueless luddite who refuses to try to understand what the rest of the modern programming world is actually doing or why.
(Nobody's forcing you to use it, but just because _you_ have decided _you_ don't like it doesn't mean other people can't still legitimately find it useful or beneficial for what they want to do. Unless you're really _that_ insecure about everything...)
What a improvement
I'd really like a solid comparison of circuit python vs micropython, from people who actually know. I LOVE micropython. But I'm also pretty basic with firmware level programming. Arduinos C-like is great and generally outperforms micropython, but it's still development level and not production code. Python variants are very much development stuff, but it's just so damn easy... And since you have to rewrite and recompile anyways... What's the downside other than running on extremely thrifty hardware?
I use both CP and MP but primarily MicroPython. I also use MicroPython on production medical devices. AMA.
So every time you save your code it writes to the device? Wouldnt that wear out the memory quicker?
damn, thought you were gonna talk about microchips studio
can go all the way down to AVR assembly
So long as you don’t need a ton of performance, or a lot of functionality (CP takes up a lot of space).
Platformio........... running Python Interpreter on a µC is a whole different discussion.
Python is fine al long as your just messin around or programming relatively simple projects. If your optimising code or using registers I’d recommend c or c++
Nanoframework my man
Compiled means efficient, most of the time.
Ooooo I like this
The way to go and how it is done for real products is to use RTC and c language . If you want to just do hobby projects, then it doesn't matter.
Just wait until you try Micropython
Im going to do that
What kind of projects I can build using this 🤔
So does it run when it is not connected to the host computer?
Thats awesome
Arduino is MUCH faster than circuitpython.
Vscode is a editor not an ide, with some extensions, it can be made close to a ide
curious to know if there is a way to manage watchdog timers.
I'm not sure about CircuitPython but in MicroPython there is.
Yes it was great when I moved to micropython from Arduino
If I flash CircuitPython on an ESP32 will it act flash drive like here? Cause I did flash the firmware using ESPTOOL but it is not showing.
i can use pip3 whith this ?
What is this board called?
This also probably has the advantage of burning out through your writing memory cycles and buying new circuits. But I guess that's not a big concern as it should supports around 100.000 cycles?
A bit like programming a uBit. It does like c++ better tho.
Those who can’t do, teach!
Those who assume, ass!
uLisp is the way to go.
What if I like to code in C/C++
There's a reason most performant python libraries are coded in a c language, and the Arduino framework just so happens to be using a c language, c++ that is.
Adding a high layer to a bare-bone chip is beyond stupid. They are already slow enough.
And what, pray tell, do you need the speed for?
@@droga_mleczna performance matters in some applications. And if you're battery powered.
@@SimonVaIe In most of the cases, performance doesn't matter (unless you're bitbanging, for example, an I2C bus, but if you do that instead of using a library are you sure you're on the right track?), and from my testing MicroPython doesn't use that much more power compared to Wiring or ASM.
He might change your mind when you accidentally delete a large code file from your microcontroller, and then have to go back and redo 6 hours of work. Arduino saves before compiling automatically
nice job running linux!