Advertisement

The ESP32 is a low-cost, low-power, and ESPHome-compatible system on a chip microcontroller. It is the successor to the ESP8266 but not its replacement, as both are currently being manufactured. You can still buy ESP8266 boards, and they are being used in many ESPHome projects. In terms of raw power, the ESP32 has a few advantages over its predecessor, such as a faster CPU (160 MHz or 240 MHz) and, in most cases, two instead of one core.

Advertisement

For most, but not all, ESPHome projects, the upgraded CPU won’t make a significant difference. What can be used though is the ESP32’s on-board, dual-mode Bluetooth (Classic Bluetooth v4.2 and BLE), and some of its more advanced features. All in all, the ESP32 is much faster and more versatile than the ESP8266. Just like the ESP8266, the ESP32 supports the Arduino IDE, making it popular in the maker community.

Another significant improvement made to the ESP32, are the input/output options. While I will cover some of these in more detail in this article, it is worth noting that it has a total of 34 programmable GPIOs.

The ESP32 is, just as its predecessor, very affordable and can be bought for ~US$5 if imported from China. TSMC’s 40 nm process, which was first introduced in late 2008, keep production costs low and the chip in stock during these arduous times.

Following a thorough description of the ESP32 and its features, this article will also inform you on other members of the ESP32-XX family, including the RISC-V-powered ESP32-C3 and Bluetooth 5 capable ESP32-S3.

Which ESPHome projects require an ESP32?

Besides its Bluetooth capabilities, the ESP32 does have some further advantages over the ESP8266 when using it with ESPHome. These include the ESP32’s hardware pulse-width modulation (PWM), touch pad, digital-to-analog sensor (DAC), analog to digital sensor (ADC), and deep sleep capabilities.

ESP32 board

  • The successor to the popular ESP8266
  • Micro-USB port for easy flashing and powering.
  • Dual-core (Tensilica LX6), clocked at up to 240 MHz.

ESP32 Hardware PWM for lights and motors

When planning on controlling lights or a motor using pulse-width modulation (PWM), the ESP32 will do a much better job due to its hardware PWM capabilities. Similarly, the ESP32 also has a hardware pulse counter peripheral, making its pulse counter sensor much more accurate. On the ESP8266, both of these ESPHome components can only be implemented using less precise software calculations.

Advertisement

All ESPHome projects using PWM or a pulse counter should be realized using an ESP32. This includes projects such as Home Assistant Glow, and installations using dumb (i.e., non-addressable) LED strips.

Using Ethernet with ESPHome

A further component ESPHome supports is the Ethernet component, which is only available on the ESP32. Boards such as the Wireless Tag WT32-ETH01 support a wired connection to a network, making it more stable and potentially faster. Perhaps an even more interesting board is the LILYGO TTGO T-Internet-POE ESP32-WROOM (Buy on AliExpress), as it supports Power over Ethernet (PoE). The ESP8266 does not support Power over Ethernet, let alone Ethernet. A PoE ESP32 node makes sense if you want to provide data and power using a single cable.

Wireless Tag WT32-ETH01

  • An embedded serial port to Ethernet module based on ESP32 series.
  • Compatible with half-pad and connector through-hole design.

As your number of connected Wi-Fi devices increases, your Wi-Fi performance will suffer. Consumer access points will only support a certain number of connections before performance and stability takes a considerable dip. My suggestion is to always use a wired connection, if possible. Ethernet on ESP32 makes it easy to remove ESPHome nodes from your Wi-Fi network, by hardwiring them.

Advertisement

If your ESP32 only happens to support Ethernet but not PoE, but you want to restrict it to just using one cable, you do have the option of using a so-called PoE Splitter. These little boxes will separate the power and data lines and can be configured to output 5V, 9V, or 12V.

Creating capacitive buttons with the ESP32 touch pad

ESPHome’s touch pad component is also exclusive to the ESP32. With this component, the ESP32 can detect touches on any of the eight touch pads. This allows you to build capacitive buttons out of something as basic as aluminium foil. The functionality doesn’t end with capacitive buttons, you can go as far as building a leak sensor using this component.

Analog to digital (ADC) sensors in ESPHome

Even though the ESP8266 is capable of measuring voltage, it is restricted to only pin A0 (GPIO17). On the ESP32, pins GPIO32 through GPIO39 can be used to convert analog signals to digital readings. An example making use of this sensor is the ESPHome bed-presence detector using thin film pressure sensors.

8-bit digital-to-analog converter

The ESP32 can’t just read anolog signals, it can also generate them. The hardware digital-to-analog converter (DAC) on the ESP32 can output a real analog signal with no need for additional filtering.

Wake up from deep sleep using RTC pins

Deep sleep is an essential component when powering ESPHome nodes with batteries. When in this state, the ESP32 will turn off the Wi-Fi and Bluetooth baseband and radio, as well as the CPU.

All that remains active is the Ultra Low Power (ULP) co-processor and RTC memory, which will wake up the processor when something interesting happens. Using a programme stored in the RTC memory, the ULP can still access internal timers and sensor, and it can react to activity on any of the RTC pins, such as the push of a button.

Making use of Bluetooth and BLE using ESPHome

Despite all the above-mentioned components, the most significant addition to the ESP32 is the Bluetooth and Bluetooth Low Energy (BLE) radio. Using it, you can track BLE devices, such as a smartphone, with the functionality enabled in the Home Assistant app. Alternatively, you can turn the ESP32 in to an iBeacon and have your smartphone detect it. Both of these components can be used for presence tracking.

Connecting BLE sensors

There are a bunch of BLE sensors intended to be connected to a smartphone to gather data. By connecting these sensors to an ESP32 running ESPHome, the data can be imported in to Home Assistant and not just viewed in a device-specific app whenever you are in its vicinity.

These sensors include the RuuviTag, an open-source BLE sensor capable of measuring temperature, humidity, pressure, acceleration, and more. Two further similar sensors, the Inkbird IBS-TH1 and IBS-TH1 Mini, can also be used to keep an eye on a room’s temperature and humidity.

Reading Xiaomi BLE sensors with ESPHome

The widest range of compatible BLE devices come from the Chinese mega-company and number two smartphone vendor, Xiaomi. Included in the supported BLE devices are probes for measuring the state of the soil a plant is growing in (MiFlora), and even a smart plant pot (FlowerPot, Huahuacaocao, RoPot).

The Xiaomi LYWSD03MMC Bluetooth thermometer and hygrometer that can be integrated with Home Assistant using ESPHome on an ESP32.
Xiaomi LYWSD03MMC (Buy on AliExpress)
The Xiaomi LYWSD02 Bluetooth thermometer, hygrometer, and clock that can be integrated with Home Assistant using ESPHome on an ESP32.
Xiaomi LYWSD02 (Buy on AliExpress)
The Qingping Cleargrass Bluetooth thermometer, hygrometer, and clock that can be integrated with Home Assistant using ESPHome on an ESP32.
Qingping Cleargrass (Buy on AliExpress)

Perhaps more interesting is Xiaomi’s wide range of temperature and humidity sensors. What I like about these, is the fact they don’t just broadcast the data, but also display it on a screen, some of them even using e-paper. These sensors are great if you want to see the current state immediately, without having to open the Home Assistant app or viewing your wall-mounted tablet.

Gathering data from Xiaomi smart scales ESPHome

If you want to easily import weight data in to Home Assistant, you can do so by reading data from a Xiaomi Smart Scale (Miscale) or Mi Body Composition Scale 2 (Miscale2) to an ESP32 running ESPHome. The Xiaomi Smart Scale can measure the weight of multiple users and the second generation adds impedance, which can be used to roughly measure lean body mass, body fat, water, bone mass, and muscle mass.

The advantage this integration with smart scales has over others, is that it is local only. While you can integrate Fitbit with Home Assistant, the integration uses cloud polling. This means you are reliant on Fitbit’s API, which is now owned by Google and, as seen in the past, Google might one day decide to disable the API. Something similar recently happened to the Garmin integration, which has now been removed from Home Assistant.

The ESPHome BLE client

Finally, we have the ESP32’s capability to act as a BLE client when configured to do so with ESPHome. This allows an ESP32 board to read data from heart rate monitors (HRM), OBD2 car diagnostic adapters, tags, and other BLE-enabled devices. For a more in-depth look into this feature, I recommend reading this article describing it in detail.

ESP32 variants and ESPHome compatibility

Since the ESP32 made its first appearance, several variants have been produced, extending the ESP32-XX family. What I find most interesting about some of these variants, is that some of them use RISC-V CPUs. The RISC-V open standard instruction set architecture (ISA) is provided under open-source licences that do not require fees to use.

ESP32-S2 and ESPHome: No Bluetooth, single-core, and less SRAM

The ESP32-S2 is a single-core variant of the ESP32, with no Bluetooth capabilities and less SRAM. It does, however, use the newer Cadence Xtensa LX7 CPU, instead of the LX6. Despite having a larger package and offering more I/O and peripherals options, I wouldn’t recommend the ESP32-S2 for most ESPHome projects. The ESP32-S2 has been supported by ESPHome since Version 1.18.0.

SparkFun Thing Plus - ESP32-S2 WROOM

  • CPU: Cadence Xtensa Single-Core 32-bit LX7 Microprocessor and RISC-V ULP co-processor.
  • Storage: 320 kiB SRAM, 128 kiB ROM, and 16 kiB of RTC memory.
  • Input/output: 43 programmable GPIOs.

ESP32-C3 and ESPHome: RISC-V ESP8266 replacement

The ESP32-C3 is one of the aforementioned exciting new variants. It features a 160 MHz, single-core RISC-V CPU. Due to its low price and pin compatibility, the ESP32-C3 has already been titled the ESP8266’s replacement. While it only has 22 programmable GPIOs, it does support Bluetooth 5 which provides increased speed, range, and throughput.

ESP-C3-32S-Kit

  • Onboard ESP-C3-32S module that comes with a PCB antenna.
  • ESP-C3-32S-Kit Development Board based on Espressif ESP32-C3 SoC.
  • Onboard CH340, USB to UART converter.

Support for the ESP32-C3 in ESPHome is still in an early stage. ESPHome 2021.8.0 added alpha support for the chip, meaning it will take some time for it to be stable. I wouldn’t recommend the ESP32-C3 for ESPHome projects at this moment.

ESP32-S3 and ESPHome: More everything

The ESP32-S3 is a mash-up of the original ESP32 and the ESP32-S2. It features a dual-core Cadence Xtensa LX7 CPU, which can operate at up to 240 MHz, 384 kiB of RAM, and an additional 384 KiB of SRAM. Just as the ESP32-C3, it supports Bluetooth 5, but has 44 programmable GPIOs. As the ESP32-S3 was only announced on December 31, 2020, it isn’t yet supported by PlatformIO, on which ESPHome relies.

ESP32-C6 and ESPHome: Wi-Fi 6 support

An even newer addition to the family is the ESP32-C6. This variant has the same single-core 32-bit RISC-V CPU operating at up to 160 MHz, 400 kiB of SRAM, and 384 kiB ROM found on the ESP32-C3. It also supports Bluetooth 5 and 22 programmable GPIOs. What is new, however, is Wi-Fi 6 (IEEE 802.11ax) support on 2.4 GHz. Wi-Fi 6 supports a station interface, and it offers greater transmission efficiency and lower power consumption. The ESP32-C6 is currently not being sold to the public, and thus support for it in ESPHome shouldn’t be expected any time soon.

Use ESP32 mini boards with caution

Just as with the ESP8266, there are a number of mini ESP32 boards, including the LOLIN (previously WEMOS) S2 mini. I do not recommend using mini boards, if you are planning on connecting many sensors and switches to it. That is, if you are using a perfboard and manually soldering everything, such as I have done in all of my ESPHome projects so far. If you were to build or order a custom PCB, you should have none of the problems I’m about to mention.

An ESPHome-compatible mini ESP32 board with two rows of GPIO pins on either side.

The mini boards will have two rows of pins on either side of the ESP32 microchip. This keeps the board small and compact. However, it makes it very hard to connect further components using wires. Having the pins right next to one another, mistakes are more likely to occur, and you will need to know what you are soldering at all times.

ESP32 mini board (ESP-WROOM-32)
  • ESP-WROOM-32 module with onboard Wi-Fi and Bluetooth
  • Small size but fully featured

If you are planning on using the pins available on an ESP32, I recommend opting for a full-sized board, such as those based on the NodeMCU ESP32 development kit.

Why would anyone still buy an ESP8266 for ESPHome?

There are two main reasons to go with an ESP8266 over an ESP32 for an ESPHome project. Those reasons are pricing and size. As mentioned multiple times, the ESP32 can be bought at a very low price. But if you do not need the extra features an ESP32 offers, why pay those few cents more? Boards such as the ESP-12F and ESP-01 allow makers to build much smaller PCBs and these boards can come in even cheaper than, for example, the LOLIN D1 mini.

Advertisement
Liam Alexander Colman, the author and maintainer of Home Assistant Guides.

About Liam Alexander Colman

Liam Alexander Colman has been using Home Assistant for various projects for quite some time. What started of with a Raspberry Pi quickly became three Raspberry Pis and eventually a full-blown server. I now use Unraid as my operating system and Home Assistant happily runs in a Docker container. My personal setup includes many Zigbee devices as well as integrations with existing products such as my Android TV box. Read on to find out more on how I got started with Home Assistant.

Leave a comment

Advertisement