Comparison ESP8266 and Raspberry Pi Pico


ESP8266

  1. Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106
  2. Clock Speed: 80 MHz
  3. Single Core
  4. Operating Voltage: 3.3V  Input Voltage: 7-12V
  5. Digital I/O Pins (DIO): 16  one Analog Input Pins (ADC)
  6. UARTs: 1
  7. SPIs: 1
  8. I2Cs: 1
  9. PWM: Software
  10. 4 MB Flash Memory
  11. 64KM SRAM
  12. USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
  13. WIFI with PCB Antenna
  14. Programmed in C using Arduino IDE - and others**
  15. Landed cost $3.50 each for 5

Raspberry Pi Pico

  1. RP2040 microcontroller chip designed by Raspberry Pi in the UK
  2. flexible clock up to 133 MHz
  3. Dual-core Arm Cortex-M0+ processor,
  4. Operating Voltage: 1.8–5.5V DC
  5. 26 multifunction GPIO pins, including 3 analogue inputs
  6. 2 × UART,
  7. 2 × SPI controllers,
  8. 2 × I2C controllers,
  9. 16 × PWM channel
  10. 2MB on-board QSPI Flash
  11. 264KB on-chip SRAM
  12. 1 × USB 1.1 controller and PHY, with host and device support
  13. 8 × Programmable I/O (PIO) state machines for custom peripherals
  14. Programmed in Thonny using Micro Python **
  15. Landed Cost ~$10.00 each for 3
** Both can be programmed in C or python...

Resources

Code Hello World Pi Pico8gig

# Get the libraries we need
from machine import Pin, Timer

# Blink Speeds
blinkRate1 = .5  # seconds on/off
blinkRate2 = 2

# Instantiate and set the pins we are using.
led1 = Pin(25, Pin.OUT)  // On board led
led2 = Pin(15, Pin.OUT)  // External led

# Instantiate a couple of timers for the leds.
timer1 = Timer()
timer2 = Timer()

# Functions called when a timer expires
def blink1(timer1):
    led1.toggle()
   
def blink2(timer2):
    led2.toggle()

# Start the timers
timer1.init(freq=1/blinkRate1, mode=Timer.PERIODIC, callback=blink1)
timer2.init(freq=1/blinkRate2, mode=Timer.PERIODIC, callback=blink2)

Questions

Do the microcontrollers have any capabilities or functions that are not
available on the Raspberry Pi 4 or perhaps are superior to those on the
Raspberry Pi 4?  

Yes. For example Analog input.

In other words could a Raspberry Pi 4 be used instead of the microcontroller or is the Pi 4 missing certain controller capabilities and functions?

Yes a Pi can do most things that a microcontroller can do, but not all.

Perhaps the faster processor and larger RAM memory of the Pi 4 could be desirable in certain controller applications.

Yes and the Pi has a display and keyboard and lots of RAM and an infinite about of "disk" space, the full Linux OS etc. to allow you to mess with display input and interpret data.

The Raspberry Pi OS Linux operating system of the Raspberry Pi 4 has software overhead (daemons, processes, logging etc) that might delay its response as a control system.

This kind of answers the question. There are many process I/O applications that are not particularly time critical and a Raspberry Pi would work well. Time critical applications for example responding to interrupts to measure flow and sending pulses to control things like RF switches or LED lights may not work well when a multitasking operating system wanders off to do something else.

The next thing to consider is cost. A Pi 4 will cost about $70 a Pi 3 about $45. So the 5 microcontrollers I have spread around my backyard would be about $250 vs $20 for ESP8266s

Would the minimalist PiCore (Tiny Core Linux) operating system be more responsive or would it still have software overhead issues? (https://iotbytes.wordpress.com/picore-tiny-core-linux-on-raspberry-pi/) (http://www.tinycorelinux.net /ports.html)
As soon as you create a multitasking operating system there may be these issues.  There are real-time multitasking operating systems.  They are built paying a lot of attention to interrupt timing and task switching timing.  Examples QNX, FreeRTOS, VxWorks and perhaps even on the Raspberry Pi https://easychair.org/publications/open/VPzR.  

The question I have is why would you want to. A distributed system where small cheap microcontrollers are spread about feeding data into a mainframe (Raspberry Pi) to me makes a lot of sense. Each microcontroller is doing a small thing and passing data back and forth. No need for an operating system that may have other things to do.

We started implementing process control this way in the late 60s. I worked on a system that used a PDP11 as the mainframe. Display data gather and command sending. In the field we had Intel 8080 based microcomputers with lots of process input and output measuring and controlling flow, temperature etc. The connection back to the PDP11 was via a high speed serial connection. Similar to what today we call Ethernet, but this was before Ethernet. Each 8080 box and GPIO was in a 19 inch rack.
Can you suggest free software tools and libraries for developing a ‘bare metal” operating system for the Raspberry Pi 4. It would be desirable to have libraries available to access the GPIO pins, USB port, and other systems on the Pi. The bare metal operating system might be faster and more responsive than Linux in a controller application. I found the following link as a starting point. https://isometimes.github.io/rpi4-osdev/

Sorry no. I worked with this back in the 60s through the 80s, see above. I helped develop the software for the above 8080 systems. Today there is so much off the shelf hardware and software that I would rather use the plug and play approach.

And, if working on the iron interests you then please go for it. Somebody has to write the software that controls our cars and aircraft. And lord knows the aircraft folks need the help.