Do you have a moment to talk about Our Lord and Savior, the ESP32?

The ESP-WROOM-32 'module'.

The ESP-WROOM-32 ‘module’.

By now just about every electronics hobbyist, embedded systems engineer, person interested in the ‘Internet of Things’, or anyone I can get to stand still for more than three minutes, knows about Espressif’s ESP32 line of absurdly inexpensive and frighteningly powerful ‘system on a chip’ devices. If by some strange chance you don’t, and it sounds like something relevant to your interests, buckle up!

First off, what is it?  In its raw form, it’s a small surface mount chip… But that chip then requires some external components to really work. (Static RAM, an oscillator, etc.)  Where it comes into its own as an embedded computing and IoT powerhouse however, is as a ‘module’. This is a small PCB with all the required components under an RF shield, with a built-in antenna. It then has pads all around the perimeter for soldering it into your design.

This potent little board is basically a tiny computer.  It has a dual-core 32-bit processor capable of operating at up to 240MHz, it has multiple serial ports, it has built-in full-featured Wi-Fi and Bluetooth Low Energy, a couple dozen I/O pins…most of which can be reassigned to use as a specific bus, a co-processor which allows it to sleep in an extremely low-power state—which we’ll discuss more later —and the best part? You can get them on Amazon for less than $5 a piece, with Prime…which of course means you can get them even cheaper if you buy directly from suppliers in China! …assuming you don’t mind the wait.

Three ESP-WROOM-32 modules.

Three ESP-WROOM-32 modules, in ‘tape & reel’ format. (Purchased as a 5-pack, I’d already removed the other two.)

The Toolbox

So what’re we lookin’ at here, feature-wise? Well! You better go grab a sandwich or something, this is gonna take a while.

  • 34 GPIO pins.
  • A 12-bit ADC which can be active on up to 18 pins at once, some of which can be assigned to a programmable gain amplifier.
  • Two 8-bit DAC channels which can be used to output variable voltage analog signals.
  • Ten capacitive touch-sensing GPIO, for making touch-sensing buttons or surfaces. (These pins cannot be reassigned.)
  • A wired Ethernet MAC 10/100Mbps twisted pair or fiber, sorry…no gigabit!
  • SD/SDIO/MMC Host Controller (For SD Cards, etc.)
  • Three UART interfaces, supporting IrDA, and all directly accessible by the DMA Controller or CPU.
  • Two I²C Bus interfaces. Standard or Fast mode. 7-bit or 10-bit addressing.
  • Two I²S Bus interfaces. Half- or Full-Duplex operation. Clock frequency from 10kHz to 40MHz. Supports 8-/16-/32-/48-/64-bit sample resolution on input or output. Dedicated DMA Controller for each bus. The master clock can be output to the DAC. (I’m assuming this means you can technically generate sound directly from this.)
  • Infrared Remote Controller. Supports eight channels of IR remote transmitting and receiving.  Programmable, can support various protocols. Has a dedicated 512×32-bit block of memory for storing incoming/outgoing waveform.
  • Pulse Counter
  • PWM
  • LED PWM
  • SPI Bus
  • Hardware Acceleration
  • CAN Bus, a message-based protocol, designed originally for multiplex electrical wiring within automobiles but also used in many other contexts, including industrial sensor networks.
  • Bluetooth LE Radio
  • WiFi Radio
That's a lot of pins!

That’s a lot of pins!

It really makes the Arduino boards I was working with look like some kind of tinkertoy. The ATMega168/328 are 16MHz 8-bit microcontrollers with 16/32kb of RAM, one UART, one I²C bus, one SPI bus…  The ATMega32u4 basically just adds on-board USB so it doesn’t require a USB-to-UART bridge to talk to a computer and upload new code without a dedicated programmer. The USB support also allows the ATMega32u4 to be programmed to act as a USB device, such as a USB HID (Keyboards, mice, game controllers, etc.), natively.

On-board USB is pretty much the one thing that the ESP32 lacks… However it can act as a Bluetooth HID, and it can be programmed OTA via WiFi with an appropriately-configured bootloader.

But let’s not stop at comparing it to other microcontrollers; When we’re talking about sheer computing power, the ESP32 tops every computer I owned from the day I was born in 1981 through my first Windows PC in 1995… Combined!

With Great Power Something Something

Now, you’re probably thinking “Yeah, but all that muscle’s gotta come at a price, right?” Well, guess what?! The CPU only consumes 30~50mA at full speed! Granted, using the radio eats up some power; The 54mbps WiFi can consume 190mA transmit, 100mA receive, and the Bluetooth-LE is 130mA/100mA…however I imagine the duration of that current draw depends greatly on how your code is written…I’m sure there’s plenty of ways to be economical about keeping the RF module powered up…

But then we get into the ESP32’s crazy low-power modes. Its co-processor allows it to go into a ‘deep sleep’ mode of just 150μA (That’s MICRO amps!) by turning off the CPU entirely and using the co-processor to poll the GPIO pins looking for whatever values or states your program is waiting for. That can be further reduced to 100μA by only polling at a 1% duty cycle. (Still more than good enough for physical inputs and all but the most sensitive of sensors.) There’s a final ‘deep sleep’ mode which just maintains the RTC and the contents of its memory, at the cost of just 10μA…  You can go full ‘hibernation’ where only the RTC itself is powered, for 5μA. Of course when I first read up on those last two I was like “Wait, then how does it…?” it turns out that the RTC can wake the chip up based on a predetermined timer, as well as a couple dedicated RTC GPIO pins that can wake it.

ESP32 (L) beside ESP8266 (R)

An ESP32 module beside its predecessor, an ESP8266 WiFi module.

Conclusion

It’s just one hell of a piece of hardware, yet it’s stupid-cheap, absurdly-small, and can run very very light on the power consumption.  Maybe at some point in the future I’ll make another post about applications, but as it is I started writing this in June 2018, so it’s been a year and I still hadn’t finished it. Time to just post the bloody thing! 😓

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Go back to top