Transparent ESP8266 WiFi-to-Serial Bridge

These days, connecting your microcontroller project to a WiFi network is pretty easy — you connect up an ESP8266 to your microcontroller project and pretend it’s a WiFi modem, using these old-school-style AT commands. But what do you do if you need to flash new code into the microcontroller? You can’t reprogram the micro remotely through the ESP8266 because those stupid AT commands get in the way.

The solution? By flashing the esp-link firmware into your ESP8266, you talk directly to the microcontroller over WiFi as if it were connected by a serial cable: the ESP8266 becomes a totally transparent WiFi-serial bridge. Now, with a serial bootloader and an ESP8266 in Wifi-to-serial bridge mode, you can reflash your microcontroller wirelessly, and then telnet in to interact with and debug the system remotely. Once you’ve fixed the bugs, you can re-flash the microcontroller: all over WiFi, without having to climb up a ladder to reach your IoT attic-temperature sensor.

To flash a connected Arduino, for instance, all you need to do is convince AVRDUDE to use the network instead of a locally-connected USB-serial cable: avrdude -p m328p -c arduino -b 115200 -P net:192.168.1.123:23 -U:yourHexFile.hex. The ESP8266 passes the data straight through its TX and RX lines to your microcontroller and everything works as if it were wired.

Configuration to allow the ESP8266 to join your WiFi network takes place on a self-hosted webpage that uses [Sprite_tm]’s esp-httpd standalone server, which makes setup pretty painless. And then after that you can simply telnet to the ESP8266 at port 23 and type away, or do anything else you would with a wired serial connection.

Although the simple bridge mode came first, esp-link looks like it’s growing to be a one-stop shop for all your IoT or microcontroller + WiFi needs. In addition to the serial bridge code, there is also a REST-based microcontroller-to-internet mode and there is bi-directional MQTT support in the wings. We haven’t had a chance to dig into these yet, so if you have, let us know in the comments.

If you want to dig in deeper, head over to [Jeelabs]’ blog for a slightly outdated tour of the project written by the code’s author, [Thorsten von Eicken]. For the most up-to-date development news, follow the very active development of esp-link in this thread on the esp8266 forums.

57 thoughts on “Transparent ESP8266 WiFi-to-Serial Bridge

  1. Wow. Not only this, it also makes a RS485-WiFi bridge for a fraction of a commercial cost – just add a transceiver with direction auto-detection. Shame I don’t have an ESP on my hands right now, I’ll have to build a long RS485 transmission line with many sensors the day after tomorrow and it’d seriously rock to debug it wirelessly, or make a simple extension without adding 30m of wires for a single sensor.

        1. No, it made 15 vs 100+ eur for a box that did the same, installed with some machines, still working 4 years later.
          Add a box and power supply to your ESP and you will not save that much, if you still want to stay with the same application. Add WiFi vs Ethernet issues and I would still use a router if I had to do it again.
          Different applications call for different approaches, of course, but it is not like before the ESP you could not get something on-line for reasonable low cost.

      1. The board in those links is essentially a Uno with the ATMega replaced by an ESP8266, everything else, including the USB to UART circuit. Which means it won’t work with any libraries that access the Arduino hardware directly. What Christopher is talking about is adding an ESP8266 to a Pro Mini, which is currently missing the UART circuit but might have enough room for an ESP8266 on its underside. Such a board would be truly Kickstarter-worthy.

        1. @#$%^ ignore the “everything else”. Hackaday, when are we going to get an edit button? You have some of the best minds on the planet reading this blog, surely you can find someone capable of doing a little PHP scripting for you…

          1. Hackaday is a WordPress based site (although you wouldn’t know it to look at it). So I guess that hacking the commenting system isn’t that trivial – it’s probably some add-on written by someone else.

        2. Adding an ESP8266 just to serve as a serial wireless bridge to an 8-bit AVR seems a bit of a pointless waste, though.
          The ESP8266 is more powerful than the “main” microcontroller! Why not just use the ESP8266 itself to run your application?

          1. Exactly. Only 1 ADC, no hardware i2c, greatly reduced PWM, no 2-wire…the list goes on and on. My current project is a WiFi 3d printer controller which is why I’m so interested in the Pro Mini/ESP8826 combo (it’s what I’m currently using myself); the ESP8826 wouldn’t have the GPIO/ADC pins let alone support for any of the low-level hardware code in Teacup. It’s a much more powerful chip, as you say, but it was built for a specific application and it’ll take time for many of existing libraries to be ported. A Pro-Mini/ESP8266 combo, on the other hand, is doable right now and would require nothing more than a PCB design.

          2. @Myndale I remember seeing some (not arduino user so i did not bother remembering where) but my best bet is that you can make a simple pcb to connect the 2 together. it should be small enough to fit multiple of them in the 5×5 smallest PCB batch.

  2. Thanks for posting!
    I actually was getting ready to duplicate this capability tonight. Glad I procrastinated and checked hackaday first!
    Using it on an evaluation board to test out the BNO055 on a robot. This will let us evaluate the sensor and monitor data remotely, real-time witout having to write any code for our ultimate target.

    Quick demo: https://youtu.be/ssxibpOCFhI

  3. bit.ly is not a mask its an awesome tool to see where your traffic is coming from… and considering 80% of visitors are new visit the site daily, its not that known YET…. and running a site for free and putting the massive amount of time and effort into it that I do and get this type of response…

    1. Richard, I appreciate your effort and I’m glad that the esp8266.com website exists, I’m sorry if I sounded too harsh. I can understand the need to advertise the site, but using url shorteners is usually seen in a bad way (spammy) in comment threads and when I see one I just avoid clicking on it.

      1. Never really saw it that way! I just hate trying to link to my content with huge URLS…. hmm I will rethink this strategy! Or I just make my own short URL code on esp8266.com and then voila problem solved! I have added some shortened once but I rewrite .htaccess by hand to do it :-(

    2. Don’ make it look like you are running a charity, You have ads setup on esp8266.com and so you do get ad revenue from running that site and putting a useless comment on every HAD thread about esp8266 linking to your site is your way of promoting your site.

      The discussion link that you had put in your comment was already given in the main article, So what was your point of putting it again ? I doubt you even read main post completely before proceeding with your regular ritual of putting a comment on every esp8266 hackaday post.

  4. Advertising, what am I selling? This is an awesome site for ESP8266 people and the bit.ly link was a direct link to the massive thread dedicated to this exact article. I encourage people with any project to talk to me about it and see if we can get a dedicated area setup for it…. not many other sites are so inclined…

    1. I avoid shortlinks as far as possible. You do not know where they go. From this point of view Richard’s post is no advertisement, just an ugly cryptical text string :-)

      1. Sorry this is a little late, but just for future reference, you can add a + to the end of a bit.ly link and it’ll take you to a page which allows you to see the destination and when people have been clicking on it.

  5. I am terribly behind on all the info about esp’s. The last one I had got pretty hot and I think it had quite an amp draw (~150mA?).
    Are there any “low energy” versions yet?
    Is there a comprehensive guide to the various types and recommendations which not to buy?
    I have a couple of the very basic ones I got when the esp craze began.

    1. The power consumption is going to be somewhere between 20-70mA with spikes to 300mA when transmitting. I think that’s pretty typical for any wifi radio.
      In terms of which module types to get, the esp-12, esp-13 and wroom-02 versions have much better RF than any of the others. Also, PCB antenna typically beats ceramic antenna. I see 10dB better rssi using a -12 over a -03. I would get the -12e or the newest -12f (hard to find in the US right now). These have all the gpio brought out and good RF.

      1. This is great.

        Very helpful indeed. it’s good to hear someone’s experience with the different module designs. I had assumed the ceramic ones were best. oops

        Thanks for the info.

    2. there is a “low energy” mode which is supposed to periodically wake up on a synchronized time with the router telling it if there are any packets. You need a router capable of that and I am not sure if anyone used this mode so far…. it is supposed to average ~1mA if no data is transmitted or received.
      other than that you are left with shut-down modes which mean device reinitialization and WiFi connection every transmission.

      1. There is what’s called “modem sleep”, which uses the Wifi DTIM interval (supported by almost all APs) to turn the receiver off for several beacon intervals (100ms) at a time. While the esp is in that mode, it uses ~20mA. When the receiver is on it uses ~70mA. Going down to ~1-2mA requires turning the processor off, i.e., really just keeping memory and a timer powered and so far I’ve been unable to get into that mode. I believe that as long as there’s a peripheral enabled (such as UART) it can’t go into that mode ’cause there’s nothing to react to any input on the peripheral.

        1. right….i thing i was remembering the TI chip.
          Personally i don’t find the ESP that suited for low power. It takes long to start(~0.5 seconds) and connect to wifi, so anything battery operated has to require very occasional data transmission and deal with big delay.

  6. I’d love if there were a wired version of the ESP8266. Wireless isn’t always the best option and doesn’t work with all wireless networks, and then one could mix-and-match depending on usage and location. (Yes, I know, there are other Ethernet chips like the Enc28j60, but then you have two code bases)

    1. It is highly unlikely that somebody will do that, the END is there and performs really well. I don’t think there is a market for Ethernet connected low complexity devices any more. I do agree that most problems are easier to solve via Ethernet.

  7. I’m trying to use port tcp/2323 to provide html to the browser, problem is that after outputting the code through Serial.println() the Arduino is not able to close the tcp connection and the browser keeps loading… any idea ?

  8. I flashed transparent bridge 2 binary files in my esp (01) module and it was done successfully but i dont find the wifi network of my module in the taskbar.
    Could you assist me!

  9. Everything is nice, but do you have a FULL working program with a schematic. I am new to ESP, and i would like to have a full project to replace my RS232 and RS485 with ESP connection. I will build it and LEARN from there.
    Thank you

  10. I would like to make the following communication ArduinoTX->ESP8266->ESP8266->ArduinoRX. I can do it with Xbee’s but they are expensive. Ha anyone seen a prebuilt ESP firmware to do this?

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.