Wifi repeaters are getting very cheap nowadays, about 5 euro/dollar, and are quite easy to modify. And of course have built-in power supply! I want to test if these can be used as general purpose SBCs. They used to come with a RTL8196E which has good open source support, but lately they seem to have the QCA9533 which has great support in OpenWrt as well. My focus will be on repeaters like the one in the gallery.
Two goals of this project are:
1) Get support for the latest OpenWrt (it has only 8M ROM, so support might not reach "official" status)
2) Get some form of GPIO nicely broken out. This might get done via SPI or maybe the LED pins or something else I did not think of
I'll keep a list of links where to buy those repeaters with the QCA9533 from everyones favorite online mall in the first log.
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
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.
The hardware is not locked down almost at all, just a vanilla install of Lede. You could go through the setup as per the instructions that came with it and then connect over SSH, or you could solder the UART pins that are clearly marked on the pcb and connect to a PC (that's what I did).
The board draws very little power, my USB to UART stick had enough juice on the 5v pin to power it up. It shows the u-boot and Linux boot log over the standard 115200 baud. You can cancel the bootloader and drop in an u-boot shell, or let Lede fully boot and then press Enter to get a root shell.
Now there are two options:
1) Keep the current (perfectly fine) Lede install, and start modifying that. You'll need a 3rd part toolchain if you want to compile code for it, which can be found here:
Don't forget to use static linking (-static), because the C lib will not match. This means 0.5MB extra per application!
2) Compile OpenWrt and update. This will get you a bit newer kernel, but most importantly, a compatible toolchain! Here is a repo specifically for that (you could completely skip 'make menuconfig'):
I've also attached a firmware image made with this code, and the corresponding toolchain in the "Files" section here.
First time flashing this firmware will have to be done via the uboot console (Luci will not accept this sysupgrade.bin as it thinks it's for another device), with instructions here:
setenv ipaddr <make up an ip>
setenv serverip <tftp server ip>
tftp 0x80060000 openwrt-ath79-generic-embstar-squashfs-sysupgrade.bin
erase 0x9f050000 +0x7a0000
cp.b $fileaddr 0x9f050000 0x7a0000
setenv bootcmd "bootm 0x9f050000"saveenv
EDIT: apparently the openwrt 21.02 in the repo has an issue with bpf filters on wireless:
There are several vendors that sell this type of repeater for very low prices. Here is a list of links where I bought mine, and confirm that they contain the QCA9533 (but that is not a guarantee that yours will!)