- This ESP32-C3-powered project blocks 537,000 ad domains using just 50KB.
- Stores 5-byte (40-bit) domain hashes in flash and binary-searches them to avoid using RAM.
- Build your own $5 ESP32-C3-powered SuperMini ad blocker via GitHub.
As far as ESP32 projects go, this one is very cool. Developer ZedAxis (M-Abozaid on GitHub) created an ESP32-C3-powered gadget that blocks a staggering 537,000 ad domains using just 50KB. Even better, the device can respond to a blocked query in just 10 milliseconds (via Tom's Hardware).
Instead of a more traditional Pi-hole, which loads its entire blocklist into RAM, an ESP32 only has a few hundred KB of memory, and the ESP32-C3 used in this project doesn't have the 8MB of PSRAM found on higher-end models. To get around this limitation, ZedAxis hashed each blocked domain to a maximum of 5 bytes each (40 bits max).
These hashes are then sorted and written directly to the chip's flash storage. Then, when a DNS request comes in, the custom firmware hashes the request and performs a binary search. This means that the ESP32-C3's RAM never gets involved in the process. Overall, it's a pretty clever solution amid the ongoing RAMpocalypse.
You, too, can build your own SuperMini ESP32 ad blocker
The entire project is on GitHub
Since there's no DHCP server, it's unlikely that most people would want to replace this project with a more traditional Pi-hole. In this case, M-Abozaid says that they use their ESP32-C3-powered ad-blocking contraption when their Pi-Hole is rebooting or unavailable.
M-Abozaid's project is fully open-source under the MIT license and includes a Python script to build the latest hash table. The best part is that you can build one yourself using a $5 "SuperMini" ESP32-C3 microcontroller. All the details necessary to create your own pint-sized ad blocker can be found on GitHub.