ESP8266 Wifi Repeater and automesh

February 15, 2018 by richardvk

Filed under ESP8266

Last modified February 18, 2018

I recently discovered this video on YouTube and thought it looked like a really interesting idea! Especially since I recently bought a pack of 10 NodeMCU boards for about $27 – just because it was so cheap, not because i actually needed 10 of them! – and was wondering what the heck I was going to do with all these things!

I own a commercial WiFi repeater like this one which works pretty well, but what really interested me with the esp_wifi_repeater software, was the ‘Automesh’ feature. A quick skim through the README file on GitHub revealed “Sometimes you might want to use several esp_wifi_repeaters in a row or a mesh to cover a larger distance or area.”

Mesh networking is a really interesting concept. The idea is that in many cases you have only one fixed device like an ADSL , fibre or LTE modem (we’ll call it the gateway, as in ‘gateway to the Internet’) connected to a broadband Internet connection, but you have sensors and/or control devices ‘out in the field’ which require access to this connection but are out of range. Mesh networking lets nodes ‘bounce’ off of one another. That is, if at least one node has a good connection to the gateway modem, and that node in turn has good connectivity to a second node which is further away from the gateway and cannot connect to it directly, the first node will relay the traffic between the second node and the modem, effectively allowing the node which is out of range to connect to the gateway.

Now there is nothing stopping us from throwing a third node in the mix, and putting that node even further away than the second. It will effectively hop across two nodes to get to the gateway. That is, it has a ‘path’ through two nodes to the gateway.

This is a linear scenario, but the really cool thing with a mesh network is that the nodes don’t have to be in a line, they can be scattered all over the place. What makes this architecture really powerful is that if one node is lost – powers down or fails – other nodes which were relaying through that node will simply re-route their traffic via any other available path.

I wont get into the technical details of how this actually works, the underlying protocols can be quite complicated, but the point is that when I see the word ‘Automesh’ I think “Aha! This piece of software is going to take care of all of that complexity for me!” And indeed I was right. In fact, this software allows you to simply tick a checkbox and it takes care of the complicated inter-node communication all by itself. How awesome!

While there is a lot of software which can be compiled and uploaded to an ESP8266 board like the NodeMCU via the Arduino IDE or a tool like Atom and PlatformIO, the esp_wifi_repeater is a little more sticky. There is no ‘.ino’ file. Rather we need to compile the code ourselves and write the resultant ‘.bin’ files directly to the chip.

I spent a fair chunk of time reading through the esp_wifi_repeater docs, which led me to the esp-open-sdk docs (required to compile the esp_wifi_repeater code),  which in turn led me to the esptool docs (required to upload the code to the chip) – yikes! To make things more complicated, each of these has their own version of ‘How to install on Windows/Mac/Linux’.

Argh! Where to start?

Turns out its all really pretty easy. I did not try this on Windows, but I did try on both Mac and Linux (Ubuntu 16.04) and it worked like a charm.

A few notes then:

  • You do NOT need to compile the code to create ‘.bin’ files. The esp_wifi_repeater repository comes with a ‘firmware/’ folder which has two .bin files pre-compiled already in it, and these work just fine.
  • You then don’t need to go through what was for me a pretty painful experience trying to install the esp-open-sdk stuff – just SKIP IT – no compilation required!
  • Just install esptool. In both cases (Mac and Linux) it was a matter of installing the Python ‘pip’ tool (Mac: ‘sudo easy_install pip’, Linux: ‘apt install pip’) and then using pip to install the esptool software (‘pip install esptool’ for both Mac and Linux)
  • Then simply clone the esp_wifi_repeater repo into some folder, and change directory to the cloned folder. You’ll know if you are in the right folder if you have the file, and more importantly the ‘firmware/’  folder in your working directory.
  • Then just plug in your ESP and run this command: ‘sudo –port <usb_port> write_flash -fs 4MB -ff 80m -fm dio 0x00000 firmware/0x00000.bin 0x10000 firmware/0x10000.bin’
  • I have made the <usb_port> variable, because of course it depends on where your device is plugged in. On my Mac it was ‘/dev/cu.wchusbserial142’ or ‘/dev/tty.wchusbserial1420’, but my Ubuntu VM (on my Mac) saw the same port simply as ‘/dev/ttyUSB0’. So just replace with the port you need and off you go.
  • It looks like even though is runnable by any user, you should run the above command as root, as it requires access to the hardware to write to the USB device.
  • Finally the ‘write_flash -fs 4MB -ff 80m -fm dio’ portion was critical. I tried initially without this and its a show stopper.
  • As a side note, if you want to completely erase the flash, you can do this with : sudo –port <usb_port> erase_flash

Once all this business is taken care of, the device should reboot and you should see an SSID called ‘MyAp’. Simply connect to that and open a browser to – the devices default address. From there its pretty easy: enter you gateway SSID name, password, and tick the Automesh checkbox. The device will reboot again, and come up with the same SSID as your gateway.

Now heres the thing. Once this is done, you can’t tell the difference between your ‘real’ gateway SSID, or the SSID being broadcast by the node (the ‘repeater’). Of course thats kind of the point, right? You should be able to walk around anywhere inside the area that your mesh covers and see your SSID as if you were in range of your gateway. But how then do you connect to the web interface of the node if you want to make a config change? Well, the easiest for me was to bring up a terminal client (iTerm2) on my Mac, and run ‘ifconfig’ to check out what IP address my Mac was assigned. Assuming you know the DHCP range of your gateway modem, you’ll be able to tell if you are directly connected or not. If you took some time to look at the rest of the config page when setting up the SSID and Automesh config on the node, you may have noticed that it has a ‘Subnet’ field with a address. If your ‘ifconfig’ reveals you have an address in the 10.24.1.x range, then it means you are connected to the repeater and not the gateway – and I bet you didn’t even notice! How cool is that!

Now i have not (yet) tried this with multiple nodes, in either a linear or grouped mesh environment, only because i don’t have enough battery sources to scatter a bunch of NodeMCU’s all over the place, but trust me, I will :))

Related Articles


                          1. seaser

                            Thanks for this blog post. I also used the mentioned command on my Mac OSX 10.13.4 with the SiLabs Driver “CP210x Macintosh OSX VCP Driver 5.0.4” from It took me a while to make the driver work because I didn’t know that some USB cables are not made for data/serial connections.

                            To flash the NodeMCU is used following command with the downloaded firmware from github. It worked like a charm as you said!

                            sudo –chip auto –port ‘/dev/cu.SLAB_USBtoUART’ write_flash -fs 4MB -ff 80m -fm dio 0x00000 firmware/0x00000.bin 0x10000 firmware/0x10000.bin

                            I had the ESP tools already installed. Thus, no need for me to download it again. Thanks again buddy!

                            May 29, 2018 - 3:50 pm – Reply

                          2. guy

                            I tried to follow your blog, but receive a error message.

                            esptool write_flash: error: argument : [Errno 2] No such file or directory: ‘firmware/0x00000.bin’
                            The 0.00000.bin file is in the directory.

                            July 9, 2018 - 9:00 pm – Reply

                            • richardvk

                              HI there! Thanks for the comment and apologies for the delayed reply.

                              Did you manage to come right here? My devices have been in storage while I move house so I wasn’t able to test this again recently.


                              September 1, 2018 - 9:58 am – Reply

                          Leave a Comment