Goodbye Raspberry Pi - Hello ESP32

The chip crisis is on everyone's lips. The automotive industry delivers unfinished cars and graphics cards have either become massively more expensive or have not been available for months. The reasons for this are diverse and range from US sanctions to the corona virus to accidents such as major fires or snowstorms. In the meantime, many industries have been affected by the lack of semiconductors and the maker scene has not been spared either.

I was amazed when I recently wanted to buy a Raspberry Pi 3 A+ for the new Zykochron. In just a few months, the price has almost doubled. The situation is no better with the Raspberry Pi 3 B+ either. On the two diagrams from geizhals.at you can see the sudden increase in prices very clearly.

Raspberry Pi 3 A+ price development

 

Raspberry Pi 3 B+ price development

Of course, the Raspberry is still affordable, but the development still gives me food for thought. How far will that go? Will the Raspberry Pi 3 A+ and B+ still be available in a few months? The Raspberry Pi is not an industrial product and long-term availability of any particular model is not guaranteed. The crucial question now is, are there other options for me?

Alternatives to the Raspberry Pi

Aside from some experimentation with an 80535 microcontroller in the late 80's, I'm only familiar with the Arduino Uno and the Raspberry Pi so far. Once you start looking for other microcontrollers, you're presented with an almost unmanageable number of possibilities. This Wikipedia page, on which the individual brands and models are listed, offers a first overview. However, only those types that are referred to as microcontrollers are listed here. Apart from the Pico, the CPUs of the Raspberry models are microprocessors. The distinction between microcontrollers and microprocessors is difficult and basically not important to me as long as the required task can be fulfilled. After extensive research, I finally narrowed down the selection to the following boards:

  Pi Pico Pi Zero 2 W 3 Mod. A+ 3 Mod. B+ ESP32
DevKit C V4
Black Pill
STM32F411
RedBear
WiFi Mini
 Year 2021 2021 2018 2018 2016 2020 2016
 SoC RP2040 BCM2710A1 BCM2837B0 BCM2837B0 ESP32 STM32F411 CC3200
 Type Arm Cortex-M0+ (32 Bit)  Arm Cortex-A53
(64 Bit)
Arm Cortex-A53
(64 Bit)
Arm Cortex-A53
(64 Bit)
Tensilica Xtensa LX6 (32 Bit) Arm Cortex-M4 (32 Bit) Arm Cortex-M4 (32 Bit)
 Cores 2 4 4 4 2 1 1
 Clock 133 MHz 1000 MHz 1400 MHz 1400 MHz 240 Mhz 100 MHz 80 MHz
 Power 0,4 Watt 3 Watt .4,24 Watt 7 Watt 0.8 Watt 0,1 Watt 0,8 Watt
 RAM 264 KB 512 MB 512 MB 1024 MB 520 KB 128 KB 256 KB
 Flash 2 MB microSD microSD microSD 4 MB external 512 KB external
 WiFi - 2,4 GHz, 802.11b/g/n 2,4 u. 5 GHz 802.11ac 2,4 u. 5 GHz 802.11ac 2,4 GHz, 802.11b/g/n - 2,4 GHz,
802.11 b/g/n
 Bluetooth - 4.2 BLE 4.2 LS LE 4.2 LS LE 4.2 BR/EDR & BLE - -
 GPIO 26 26 26 26 34 16 27
 Analog 3 x 12 Bit - - - 2 x 12 Bit 1 x 12 Bit 4 x 12 Bit
 SPI 2 2 2 2 4 5 1
  I2C 2 1 1 1 2 3 1
 UART 2 2 2 2 3 3 2
 Price 9 Euro 28 Euro 40 Euro 75 Euro 5 Euro 15 Euro 40 Euro
 Available good bad bad bad good good bad
Microcontroller comparison


The table shows immediately that most of the models come from the Arm Cortex-A or Cortex-M family. Personally, I would have preferred a microcontroller from one of these families, since I have been interested in this architecture for a long time and due to its widespread use, there is a corresponding amount of literature. In the end, however, I decided on a completely different microcontroller, namely the ESP32 from Espressif.

The ESP32

Why did I decide to use the ESP32? As is so often the case, what matters are the requirements that the microcontroller must meet in general and specifically for controlling the Zyklochron. These include

  • Easy availability of development boards
  • Wi-Fi for time synchronization
  • Good development environment
  • JTAG debugger
  • SDK with detailed documentation and many examples
  • Interfaces like UART, SPI, I2C
  • Inexpensive

The Raspberry PI Zero 2 W meets all technical requirements, but is very hard to get at the moment. Also the fact that a complete Linux installation is needed for operation bothers me a lot. For many tasks this may be useful, but for the use as a microcontroller it is rather just ballast. The Black Pill board with the STM32F411 unfortunately, like most microcontrollers, does not support Wi-Fi. This is a pity, because this board was my favorite. Another option would be the CC3200 from Texas Instruments, but the development boards from TI and RedBear Labs are very hard to get and quite expensive.

Only one microcontroller really meets all the criteria and that is the ESP32 from Espressif. A search on Amazon or AliExpress yields a variety of available boards that can be bought for under 10 Euros. In addition to Wi-Fi and Bluetooth functionality, the ESP32 offers a lot of other features that make it a universal microcontroller for IoT tasks:

Core and memory ROM Cryptographic hardware acceleration AES SHA RSA RTC ULP coprocessor Recovery memory PMU Bluetooth link controller Bluetooth baseband Wi-Fi MAC Wi-Fi baseband SPI 2 ( or 1 ) x Xtensa® 32- bit LX6 Microprocessors RF receive RF transmit Switch Balun I2C I2S SDIO UART TWAI® ETH RMT PWM Touch sensor DAC ADC Clock generator RNG SRAM Embedded Flash or PSRAM Timers

CPU & Memory

  • Xtensa dual-core 32-bit LX6 microprocessor with maximum 240 MHz
  • Ultra low power (ULP) coprocessor
  • 448 KBytes ROM for booting and basic functions
  • 520 KByte on-chip SRAM for data and commands
  • 8 KByte SRAM (RTC SLOW memory) which can be accessed by the co-processor during deep sleep mode.
  • 8 KByte SRAM (RTC FAST Memory) code to be executed after waking up from Deep Sleep mode.
  • 1024 bits of EFUSE, of which 256 bits are used for the system and the remaining 768 bits can be used for custom applications.

Connectivity

  • 802.11 b/g/n Wi-Fi
  • Classic Bluetooth v4.2 and BLE

Peripherals

  • 34 programmable GPIOs
  • 12-bit ADC with 18 channels
  • 8-bit DAC with 2 channels
  • Serial interfaces: 4 x SPI, 2 x I2C, 2 x I2S, 3 x UART.
  • SD/SDIO/MMC host controller and SDIO/SPI slave controller
  • Motor PWM and up to 16 channels for LED PWM
  • 2 pulse counter modules
  • 4 timers
  • Remote Control Transceiver 
  • Hall Sensor
  • Secure boot and flash encryption
  • Hardware acceleration for cryptography

In the meantime there are a lot of development boards with the ESP32, partly equipped with a small display, flash memory of different size, connection for an external battery or other extras. I decided to use the ESP32-DevKitC V4 board, because it is completely sufficient for the beginning.

ESP32-DevKitC V4

You can even get this board for less than 5 Euros on AliExpress. You should only make sure to get the chip revision 3, so that you can use Secure Boot v2 if necessary. Due to the USB-to-UART bridge, you only have to connect the board to the PC via USB and you are ready to go.

Development environment

The ESP32 can be programmed in different ways. The most important environments are

  • Arduino IDE
  • Eclipse with the ESP-IDF Eclipse Plugin
  • PlatformIO (Visual Sudio Code)
  • MicroPython
  • LUA
  • JavaScript

I first started with MicroPython, but quickly switched to PlatformIO and use the Espressif IDF (IoT Development Framework) because it allows me to program as close to the hardware as possible. A good opportunity to brush up on my C skills from the past.

The change from Java in the client/server environment to C and a microcontroller is not an easy one though and requires some rethinking. In the meantime I am very enthusiastic about the ESP32 and programming in C is a lot of fun. There is still a lot to learn, which is made easier by the good documentation and the many examples. And the next goal is quite clear. Replace the Raspberry Pi in the Zyklochron with the ESP32!

Loading Conversation