Browse Category

Embedded

The embedded category – all about embedded programming.

ESP32 Wroom module.

The ESP32 – why it’s so cool?

What is this at all?

The IoT. Nowadays it’s almost the most fashionable and sexy word in the world. The Industry 4.0 – almost same popular as the IoT – despite that no one knows what it exactly means (but – looks great on the marketing brochures) – but I feel that the ESP32 fit’s here perfectly.

If we want to create some device which do something more complicated than light the bulb on or off (but believe me the ESP32 can do this like a pro as well) we can use this microcontroller. It has a WiFi communication, the Bluetooth communication and a lot of horse power to do very complicated stuff. 

Why it’s cool?

The ESP32 is cool. Why? Because it’s cheap, on aliexpress you can buy a complete evaluation board for about 2$. It’s powerful – has a dual-core processor operating at 240 MHz. It’s low power – in sleep mode takes 10 uA which means that it can sleep for it means that on a single 18650 battery it can last about 32,5 years (assuming the capacity of the battery is 28500 mAh). The documentation (https://docs.espressif.com) is outstanding and very understandable. And last but not least the community which unites experienced embedded programmers.

Why it’s not so cool?

Like everything, it has its downsides. The IDF-SDK it’s a little (but only a little) harder than ex. Arduino. It may not be ready for commercial products – it’s stable, every new update of SDK is better and better but this chip is quite new, there is no big-scale study of stability.

Why is worth to learn about ESP32

The programming of the ESP32 is the same programming like in professional products which we can’t say about Arduino IDE (please don’t read me wrong – I believe that the Arduino still is a good entry point to people who starts his journey in embedded programming or for scientists which need to prototype something fast).

In short time the new ESP32-S2 chips will be available which I believe they will fit the professional requirements and will be more secure than the previous version.

The hardware

As I wrote in the introduction, the ESP32 is powerful, cheap and low power. Please check the most important raw information below:

  • Core: Xtensa® dual-core 32-bit LX6 microprocessor up to 600 MIPS
  • ROM: 448 kB (but it’s used for booting and core functions. We don’t want to touch that.)
  • RAM: 520 kB
  • RTC RAM: 8kB (it’s called the RTC FAST and it’s nice because we can store there some data when we go to sleep)
  • RTC RAM: 8kB (it’s called the RTC SLOW and it’s not so nice because it’s used co-processor during the deep sleep mode and we can’t do anything with it)
  • eFuse: 1kB (256 bytes are used by the system for some stuff like keep the MAC address, but the rest of it – the 768 bytes are available for the user – it means you.)

That’s the most important parameters of ESP32 core. As you probably noticed there is no mention of flash capacity, and you’re right. There is a need to use external flash but don’t worry – the modules which we will use have integrated flash memory – more in the next sections. The more detailed data about the core processor can be found in the datasheet.

The core

The ESP32 uses the Xtensa® dual-core 32-bit LX6 microprocessor. It has two cores working at 240 MHz and both of them can be used for user tasks – but remember, that one of the cores is used to execute the core stuff like using the WiFi, Bluetooth communication, etc. as well.

The flash and the RAM

The processor handles the external FLASH and SRAM memory. It’s possible to map the 16MB of FLASH and this memory can be mapped into CPU instruction memory space which means that we can simply use it as internal processor flash memory without additional software to communicate with the external device.

The device has 520 kB of built-in SRAM. It’s a lot of memory and it’s enough for most of the tasks (even quite complex) but this memory can be extended up to 8 MB but unfortunately – it can’t be used at the same time – we can use the only 4MB at the time – but we can shuffle them.

The connectivity

The ESP32 has the WiFi and implements TCP/IP and full 802.11 b/g/n standard. It works on 2.4 GHz frequency. In normal we can reach about 20 Mbit/s for TCP/IP connectivity. More details can be reached here.

It supports the Bluetooth in up to class 3 nothing cutting edge (the low power Bluetooth starts at class 4 but it’s onboard and we can use it in three modes:

  • UART HCI – which allows to use it like the “normal” UART but over the air,
  • SDIO – which works like the SPI device,
  • PCM – as I2S audio interface which is nice to use with audio devices like headphones etc.

The peripherals

This chip offers a ton of peripherals which can be used for numerous applications:

  • SPI (Serial Peripheral Interface)
  • I2C (Inter-Integrated Circuit)
  • I2S (Inter-IC Sound)
  • SDIO (Secure Digital Input Output)
  • UART (Universal async. receiver-transmitter)
  • CAN (Controller Area Network)
  • ETH (Ethernet MAC)
  • IR (Infrared)
  • PWM (Pulse Width Modulation)
  • Temperature sensor
  • Touch sensors (ten captive sensing inputs)
  • DAC (Digital to Analog Converter)
  • SAR ADC (Successive approx. analog to digital converter)
ESP32 function block diagram
ESP32 function block diagram

Comparison

Compare ESP32 to most popular in similar class microcontrollers (Arduino and Blackpill).

 ESP32-WROOM-32Arduino NanoSTM32 Black Pill
Core:Xtensa® dual-core LX6ATmega328STM32F411CEU6
Architecture:32 bit8 bit32 bit
Clock:2x 240 MHz16 MHz100 MHz
SRAM:520 kB2 kB128 kB
Flash:4 MB32 kB512 kB
Connectivity:WiFi + Bluetooth
Power cons.   
Voltage:3.3V5V3.3V
Operating at max:35 mA – 68 mA (116 mW – 224 mW)9.2 mA (46 mW)23 mA (75 mW) ***
Power per. MHz73 uA – 142 uA (241 uW – 469 uW) 575 uA (2,9 mW)230 uA (759 uW)
Price:4.26$2.09$4.46$
Popular microcontrollers comparison.

*** It’s a running processor witch partly powered peripherals.

Please look at it as approximations which are the result of mixing data sheets information and some assumptions like not all peripherals are running at the same time etc.

The prices was checked on alliexpress at popular sellers.

Of course, all this comparison doesn’t mean that from now you should use the ESP32 everywhere.

For example:

  • if you are experienced embedded developer and want a small, cheap, well tested and used in industry microcontroller to drive ABS in the car – STM is the answer,
  • a fancy device used in the home for flower pots moisture measurement powered by small solar panel and store history of in the database on RPi or in cloud services – I would go with ESP32.
  • If you start your programming journey and want to light the LED up or check how peripheral like ADC works – use Arduino as an entry point.

Remember: right tool for right thing.

The SDK

ESP32 SDK is pleasant and well designed. It consists of modules that can be configured using menuconfog which is a tool based on ncurses library well known from kernel or buildroot configuration.

Using SDK for creating your own ESP32 modules is a big deeper topic and I will show you how to do this in another entry.

How to prepare environment

Setting up the environment is nice, easy and described in details at: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/

Thats all folks

Thanks for reading. If you have any suggestions or questions please let me know in the comment below.

Best regards and use ESP32.