Arduino VS CircuitPython Speed Comparison

  Переглядів 34,500

educ8s.tv

educ8s.tv

Рік тому

Arduino VS CircuitPython Speed Comparison
I run the same Pi approximation algorithm on two Raspberry Pi Pico Boards. One board is using CircuitPython and the other one is using Arduino. Which one is faster, and by how much? Let's find out.
CircuitPython Code: github.com/educ8s/CircuitPyth...
Arduino Code: github.com/educ8s/Arduino-Pi-...
Join this channel to get access to perks:
/ @educ8s

КОМЕНТАРІ: 65
@Tims_Projects
@Tims_Projects Рік тому
Another advantage for boards that use an interpreter, if the board also has Bluetooth or wi-fi, you can update the code remotely, because you are just replacing a file.
@NabekenProG87
@NabekenProG87 Рік тому
OTA Updates are possible with any language. You just have to reserve extra space on the Chip
@Tims_Projects
@Tims_Projects Рік тому
@@NabekenProG87 You are right, also space for the interpreter or compiler.
@damiankaleomontero496
@damiankaleomontero496 10 місяців тому
builds custom bytecode interpreter because to heck with python
@SupernovaSpence
@SupernovaSpence 4 місяці тому
I almost always use a library for OTA updates on my connected projects… just saying
@qzorn4440
@qzorn4440 11 місяців тому
This is very interesting information. Do you have some kind of examples using the Debian-Bullseye Orange Pi-5 GPIO PWM servo pins? Thank you.
@avejst
@avejst Рік тому
Great test. Great video as always 👍😃
@leehewitt9559
@leehewitt9559 Рік тому
Great video Nick
@2kBofFun
@2kBofFun 10 місяців тому
2:51 Why is it easier? Personally I find the weird object-everything approach (minion3.display.colour.change.red) with crazy user chosen names and the indentation police of python tougher than c++. Can you compare both too on energy use, also including examples that need a Pico to run in Python, but would fit compiled on an Attiny85. How do those situations compare in speed and energy use?
@ObscuraDeCapra
@ObscuraDeCapra 22 дні тому
As opposed to the ; police and the tab vs space police and the unending holy war of "{ at the end of the line" vs "{ under the line" and all of the other police of C++? C'mon.
@jeffschroeder4805
@jeffschroeder4805 Рік тому
Is it possible to write a program in an interpreted language and convert it to binary prior to flashing it to a micro controller to avoid interpreting it again every time it is run? As to previous comments: No REPL but over the air updates might just require converting to binary or compiling again prior to updating. Aren't OTA updates possible using compiled Arduino code?
@Educ8s
@Educ8s Рік тому
As far as I now it is not possible for microcontrollers. For deskop, take a look at Cython.
@adamkoxxl
@adamkoxxl Рік тому
OTA are possible even for a compiled languages if you code an update mechanism into the binary and reserve space (or use a lib which does this for you). You cannot just convert a script and interpreter to a compiled version of the instructions, it doesn't work like that. On desktop there are different Python implementations other than the default CPython like PyPy or Codon, which are not interpreters but just-in-time/ahead-of-time compilers, i.e. Codon can generate native binaries from Python source code, but I am not sure if this is applicable to microcontrollers.
@dawsonpate7385
@dawsonpate7385 9 місяців тому
yes and no . . . im going to use javascript and v8 as an example since i know how to do it on there, idk about python directly. but with v8 you can create a dump of the memory after the js has been processed and converted to the code to be run (since v8 will process the entire file and create an instruction set in memory) and using that dump u can load that directly into v8 memory and execute it without having to process the file again. now python is interpreted line by line vs the entire file so im not sure if it will work on there but if u can do it you will probably need to create your own custom vm to run it
@m-luthfi
@m-luthfi 7 місяців тому
i'm glad that i started "MCU programing" with C++ Arduino IDE
@hpsmexico3497
@hpsmexico3497 Рік тому
Nice vídeo !! One question , why circuit python and no micropython ?
@Educ8s
@Educ8s Рік тому
Thanks for the comment. I chose to use CircuitPython because I am more familiar with it, there are many libraries available, and the graphics libraries are developed by Adafruit's engineers, the same guys that developed the Arduino graphics libraries, so it is a better comparison. I expect the performance of MicroPython will be similar to the performance of CircuitPython, they both share the same code with only minor differences.
@darrenl4031
@darrenl4031 Рік тому
I wish these boards were designed for USB-C
@williamsteele
@williamsteele 3 місяці тому
There are plenty of RP2040 based boards that are. I like the Adafruit PicoDVI board as a good example of one with USB-C.
@rubialugattimoreira1978
@rubialugattimoreira1978 Рік тому
Nice! 😀
@Educ8s
@Educ8s Рік тому
Thanks! 😄
@franciscomarin5191
@franciscomarin5191 7 місяців тому
How can I now if you add sleep code in Micropython to make it slower... I'm kidding, good video!
@vaggelisntaloukas2016
@vaggelisntaloukas2016 Рік тому
Thanks!
@Educ8s
@Educ8s Рік тому
Thank you very much the support! Much appreciated!
@dbjindian
@dbjindian 9 місяців тому
100% useful very very
@element4element4
@element4element4 Рік тому
Why do people call "Arduino" a language, instead of a set of libraries...? I find the terminology confusing.
@anatoliyv5607
@anatoliyv5607 Рік тому
Это фреймворк на самом деле
@VerticalWit
@VerticalWit Рік тому
! At last :) thank you
@Educ8s
@Educ8s Рік тому
You're welcome!
@flingmonkey5494
@flingmonkey5494 Рік тому
One area of concern for me is program security. If I am going to make and sell a widget using an RPi Pico, I don't want someone to be able to duplicate it by stealing my code from one of my widgets. With Circuit Python the can easily open the memory storage and copy my code from the RPi. With Arduino code only the compiled code is place on the widget and it is much more difficult to reverse-engineer. On other hand, at work, when I make a device to be used in the lab, if I want anyone to be able to edit the code I put there, then Circuit Python is the way to go.
@nUrnxvmhTEuU
@nUrnxvmhTEuU 3 місяці тому
If *I* were to make and sell widgets using the RPi Pico, I would definitely publish all the source code as open source
@nUrnxvmhTEuU
@nUrnxvmhTEuU 3 місяці тому
And if I were to buy a widget, I would much more gladly buy it if it was open source, rather than proprietary
@flingmonkey5494
@flingmonkey5494 3 місяці тому
@@nUrnxvmhTEuU Thank you for your replies. The need for code security depends on your goal for your project. If you are making something you intend to share with others like yourself then yeah, open source is the way to go. But look at a company like Ozobot, with their Bit and Evo robots. Both of those are Arduino-based, and they are VERY cool. But it would be a disaster for the company to provide source code for them, for so many reasons. On the other hand, look at the Ringo robot, also very cool. When I bought mine I was able to download the source code for it, so I was able to hack it and then restore it to original functionality. Different products, different goals for them.
@piconano
@piconano Рік тому
I learned K&R 'C' back in 1985, when most where not even born! It's impossible for me to learn another programming language. I find them all lacking and stupidly slow tbo. If I was a newbie, I would still go for C++. Harder to learn, but second to none.
@Educ8s
@Educ8s Рік тому
I agree, C/C++ is a must for any serious user. But not all users want to spend months to learn a new language just to program a microcontroller for a weekend project. A user that is already familiar with basic Python can pick up CircuitPython in a weekend.
@qwaqwa1960
@qwaqwa1960 13 днів тому
Meh...nothing beats assembler.
@atom6_
@atom6_ Рік тому
the REPL interface is a godsend though
@Educ8s
@Educ8s Рік тому
Sure!
@reinekewf7987
@reinekewf7987 3 місяці тому
1:55 that is not true python code is only once fully interpreted and then the bytecode is much easier to interpret is nearly identical to assembler code witch is simple to interpret. but the best thing is python can force it self reload it self so you can make code that advaces it self or you can change code in runtime without rebooting the system or loss your data that is currently in ram. python might be slower compared to other languages but python can handle big strings and datasets, it has many buildin funtions and everything can be handled like a list. for example counting letters or words in a complete book. the whole book stored in a single string. python can make strings or other types of data with unlimited size. ok that is not fully true the the interpreter can handle 128G at once on windows but on linux 1TB is the limit but this depends on interpreter settings. on a micro controller i dont know how much i think it is set to the same or more ram as the controller has. i personally had one time a dataset that occupied 60gb ram on a single instance of python3. another thing python3 and micropython are the same language wise on interpreter side it depents on your chip but in general it is designed with 16bit cpu in mind but some versions will work on 8bit or multicore systems. circutpython on the other hand is simpler more like assambler but it needs more user work to do the same things but it is much easier for the interpreter but for the fact it is only once interpreted then only the bytecode is executed over the interpreter it will make no difference for the same task. loading time might be shorter.
@robotboy3525
@robotboy3525 Місяць тому
I love Pico with C programming! the best of both worlds!
@arduinocoding
@arduinocoding Рік тому
This is because you helped on the Seeeduino XIAO
@Educ8s
@Educ8s Рік тому
I am glad it worked, and thank you very much for your support!
@wincydelavega653
@wincydelavega653 Рік тому
How can I use c++ language on pico please help me
@Educ8s
@Educ8s Рік тому
Just program the board using the Arduino IDE.
@Yakroo108
@Yakroo108 3 місяці тому
👍👍👍
@gilazemil
@gilazemil Рік тому
Интересно
@brunosuperman
@brunosuperman 4 дні тому
Is Arduino a language?
@akissot1402
@akissot1402 Рік тому
απο τον τίτλο φαντάστηκα το αποτέλεσμα χδ
@BH4x0r
@BH4x0r 9 місяців тому
I can tell you that if you know python and don't know c++, python will be easier me having always used C/C++ it's a no brainer over learning python
@qwaqwa1960
@qwaqwa1960 13 днів тому
Wow, less than 3× advantage to Arduino! Given how much I hate C & love Python, I think I know what I'll be mostly using from now on :-)
@Rolandas3K
@Rolandas3K 3 місяці тому
It would be interesti g to compare Arduino vs regular c or cpp
@gautambhatnagar4765
@gautambhatnagar4765 26 днів тому
I guess the real question is why you would be running complex computations on a microcontroller 😂
@rotorblade9508
@rotorblade9508 Рік тому
arduino nano is 8 times slower than pico but if you use python it would be only like 2.6times unless using the second core. however with complex libraries my code ran like 10x slower than arduino nano. so I’ll have to start all over with arduino c Another problem is often you install libraries that come as packages with many things you don’t even need that take up so much space you run out of flash memory so you then spend a lot of time looking for smaller packages or single library files
@2kBofFun
@2kBofFun 10 місяців тому
A compiler removes all unneeded crap. I once made a speed test and the compiler said if you don't use the result of all those thousand calculations, I can as well remove the code entirely.
@kellerossel
@kellerossel 4 місяці тому
I mean, theoretically you can also compile Circuitpython
@pavankumar693
@pavankumar693 Рік тому
Hie utook a loooong break!,,
@0124akash
@0124akash 2 місяці тому
Conclusion is python is not for microcontroller because it's very slow ? Compair to Arduino.
@robotboy3525
@robotboy3525 Місяць тому
Precisely! Again, try to run the code again but using C programming and the speed will be 3 or 4 times faster than that of the Arduino. Go C or Go See!!, my friend! 🤪
@nickefs8106
@nickefs8106 Рік тому
are you greek?
@Educ8s
@Educ8s Рік тому
Yes!
@nickefs8106
@nickefs8106 Рік тому
@@Educ8s γεια σου φιλε και γω ασχολουμαι με αρδυανο
@davidl1813
@davidl1813 9 місяців тому
a nice comparison to demostrate the speed difference. :) I downloaded the code to see if it could help identify the issues I have at the moment with the Pico and St7735 under Arduino v2.1.0 IDE but the code compilation produces the following errors: ...\AppData\Local\Temp\.arduinoIDE-unsaved2023612-2584-heek7s.8rgmq\sketch_jul12a\sketch_jul12a.ino: In function 'void drawResults(double, double)': ...\AppData\Local\Temp\.arduinoIDE-unsaved2023612-2584-heek7s.8rgmq\sketch_jul12a\sketch_jul12a.ino:93:3: error: 'dtostrf' was not declared in this scope dtostrf(pi, 7, 5, result); ^~~~~~~ ...\AppData\Local\Temp\.arduinoIDE-unsaved2023612-2584-heek7s.8rgmq\sketch_jul12a\sketch_jul12a.ino:93:3: note: suggested alternative: 'strstr' dtostrf(pi, 7, 5, result); ^~~~~~~ strstr exit status 1 Compilation error: 'dtostrf' was not declared in this scope ########## What version libraries (GFX, ST7735, and SPI) are you using? Have you had a problem with the Pico and the ST7735 screen when writing text? My code (snippet below) displays properly until the '.print' is uncommented. It then makes the screen flash rapidly or go completely white. // Load the Libraries #include // Adafruit LCD Graphics library #include // ST7735 LCD Display library #include // Arduino SPI and I2C library /************************** DISPLAY CONFIG **************************/ // pin definition for the 1.8", 128x160 ST7735 LCD Display on Raspberry Pico // These can be connected to any GP Pin not in use #define TFT_CS 9 // using SPI1 CSn #define TFT_RST 8 #define TFT_DC 7 // Used for SPI connectivity on SPI1 #define TFT_SCK 10 #define TFT_MOSI 11 // Setup the ST7735 LCD Display and variables Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCK, TFT_RST); int textxoffset = 5; // move 5 pixels across to avoid the box int textyoffset = 7; // move 7 pixels down to avoid the box int tft_line1 = 0; /*******************************************************************/ /************************** SENSOR CONFIG **************************/ /********************************************************************/ /************************ INTERRUPT FUNCTION ************************/ /********************************************************************/ /*********************** TEMP SENSOR READ CODE **********************/ /********************************************************************/ /*************************** SETUP CONFIG ***************************/ /********************************************************************/ void setup() { /************************ SERIAL Output SETUP ************************/ Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println("Initialising SD card..."); /********************************************************************/ /************************ Initial LCD SETUP ************************/ // Initialise the 1.8" LCD Screen tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab tft.fillScreen(ST7735_BLACK); // Fill the screen with Black tft.setRotation(1); // Set rotation to Portrait mode (set to '1' for Landscape) tft.setTextWrap(false); // By default long lines of text are NOT wrapped at the end of the line, set to 'TRUE' for wrapping the text // Draw the 1.8" LED display layout tft.drawRoundRect(0, 0, 83, 31, 10, ST7735_CYAN); // Draw a Rectangle x,y, across, down with corner & Colour Values tft.drawRoundRect(0, 35, 160, 93, 10, ST7735_CYAN); // Draw a Rectangle x,y, across, down with corner & Colour Values tft.drawLine(80, 65, 80, 110, ST7735_CYAN); // Draw a mid-line x1,y1, x2, y2 for the Colour Values tft.setTextColor(ST7735_GREEN, ST7735_BLACK); tft.setTextSize(1); // Set the text size to 1 tft.setCursor(textxoffset + 54,textyoffset + 1); // tft.print("Test"); // ENABLE THIS LINE AND THE LCD STARTS FLASHING RAPIDLY OR GOES WHITE // THE CODE CONTINUES CORRECTLY IN THE BACKGROUND THOUGH /********************************************************************/ Serial.println("STARTING TEMP READINGS"); } void loop() { }
@davidl1813
@davidl1813 9 місяців тому
Well, I figured out what was wrong with my set up shortly after writing the above comment. I noticed that you had both the 3.3v and 5v connected. With the Arduino you only need to connect the LCD line to the 3.3v for power, while the Pico seems to require BOTH the 3.3v AND 5v line to be connected! As soon as you do this it works like it does on the Arduino board. :) Thanks. Once again your videos have proved very usefull, and I've watched many of them. I still get the error with your benchmark code though :(
@vaggelisntaloukas2016
@vaggelisntaloukas2016 Рік тому
Thanks!
@Educ8s
@Educ8s Рік тому
Thank you very much the support! Much appreciated!
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
GreatScott!
Переглядів 581 тис.
Артем Пивоваров х Klavdia Petrivna - Барабан
03:16
Artem Pivovarov
Переглядів 5 млн
Сын Расстроился Из-за Новой Стрижки Папы 😂
00:21
Глеб Рандалайнен
Переглядів 5 млн
Turning a Raspberry Pi Pico into a GPU!
16:42
element14 presents
Переглядів 99 тис.
Moving from Arduino to MicroPython - 10 Things you need to know.
15:49
Kevin McAleer
Переглядів 22 тис.
MicroPython vs Arduino Benchmarking on an ESP32 microcontroller
14:24
«Что может Python на микроконтроллерах» Андрей Власовских, JetBrains
33:17
Видео с мероприятий {speach!
Переглядів 31 тис.
Try these 16 Brilliant ESP32 projects!!!
11:18
ToP Projects Compilation
Переглядів 511 тис.
#370 Raspberry Pi Pico vs ESP32 (-S2) and STM32 Blackpill
15:53
Andreas Spiess
Переглядів 383 тис.
Pi pico therapy timer and C vs. micro python
8:27
Matthias random stuff
Переглядів 28 тис.
3 Easy @raspberrypi Pico Projects that ANYONE can tackle!
19:21
Print 'N Play
Переглядів 135 тис.
Рекламная уловка Apple 😏
0:59
Яблык
Переглядів 392 тис.
Что еще за обходная зарядка?
0:30
Не шарю!
Переглядів 384 тис.
10 regrets of experienced programmers
8:16
Fireship
Переглядів 391 тис.
Broken Flex Repair #technology #mobilerepair
0:50
ideal institute aligarh
Переглядів 888 тис.
Секретная функция ютуба 😱🐍 #shorts
0:14
Владислав Шудейко
Переглядів 2,2 млн
Samsung UE40D5520RU перезагружается, замена nand памяти
0:46
Слава 100пудово!
Переглядів 2,5 млн