Raspberry Pi Pico compared to Arduino Maker 1010

 

Starting with a feature and price breakdown.

 

MKR WiFi 1010

Pi Pico W

Processor

Cortex-M0+ 32bit ARM running at 48MHz

2 ARM Cortex-M0+ 32 bit cores clocked at 133MHz

Memory

256Kb Flash plus 32Kb RAM

256Kbyte RAM

WiFi

2.4GHz 802.11 b/g/n

2.4GHz 802.11 b/g/n

Bluetooth

BLE

5.2

GPIO Pins (excl. power etc.)

22

1xSPI, 1xI2C, 1xUART, 7x12-bit ADC, 1x10-bit DAC, 13xPMW

10x External interrupts

26

2×SPI, 2×I2C, 2×UART, 3×12-bit ADC, 16× PWM

All GPIO pins support external interrupts

Real time clock

yes

yes

Other

Encryption Chip

Temperature sensor

Floating Point library on chip

8×Programmable IO state machines

SoftAP

Price

£29.90

£7.00

Looks like an easy price/performance win for the Pico even if you needed to buy an external DAC for a specific project.

Board hook-up usability.

The Arduino comes with male and female headers while the Pico WH, I chose, has just male pins. You could, of course, buy the bare Pico W and solder your own chosen header type to the board. Both can be powered and programmed though a micro-USB port.

Developer Set-up.

A clear win here for the Arduino. Arduino development using the desktop IDE is a simple installation on Windows, Linux and MacOS that could be titled “It Just Works”. Setting up the toolchain for the Pico requires a rather more effort and expertise.

The Raspberry Pi family is rooted in the Linux OS and even though the Pico runs C++ “on the metal” it is way more straightforward to develop using a Linux PC. A reasonable choice might be a Raspberry Pi 4 – I chose to use my Raspberry Pi 400 and there is a pre-prepared installation kit available for those platforms. I did build a setup on Windows (10) and it was pretty steady but the Raspberry Pi installation instructions suggested that you need a Raspberry Pi (4B maybe) to sit between a Windows PC and the Pico. This turned out to be strange advice. Once I had built and loaded a program for my Pico using Linux I just followed the same procedure to load a compiled program from Windows (see below) and all worked as expected.

Later it also turned out that the Arduino IDE supported Pico C/C++ development on all relevant platforms - including Windows.

The Pico can be programmed using Python and the MicroPython firmware running on the board. This could be a key feature for some.

Python aside, someone coming new to microprocessors should probably choose the Arduino offerings unless they have pre-existing skills building toolchains on their favoured PC platform. More experienced developers are going to relish the opportunities afforded by the Pico family.

Hello World.

It was not my original intention to compare the development process between the two boards but I did want to note the code, compile and deploy steps for the classic “Hello World”. Later I wanted to check that the Pico could handle all of the projects developed for Arduino in my book “Practical Arduino C” and more.


Yes - I installed the Arduino IDE on the Raspberry Pi 400 alongside VS Code and the Pico toolchain (just spreading that microprocessor love around).

Here is an Arduino version:

void setup() {
    Serial.begin(115200);
    while(!Serial){
        ;
    }

    Serial.println("Hello World");
}

void loop() {

}

and a variant for the Pico from the supplied Pico examples:

#include <stdio.h>
#include "pico/stdlib.h"

int main() {
    stdio_init_all();
    while (true) {
        printf("Hello, world!\n")
        sleep_ms(1000);
}
    return 0;
}

as that version has a pre-prepared CMake FILE:

if (TARGET tinyusb_device)
    add_executable(hello_usb
            hello_usb.c
        )

# pull in common dependencies
    target_link_libraries(hello_usb pico_stdlib)

# enable usb output, disable uart output
    pico_enable_stdio_usb(hello_usb 1)  
    pico_enable_stdio_uart(hello_usb 0)

# create map/bin/hex/uf2 file etc.
    pico_add_extra_outputs(hello_usb)

# add url via pico_set_program_url
    example_auto_set_url(hello_usb)

elseif(PICO_ON_DEVICE)

    message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in the SDK")

endif()

Of course, the automated Arduino toolchain deals with the inclusion of key libraries and "masks" the structure of a standard C program - all arguably user friendly features.

Installing and running the Arduino version simply requires the selection of board and port, opening the Serial Monitor and clicking the upload button. After the automated compile, build and upload, the legend "Hello World" appeared in the Serial Monitor window.

I used Visual Studio Code (on the Pi 400) to build the Pico version. I then connected the Pico to the USB port on the Pi 400 while holding down the BOOTSEL button; which then mounted the Pico as a USB mass storage device. I then used the file manager to copy the hello_usb.uf2 file from the build directory to the Pico. The program was then automatically loaded and run by the Pico which disconnected as a mass storage device. Normally, you would then use a program such as minicom (sudo apt install minicom; if not already installed) to connect to the USB port and display the output. As it happened, I already had the Arduino IDE Serial Monitor (version 1 IDE) window open and that worked just fine.

A Different approach

So that demonstrated the "official" Raspberry Pi approach to Pico C/C++ development.

How about using the Arduino IDE to develop for the Pico board? This article on the Drone Bot Workshop site shows you how to set up the IDE to program a Pico. This allowed me to quickly get the Arduino version of the infamous "blink" sample program up and running on my Pico on Windows without any trouble (which begs a few questions).

I then tried out the suggested code to connect the Pico W to my WiFi network. There was a bit of fiddling with the assigned port to get the program uploaded (warts and all here) but after an upload and a short wait the IDE Serial Monitor was soon displaying the IP address assigned to the Pico by my router. Note that the Serial Monitor says that it is not connected to a port even though it is happily displaying incoming text from the Pico. I switched it to the available COM port after uploading the program to capture the output but as this is not notionally connected to a board you get that message.


The Pico responded happily to a "ping" just as advertised.

There is no significant difference between the code used here on the Pico (via the Arduino IDE) and the code I used when exploring the Arduino MKR 1010.

Anyone with Arduino programming experience is going to find this approach much more comfortable than ploughing through the Pico C/C++ SDK and the Pico supplied example programs. I had not expected that when I set out.

Pushing the envelope.

I decided to try out some of my existing Arduino "demo" programs on the Pico. I started with a Sudoku solving program. The first version runs a test tackling 96 puzzles of increasing difficulty. When I compiled my Arduino code for the Pico I got two error messages. They both featured the words "error control reaches end of non-void function" and indicated two functions. One was declared as returning a bool and the other a uint8_t type. In reality, both functions always returned a value of the required type during execution but the compiler had no way of knowing that for sure and so I needed to add an appropriate return statement at the end of each. With those two small changes in place, the program ran happily (and fast) on the Pico.

Next up was a version of the sudoku program that renders a web page where a sudoku puzzle can be entered and then offers a service accessed using Ajax to solve any arbitrary puzzle. After all I was supposed to be testing a WiFi enabled board. This program project is built from 5 separate code files.

This is where I started to run into problems. The HTML and JavaScript being rendered to the browser ran to 120 odd lines of text of roughly 50 characters but it was clear that a great many lines were not making it. The web page repaired itself but the JavaScript was woefully incomplete. Obviously, the Pico would be executing the lines writing the text to the WiFiClient instance way faster than the Arduino MKR 1010 so maybe there was a bottleneck. Some experimentation found a workaround - by writing each line to the Serial object immediately after the client instance. This appeared to slow things up sufficiently for the web browser to receive the full set.

Looks like the client write buffer might be inherited from Print::write. Should I go off down the possible rabbit hole of finding and adjusting the buffer or go look at some other aspects of the Pico board?

Going further was going to need some studying of the C/C++ SDK documentation and much experiment. So, for the moment, I am leaving it there.

Conclusion.

If an Arduino board can deliver the speed, memory and functionality you need then you might want to stick with that format. The Pico though, probably represents the future with an amazing price/performance ratio.











Comments

Popular posts from this blog

Unicode output from an Arduino.

Arduino: How to scroll long text on OLED screen

Arduino Regular Expressions