ESPNOW - MQTT bridge

A project log for Fun with wifi repeaters

WiFi repeaters are getting super cheap now ($5!) and can contain quite open hardware. Try to make the most out of the QCA953X based ones.

biemsterbiemster 09/19/2023 at 19:220 Comments

After getting the more recent OpenWrt 21 running on the repeater, I decided to first try to get some useful functionality out of it. For quite a while I wanted a more hassle free way to get simple data from some sensors into my home automation, and since my favorite microcontroller is the ESP32 an ESPNOW to MQTT bridge was the logical subject.

This turned out to be actually quite straightforward, because there are already many many project that focus on either one of these two, although rarely together. My work is evolving in this repository:

and it is already able to forward all ESPNOW messages it receives to the MQTT broker, in an executable only 20kB in size! That is thanks to the toolchain that is produced when compiling the OpenWrt 21 firmware.

One thing not to forget though is that OpenWrt 21 has a bug in BPF filtering 802.11 monitor mode data, for this to work properly you need to disable BPF JIT:

echo 0 > /proc/sys/net/core/bpf_jit_enable

Or make this survive a reboot:

root@OpenWrt:~# cat /etc/sysctl.conf 
# Defaults are configured in /etc/sysctl.d/* and can be customized in this file

I'll update this log when I get the other direction running: sending out an MQTT message over ESPNOW.

EDIT: both directions are working now, with the small footnote that it is still capturing its own ESPNOW frames, and pushing them back over MQTT. This is not a deal breaker for me at the moment, but will probably become an issue when the bridge is under stress.

For now, it's running nicely. Keep in mind that the bridge sends out it's ESPNOW frames to the broadcast address, so have that configured as a peer if you want to receive them on your ESP32.