FAQ
TL;DR: "54 % flash used, all the results are correct" [Elektroda, dktr, #17264295; #16847583]. 1200–9600 baud verified, MAX3485 lets 3.3 V reach full RS-485 length. Inline Wi-Fi auto-reconnect added in v2.
Why it matters: this open-source bridge lets any PC or PLC talk Modbus-RTU over Wi-Fi with parts that cost under €5.
Quick Facts
• Verified baud rates: 1 200, 2 400, 9 600 bps [Elektroda, dktr, post #16847583]
• Flash footprint: 238 kB (≈54 % of 434 kB) on generic ESP-12 F [Elektroda, dktr, post #17264295]
• Typical current draw: 80–170 mA for ESP-12 F @ 3.3 V (*ESP8266 Datasheet*)
• MAX485 requires 5 V; MAX3485 works 3.0–3.6 V, 52 mA max (*Maxim DS3999*)
• socat command: pty,link=/dev/espS0,raw tcp:<IP>:8888 [Elektroda, dktr, post #16846354]
What exactly does the ESP8266 TCP-IP/RS485 converter do?
The sketch opens a Wi-Fi TCP server (default port 8888), wraps every byte received on UART0, and forwards it unchanged to the RS-485 transceiver; the reverse path works identically. Your PC sees a virtual serial port created by socat and speaks Modbus-RTU as if a local COM port were present [Elektroda, dktr, post #16846354]
Which baud rates are proven to work without errors?
Continuous overnight polling showed zero frame errors at 1 200, 2 400 and 9 600 baud [Elektroda, dktr, post #16847583] Users have reported stable 19 200 baud when DE/RE is handled in hardware delay circuits [Elektroda, byrrt, post #17047739]
Can I run the MAX485 transceiver at 3.3 V?
Yes, but range shrinks sharply because the output swing drops; keep cable length below 10 m [Elektroda, levy^, #16851429]. Replacing it with pin-compatible MAX3485 restores full-length operation at 3.3 V [Elektroda, george2002, post #16851575]
How do I compile and upload the project?
I see “ESP8266WiFi.h: No such file”. What’s missing?
The ESP8266 core libraries are absent. Install the ESP8266 platform through Arduino Board Manager or use PlatformIO’s “framework-arduinoespressif8266” [Elektroda, dktr, post #20320111]
How does the new auto-reconnect work after Wi-Fi loss?
Version 2 waits until Wi-Fi reconnects, then restarts the TCP listener. The MCU stays online, but any socat process must be relaunched from the host side [Elektroda, dktr, post #17032661]
Is there a Windows replacement for socat?
Yes—com0com + hub4com or the free “tty2tcp” utility create a virtual COM port and forward it to the ESP’s IP:8888 endpoint. Operation is identical to the Linux socat string (tty2tcp Manual).
How should I wire DE/RE on a Wemos D1 mini?
Connect RO→D7 (GPIO13), DI→D5 (GPIO14) and tie MAX3485 DE+RE to D2 (GPIO4). Ensure a 10 kΩ pull-down keeps DE low during reset to avoid bus collisions [Elektroda, pela222, post #21101804]
Do I need line termination and bias resistors?
At lengths under 3 m termination rarely improves signals, but once terminators were added the transistor-only DE trick showed severe undershoot [Elektroda, byrrt, post #17047739] Use 120 Ω at both ends plus 680 Ω pull-ups/downs for reliable multi-node buses (Maxim AN1090).
Can the bridge carry Modbus-RTU transparently?
Yes. Send a raw RTU frame over the TCP socket; the ESP adds no header. One user reads a WE-504 power meter by pointing Perl-MBclient directly at 192.168.1.87:8888 [Elektroda, zychzbig, post #21153086]
What happens if socat crashes during long polling?
The ESP keeps its socket open. Frames pile up until the TCP stack resets, causing a visible 1-2 s pause and dropped Modbus queries—an edge case fixed by auto-restarting socat every minute via a shell script [Elektroda, piterek-23, post #17043584]
Any quick test method without real RS-485 hardware?
Loop the ESP’s UART TX to RX and open two terminal windows on the virtual port: characters typed in one echo in the other, proving full duplex operation over Wi-Fi.
How much headroom remains for additional sensors or web UI?
About 195 kB flash and 49 kB SRAM stay free after compiling v2 on a 1 M flash module [Elektroda, dktr, post #17264295] “That’s plenty for an HTTP dashboard,” says contributor uzi18 [Elektroda, uzi18, post #16968894]
Edge case: Can long strings flip DE early?
On AVR, Serial.print() returns before UART empty, risking premature DE low [Elektroda, ditomek, post #16852120] The ESP8266’s FIFO releases DE only after the last byte leaves, so no truncation occurs [Elektroda, byrrt, post #16851892]
Comments
Is it something like esp-link? https://hackaday.io/page/1304-virtual-serial-port-tunnel-to-use-with-esp-link because esp-link has a lot of options, only the RS485 support is probably not implemented... [Read more]
Yes, it will be the same as ESPlink, in 1200,2400,9600 it works fine but requires changes in the code - serial.begin () I have nothing else with rs485 except this orno indicator, I polled the counter all... [Read more]
Does this converter work at 3.3v with esp? It shouldn't because they're at 5v. [Read more]
it should work, but at much shorter distances [Read more]
It is enough to replace it with the MAX3485 and everything in accordance with the art and ranges ;) [Read more]
On what basis do you calculate the time needed to control the RE / DE signal? Doesn't cut anything with longer thongs? [Read more]
Not supporting RS485 (DE signal) is not a problem: https://obrazki.elektroda.pl/5164797400_1511769306_thumb.jpg Proven - works, also in many production devices. Added after 1 [minutes]: ... [Read more]
on the first post, re_de is controlled from the ESP pin, so the diagram you pasted later does not make sense. By the way, I use a similar one myself in my projects. I am asking this because in arduino... [Read more]
And how to select elements when UART works at the 3V3 level? MAX485 to MAX3485, what about the rest? [Read more]
what about the rest? stays the same ... [Read more]
I meant the transistor and resistors because the entire power supply will change from 5V to 3V3. If nothing needs to be changed that's great, but I preferred to ask. Thanks, I'll be testing soon... [Read more]
There is an esp-link latka with rs485 support, you have to look at repo / issue [Read more]
Gentlemen, everything works great, but ... but there is a small problem ... If, for example, I reset the router, ESP loses the connection and can not reconnect - just do ESP reset and everything is OK... [Read more]
Are you talking about the software from 1 post? [Read more]
Yes. [Read more]
I made a fix, after breaking the wifi connection, the program waits for reconnection and resumes work. [Read more]
Hello, I also use this converter. I get an error compiling this new version es-rs485: 19: error:'earchwifi 'was not declared in this scope How can I fix it? [Read more]
I think I broke something and I didn't attach this file, but the one from this attachment compiles without error. Another thing is that ESP itself will reconnect to the network and will work, but... [Read more]
Already ok. New version of arduin ide helped. Thanks [Read more]