logo elektroda
logo elektroda
X
logo elektroda

How to replace the cable with WIFI communication in ESP32 between RS485/RS232?

globalinfo 8067 23
Best answers

Can I replace an RS485/RS232 cable with an ESP32 and Wi‑Fi communication between remote devices?

Yes — you can bridge RS232/RS485 over Wi‑Fi with ESP32 boards, for example by using ESP-Now-Serial-Bridge or a UART bridge solution [#21008140] For ESP-NOW, set one board as BOARD1 and the other as BOARD2, then enter each board’s MAC address into the other board’s RECVR_MAC setting [#21009054] The thread author reported that this setup worked in both directions after that [#21009417] A later test confirmed a stable bidirectional USB↔ESP32↔RS232 link running for 2 days without problems [#21011771] The inverter side was configured at 9600 baud to match the device sending data [#21013246]
Summary generated by AI based on the discussion content.
ADVERTISEMENT
This content has been translated flag-pl » flag-en View the original version here
  • #1 21006622
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    Hello,

    I have remote devices that communicate over RS485 or RS232 can the cable be replaced by an ESP32 and communicate over WIFI between these devices?
    Very please give me a hint.

    Device communication diagram using ESP32 and Wi-Fi. .
  • ADVERTISEMENT
  • Questioning the need to replace RS485 with WiFi

    #2 21006714
    JacekCz
    Level 42  
    Posts: 8670
    Help: 760
    Rate: 1463
    Like everything in IT "it depends"

    Distance, critical impassable delay, obstacles and a few more questions. Serial works at the byte level, networks at the packet level.
    I know of an installation that moving away from RS485 would break acceptance, approvals, legal and tax dimensions.

    You have "something that works" so the general engineering answer is: don't change.
    If there are any problems you enter, what are they ? What are you motivating the idea with ?
  • ADVERTISEMENT
  • #3 21006900
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    The installation is private and mine so there should be no problems.

    Quote:
    If there are any problems you are running into, what are they ? What are you motivating the idea with ?

    I would like to be able to connect e.g. a laptop via USB and communicate remotely without having to stand at the device with it.
    I would also like to collect data remotely without having to run wires.
  • ADVERTISEMENT
  • ESP-Link may not work on ESP32; Bluetooth may be better

    #5 21007216
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    tcm3105 wrote:
    Easiest solution: ESP-Link

    Will it work on ESP32 because in the description it is:

    Quote:
    The esp-link firmware connects the microcontroller to the Internet via the ESP8266 Wi-Fi module. It implements a number of functions:

    Unfortunately I don't have an ESP8266 but have a lot of ESP32.

    Added after 42 [minutes]:

    JacekCz wrote:
    As with everything in IT "it depends" ...Serial works at byte level, networks at packet level....


    And maybe Bluetooth would be better?
  • Serial works at byte level, networks at packet level

    #6 21007260
    JacekCz
    Level 42  
    Posts: 8670
    Help: 760
    Rate: 1463
    globalinfo wrote:
    I would like to be able to connect e.g. a laptop via USB and communicate remotely without having to stand at the device.


    Another "content" thread.
    You are crooked once again. First you suggested that the solution supposedly works, now that you don't have wires.
    What distance you were also asked.
    Some things will still be achievable on raw low-level Wifi, but others already require higher layers of internet, and that narrows the area of compatibility

    Added after 1 [minute]:

    globalinfo wrote:
    JacekCz wrote:
    As with everything in IT "it depends"

    ...Serial works at byte level, networks at packet level....


    And maybe Bluetooth would be better?


    And what, BT doesn't work packet-wise ? Anyway, already consumer BT is known for its delays.

    The more you hide, the less effectively you will get the correct advice.
  • ESP32 Wi-Fi link for inverter data polling

    #7 21008114
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    And what am I hiding here, I vaguely write because I have some ideas and I thought it would be simple for me.
    Distance of about 8m through two walls - at the moment I do not pull cables, just connect at the inverter - I can download data every 5min.
    Ideals:
    - I also have a USB/RS485 converter so it was easiest for me to write about RS485 communication.
    - to start with the connection to the inverter via WIFI (currently I connect to the inverter from my laptop via a program via USB - TTL/RS485 converter - RS485 in the inverter
    - I can also with the same program via USB connect to the inverter via RS232.

    This is the whole secret.


    I have several ESP32 so WIFI, Bluetooth is involved.
  • ESP32 MAC address prints but bridge stays disconnected

    #9 21008711
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    xury wrote:
    You can and in many ways. It is very simple e.g.:
    https://github.com/yuri-rage/ESP-Now-Serial-Bridge ....


    Thank you very much for the good idea.
    Now I'll have a little trouble.
    In the Arduino IDE 1.8 I managed to compile and upload on 2 ESP32 (I assigned ESP and Mac number )
    
    #define BOARD1 // BOARD1 or BOARD2
    #define RECVR_MAC {0x94, 0xB9, 0x7E, 0x**, 0x**, 0x**}
    

    But I think it doesn't connect because after running on Serial monitor it displays:
    Quote:


    ESP32 MAC Address: 94: B9: 7E: **: **:**
    0

    Nothing else - after resetting one or the other ESP continues to display the same thing.
  • #10 21008735
    JacekCz
    Level 42  
    Posts: 8670
    Help: 760
    Rate: 1463
    globalinfo wrote:
    #define RECVR_MAC {0x94, 0xB9, 0x7E, 0x**, 0x**, 0x**}



    one of the ugliest C macros I have seen.
    This really can be written cleaner.
  • #11 21008756
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    I like :)

    Added after 1 [hour] 31 [minutes]:

    I have a question, the description for ESP-Now-Serial-Bridge includes this information:
    Quote:
    Set the IP address of the OPPOSITE board as the RECVR_MAC value in the macros at the top of the sketch.


    I don't really understand where I need to fill this in.
  • Helpful post
    #12 21009054
    xury
    Automation specialist
    Posts: 7078
    Help: 878
    Rate: 1494
    I understood it like this
    You define one as BOARD1 and the other as BOARD2
    You enter MAC addresses (not IPs as described probably incorrectly) alternately. So in BOARD1 you enter the MAC from BOARD2 and in the other one vice versa.
  • ESP32 boards linked by MAC addresses

    #13 21009417
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    xury wrote:
    I understood it like this
    You define one as BOARD1 and the other as BOARD2
    You enter MAC addresses (not IPs as described probably incorrectly) alternately. So in BOARD1 you enter the MAC from BOARD2 and in the other one vice versa.


    It works great both ways.

    Thank you very much for your help.
    :please: :please: :please:

    Now I will try some more:
    https://mongoose.ws/documentation/tutorials/esp32/uart-bridge/
  • #14 21011771
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    Tests completed successfully.
    ESP NOW has been working for 2 days with no problems.
    Here are the results of the USB <-> ESP32ESP32 <-> RS232 bi-directional connection.
    Screenshot of Samil Power Co., Ltd. software displaying inverter data. .
  • #15 21013237
    xury
    Automation specialist
    Posts: 7078
    Help: 878
    Rate: 1494
    Well, that's great. What baudrate is it running at?
  • #16 21013246
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    I set 9600 - the same as the inverter sends.
  • #17 21031204
    margas60
    Level 8  
    Posts: 230
    Help: 1
    Rate: 7

    Tell me how you did it, because I'm trying to do the same thing and it came out a mess.
    This Arduino environment is twisted somehow.
    I have an ESP8266 and an RS232 converter board.
    #include
    #include
    #include
    where to take this from and how to add it to the program?
  • ESP-NOW setup with board MAC addresses

    #18 21031735
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    margas60 wrote:
    Describe how you did it because I'm trying to do the same thing and it came out a mess.
    This arduino environment is twisted somehow.
    I have an ESP8266 and a RS232 converter board.
    #include
    #include
    #include
    where to take this from and how to add it to the program?.


    Describe exactly what doesn't want to work - what errors, which version of Arduino IDE.
    For me on 2.3 didn't compile so I used the portable version
    https://forum.arduino.cc/t/tutorial-how-to-in...ortable-version-of-arduino-ide-1-8-19/1205125

    First upload and run ESP NOW programs on 2 ESP8266 and test sending and receiving on serial monitor. For this to work you will need to run two separate Arduino IDEs.
    For each ESP board you need to assign a BOARD 1 or 2.
    Each ESP has its own MAC address and you need to enter it into the program on the ESP8266.
    Code: C / C++
    Log in, to see the code


    Once you get through this it will be downhill from there.
  • Arduino IDE file handling and upload confusion

    #19 21031980
    margas60
    Level 8  
    Posts: 230
    Help: 1
    Rate: 7

    Nothing works Arduino is some kind of monster where you don't know what to do. It doesn't open *.h files downloaded from Github, when you make a new one and paste the code it does save some *.imo .... what is this ?. I used to write in normal environments for C and this is Arduino ? ... ... nor upload anything, it saves you don't know what, not to mention how to compile it and then upload it to ESP .... sorry, I'm probably too old for this.
  • ADVERTISEMENT
  • Arduino IDE basics and ESP32 setup videos

    #20 21032244
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    margas60 wrote:
    Nothing works Arduino is some kind of monster where you don't know what to do. It doesn't open *.h files downloaded from Github, when you make a new one and paste the code it saves some *.imo .... what is this ?. I used to write in normal environments for C and this is Arduino ? ... ... nor upload anything, it saves you don't know what, not to mention how to compile it and then upload it to ESP .... sorry I guess I'm too old for this.


    It's not that scary.
    Maybe this will help for a start.
    https://www.youtube.com/watch?v=TzTmWqoN9i8

    and here for ESP8266
    https://www.youtube.com/watch?v=4q3K5Ctm3MI
  • #21 21069539
    margas60
    Level 8  
    Posts: 230
    Help: 1
    Rate: 7

    I fought, I fought ....... and fell .... I don't know what I'm doing wrong ..... the program on the ESP [via www] is running, it can be reconfigured but there is NO communication with the program on the laptop. I think I'll drill through the wall and try to find a way to run the cable ..... but it will still be running under my feet ....
  • Request for program and web interface screenshots

    #22 21069946
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    margas60 wrote:
    I fought, fought ....... and fell .... I don't know what I'm doing wrong ..... the program on the ESP [via www] is running, it can be reconfigured but there is NO communication with the program on the laptop. I think I will drill through the walls and will try to figure out how to run the cable ..... but still some section will be underfoot ....



    Easy :-)


    What program and what WWW.
    Show screenshots.
  • ESP32 receives RS232 but sends no Wi‑Fi data

    #23 21070382
    margas60
    Level 8  
    Posts: 230
    Help: 1
    Rate: 7

    Well, once again, the INVERTER sends data via RS232, so by default I let it into the ESP after setting the IP address of my LAN. Now this data is received via WIFI by a laptop on which the inverter monitoring software is installed, in which I set the IP given to the ESP. The software processes the data and displays .......... unfortunately the ESP does not send any data, so either the configuration or it simply will not work like that.
    I also have a module EW10A and a similar configuration panel designed for RS232 transmission via wifi, but it is quite messed up in the head because once it is accessed by IP and after a while no longer, but in the network is visible, transmission also failed to start.
  • ESP-Now-Serial-Bridge requires firmware on both ESPs

    #24 21070410
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 30
    margas60 wrote:
    Well, once again the INVERTER sends data over RS232 so by design I let it into the ESP after setting the IP address of my LAN. Now this data is received via WIFI by a laptop on which the inverter monitoring software is installed, in which I set the IP given to the ESP. The software processes the data and displays .......... unfortunately the ESP does not send any data, so either the configuration or it simply will not work like that.
    I also have a module EW10A in a similar configuration panel designed for RS232 transmission via wifi, but it is quite messed up in the head because once it is accessed by IP and after a while no longer, but in the network is visible, transmission also failed to start.

    Further you did not provide data:
    What you uploaded to the ESP - if ESP-Now-Serial-Bridge then you have to upload it to 2 ESPs (layout as at the beginning of the topic) in order to transmit information further.
    If you have not uploaded ESP-Now then what because I am not able to predict your actions.
  • Topic summary

    ✨ The discussion revolves around replacing RS485/RS232 communication cables with ESP32 modules for WiFi connectivity. The original poster seeks to connect remote devices wirelessly, allowing for data collection without physical connections. Various solutions are proposed, including using ESP-Link and ESP-Now-Serial-Bridge for establishing communication. The poster successfully implements a bi-directional connection between USB and RS232 through ESP32, achieving stable data transmission at a baud rate of 9600. Challenges with Arduino IDE and configuration issues are also addressed, with suggestions for troubleshooting and setup provided by other participants.
    Summary generated by AI based on the discussion content.

    FAQ

    TL;DR: For an 8 m link through two walls, two ESP32 boards using ESP-NOW solved remote RS232/RS485-style access; after setup, the user reported it worked for 2 days with no issues, and one reply summed it up: "It works great both ways." This FAQ is for anyone who wants a laptop-to-device wireless serial bridge without running a cable. [#21011771]

    Why this matters: It shows when a simple two-board wireless serial bridge can replace a short private cable run, and when protocol, delay, or software expectations can still break the design.

    Approach Hardware mentioned Best fit in the thread Main limitation noted
    ESP-Link ESP8266 in its description Simple serial-over-Wi-Fi idea Documentation cited by the user mentions ESP8266, not ESP32
    ESP-Now-Serial-Bridge 2× ESP32 Short transparent serial link through walls Needs both boards configured with opposite MAC addresses
    ESP32 UART bridge ESP32 Wi-Fi UART bridging to TCP/network tools Packet-based networking can affect byte-stream behavior
    Modbus RTU to TCP bridge ESP32 + Node-RED workflow When the target already speaks Modbus Not a transparent replacement for every serial app

    Key insight: The thread’s successful design did not use one ESP32 as a universal serial-to-Wi-Fi drop-in. It used two ESP32 boards, one on each side, and matched the inverter’s 9600 baud link.

    Quick Facts

    • The proven test case was a private link of about 8 m through two walls, with inverter data collected every 5 min. [#21008114]
    • The working build used 2 ESP32 boards in a bidirectional chain: USB ↔ ESP32 ESP32 ↔ RS232. [#21011771]
    • The stable test ran for 2 days with no problems before the user reported success. [#21011771]
    • The final serial speed matched the inverter setting: 9600 baud. [#21013246]

    How can I replace an RS485 or RS232 cable with ESP32 modules and Wi‑Fi for remote serial communication?

    Use two ESP32 boards as a wireless serial bridge, not one board alone. Put one ESP32 near the laptop side and one near the inverter side, then pass UART data between them over Wi‑Fi or ESP-NOW. The thread’s successful setup was a bidirectional USB ↔ ESP32 <Wi‑Fi> ESP32 ↔ RS232 link, tested on a private installation. [#21011771]

    What limitations should I consider when bridging RS232 or RS485 over Wi‑Fi, especially packet delays, distance, and walls?

    You must check delay tolerance, distance, and obstacles before replacing the cable. One reply warned that serial works at the byte level, while networks work at the packet level, so some applications stop behaving like a direct cable. In the thread, the real path was about 8 m and two walls, which worked, but that does not guarantee approval-sensitive or timing-critical systems. [#21007260]

    Which approach is simplest for a laptop-to-inverter wireless serial link: ESP-Link, ESP-Now-Serial-Bridge, or an ESP32 UART bridge?

    ESP-Now-Serial-Bridge was the simplest proven path in this thread for a laptop-to-inverter link. ESP-Link was suggested first, but the user had ESP32 boards, not ESP8266 modules. An ESP32 UART bridge was also suggested, but the only option reported as working end-to-end here was ESP-NOW on two ESP32 boards. [#21009417]

    How well does ESP-Link work on ESP32, given that its documentation mentions ESP8266?

    The thread does not confirm ESP-Link working on ESP32. The user noticed the description explicitly said it connects a microcontroller through the ESP8266 Wi‑Fi module, and no later post reported a successful ESP-Link-on-ESP32 test. In this discussion, the successful ESP32 route used ESP-NOW instead. [#21007216]

    Wi‑Fi vs Bluetooth for replacing a short RS232/RS485 cable to an inverter through two walls — which is better and why?

    Wi‑Fi was better in this case because it was the only option that was tested successfully through two walls. When Bluetooth was suggested, one reply pushed back and noted that even consumer BT is known for delays, so it does not solve the packet-delay issue by itself. The finished working setup used ESP32 wireless communication, not Bluetooth. [#21007260]

    What is ESP-NOW on ESP32, and how is it used as a serial bridge between two boards?

    "ESP-NOW is a wireless protocol that sends data directly between ESP boards, using MAC-address pairing instead of normal IP networking." In this thread, it was used to move serial data between two ESP32 boards, creating a transparent bridge from USB on one side to RS232 on the other. The user later reported 2 days of stable operation. [#21011771]

    What is a Modbus RTU to TCP bridge, and when would it be better than a transparent UART-over-Wi‑Fi bridge?

    "A Modbus RTU to TCP bridge is a protocol converter that takes Modbus serial traffic and exposes it on a TCP port, instead of imitating a raw cable." It is better when your device already uses Modbus RTU and your software can read TCP data directly. One reply said this was their own approach, processed further in Node-RED. [#21008140]

    How do I configure ESP-Now-Serial-Bridge on two ESP32 boards using BOARD1/BOARD2 and the opposite board’s MAC address?

    Configure it in three steps. 1. Flash the sketch to two ESP32 boards. 2. Set one build as BOARD1 and the other as BOARD2. 3. In each sketch, place the other board’s MAC address in RECVR_MAC, so each ESP32 points to its partner. That mirror setup was the fix that made the bridge work both ways. [#21009054]

    Why does ESP-Now-Serial-Bridge say to set RECVR_MAC, and where exactly do I put the other ESP32’s MAC address in the sketch?

    RECVR_MAC tells each board which peer should receive its wireless packets. Put the opposite board’s 6-byte MAC address directly in the macro at the top of the sketch, for example under #define BOARD1 or #define BOARD2. The user was confused by a note mentioning IP, but the reply clarified that the sketch needed MAC addresses, not IPs. [#21009054]

    Why does my ESP32 serial bridge only print its MAC address and then show nothing else in the Serial Monitor?

    This usually means the two boards are not paired correctly or only one side is configured. In the thread, the output showed the ESP32 MAC and then only "0", with no further activity. The later fix was to assign BOARD1/BOARD2 correctly and enter the opposite board’s MAC in RECVR_MAC on each board. [#21008711]

    What baud rate should I use for an ESP32 Wi‑Fi serial bridge when the inverter communicates at 9600 baud?

    Use the same baud rate as the inverter. In the successful setup, the bridge was set to 9600 baud because the inverter already transmitted at 9600. Matching the serial speed avoids an unnecessary mismatch before you debug Wi‑Fi or ESP-NOW behavior. [#21013246]

    How do I build a bidirectional USB ↔ ESP32 ESP32 ↔ RS232 connection for remote inverter monitoring?

    Build it with one ESP32 at the laptop side and one at the inverter side. Connect the laptop through USB-to-serial on one end, connect the inverter through RS232 on the other, and link the two ESP32 boards wirelessly. The thread author showed this exact bidirectional chain and reported successful tests after 2 days of continuous use. [#21011771]

    Why do Arduino IDE 2.3 and Arduino IDE 1.8 behave differently when compiling ESP-NOW examples, and how can I work around it?

    The thread shows a practical compatibility issue, not a full root-cause analysis. One user said the project did not compile on Arduino IDE 2.3, then switched to a portable Arduino IDE 1.8.19 setup and proceeded from there. If your ESP-NOW example fails in 2.3, the documented workaround here is to retry with the older portable IDE. [#21031735]

    How should I install the ESP32 or ESP8266 board packages so headers like esp_now.h, WiFi.h, and esp_wifi.h compile correctly in Arduino IDE?

    Install the correct board support package first, then compile for the matching chip family. A later user mixed ESP8266 hardware with headers such as esp_now.h, WiFi.h, and esp_wifi.h, then asked where to get them. The working advice in the thread was to first run and test basic ESP-NOW programs on two ESP8266 boards before adding the serial side. [#21031735]

    Why would an ESP-based RS232-to-Wi‑Fi setup show a web configuration page but still fail to pass data to laptop monitoring software?

    A web page only proves the ESP is on the network, not that it is forwarding serial data in the format your software expects. In the thread, the failing setup showed a browser-accessible configuration page, but the laptop program still received no inverter data. The reply highlighted the likely design error: the user had not confirmed what firmware was loaded, and ESP-Now-Serial-Bridge requires 2 ESP devices, not one. [#21070410]
    Summary generated by AI based on the discussion content.
    ADVERTISEMENT