Arduino VS CircuitPython Speed Comparison

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2022
  • 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 ปีที่แล้ว +39

    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 ปีที่แล้ว +14

      OTA Updates are possible with any language. You just have to reserve extra space on the Chip

    • @Tims_Projects
      @Tims_Projects ปีที่แล้ว +2

      @@NabekenProG87 You are right, also space for the interpreter or compiler.

    • @damiankaleomontero496
      @damiankaleomontero496 11 หลายเดือนก่อน +2

      builds custom bytecode interpreter because to heck with python

    • @SupernovaSpence
      @SupernovaSpence 6 หลายเดือนก่อน +1

      I almost always use a library for OTA updates on my connected projects… just saying

  • @avejst
    @avejst ปีที่แล้ว +1

    Great test.
    Great video as always 👍😃

  • @leehewitt9559
    @leehewitt9559 ปีที่แล้ว

    Great video Nick

  • @2kBofFun
    @2kBofFun ปีที่แล้ว +3

    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 2 หลายเดือนก่อน +1

      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 ปีที่แล้ว +3

    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  ปีที่แล้ว +1

      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 10 หลายเดือนก่อน

      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

  • @hpsmexico3497
    @hpsmexico3497 ปีที่แล้ว +2

    Nice vídeo !! One question , why circuit python and no micropython ?

    • @Educ8s
      @Educ8s  ปีที่แล้ว +2

      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.

  • @qzorn4440
    @qzorn4440 ปีที่แล้ว +1

    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.

  • @flingmonkey5494
    @flingmonkey5494 ปีที่แล้ว +17

    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 5 หลายเดือนก่อน +2

      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 5 หลายเดือนก่อน +1

      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 5 หลายเดือนก่อน

      @@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.

  • @darrenl4031
    @darrenl4031 ปีที่แล้ว +6

    I wish these boards were designed for USB-C

    • @williamsteele
      @williamsteele 5 หลายเดือนก่อน

      There are plenty of RP2040 based boards that are. I like the Adafruit PicoDVI board as a good example of one with USB-C.

  • @element4element4
    @element4element4 ปีที่แล้ว +3

    Why do people call "Arduino" a language, instead of a set of libraries...? I find the terminology confusing.

    • @anatoliyv5607
      @anatoliyv5607 ปีที่แล้ว

      Это фреймворк на самом деле

  • @qwaqwa1960
    @qwaqwa1960 หลายเดือนก่อน +1

    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 :-)

  • @m-luthfi
    @m-luthfi 8 หลายเดือนก่อน

    i'm glad that i started "MCU programing" with C++ Arduino IDE

  • @rubialugattimoreira1978
    @rubialugattimoreira1978 ปีที่แล้ว

    Nice! 😀

    • @Educ8s
      @Educ8s  ปีที่แล้ว

      Thanks! 😄

  • @vaggelisntaloukas2016
    @vaggelisntaloukas2016 ปีที่แล้ว

    Thanks!

    • @Educ8s
      @Educ8s  ปีที่แล้ว

      Thank you very much the support! Much appreciated!

  • @piconano
    @piconano ปีที่แล้ว +2

    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  ปีที่แล้ว +1

      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 หลายเดือนก่อน

      Meh...nothing beats assembler.

  • @VerticalWit
    @VerticalWit ปีที่แล้ว

    ! At last :) thank you

    • @Educ8s
      @Educ8s  ปีที่แล้ว

      You're welcome!

  • @dbjindian
    @dbjindian 10 หลายเดือนก่อน

    100% useful very very

  • @Yakroo108
    @Yakroo108 4 หลายเดือนก่อน

    👍👍👍

  • @franciscomarin5191
    @franciscomarin5191 8 หลายเดือนก่อน

    How can I now if you add sleep code in Micropython to make it slower...
    I'm kidding, good video!

  • @atom6_
    @atom6_ ปีที่แล้ว

    the REPL interface is a godsend though

    • @Educ8s
      @Educ8s  ปีที่แล้ว

      Sure!

  • @reinekewf7987
    @reinekewf7987 4 หลายเดือนก่อน +1

    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 3 หลายเดือนก่อน

    I love Pico with C programming! the best of both worlds!

  • @wincydelavega653
    @wincydelavega653 ปีที่แล้ว

    How can I use c++ language on pico please help me

    • @Educ8s
      @Educ8s  ปีที่แล้ว +2

      Just program the board using the Arduino IDE.

  • @brunosuperman
    @brunosuperman หลายเดือนก่อน

    Is Arduino a language?

  • @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!

  • @BH4x0r
    @BH4x0r 11 หลายเดือนก่อน +1

    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

  • @gilazemil
    @gilazemil ปีที่แล้ว

    Интересно

  • @rotorblade9508
    @rotorblade9508 ปีที่แล้ว +1

    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 ปีที่แล้ว

      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 6 หลายเดือนก่อน

      I mean, theoretically you can also compile Circuitpython

  • @gautambhatnagar4765
    @gautambhatnagar4765 2 หลายเดือนก่อน

    I guess the real question is why you would be running complex computations on a microcontroller 😂

  • @Rolandas3K
    @Rolandas3K 4 หลายเดือนก่อน

    It would be interesti g to compare Arduino vs regular c or cpp

  • @akissot1402
    @akissot1402 ปีที่แล้ว

    απο τον τίτλο φαντάστηκα το αποτέλεσμα χδ

  • @0124akash
    @0124akash 4 หลายเดือนก่อน

    Conclusion is python is not for microcontroller because it's very slow ? Compair to Arduino.

    • @robotboy3525
      @robotboy3525 3 หลายเดือนก่อน

      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 ปีที่แล้ว +2

    are you greek?

    • @Educ8s
      @Educ8s  ปีที่แล้ว +1

      Yes!

    • @nickefs8106
      @nickefs8106 ปีที่แล้ว +1

      @@Educ8s γεια σου φιλε και γω ασχολουμαι με αρδυανο

  • @pavankumar693
    @pavankumar693 ปีที่แล้ว

    Hie utook a loooong break!,,

  • @davidl1813
    @davidl1813 11 หลายเดือนก่อน

    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 11 หลายเดือนก่อน

      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!