logo elektroda
logo elektroda
X
logo elektroda

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

globalinfo 3555 23
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21006622
    globalinfo
    Level 13  
    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
  • #2 21006714
    JacekCz
    Level 42  
    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  
    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.
  • #5 21007216
    globalinfo
    Level 13  
    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?
  • #6 21007260
    JacekCz
    Level 42  
    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.
  • #7 21008114
    globalinfo
    Level 13  
    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.
  • ADVERTISEMENT
  • #9 21008711
    globalinfo
    Level 13  
    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  
    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  
    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
    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.
  • #13 21009417
    globalinfo
    Level 13  
    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/
  • ADVERTISEMENT
  • #14 21011771
    globalinfo
    Level 13  
    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
    Well, that's great. What baudrate is it running at?
  • #16 21013246
    globalinfo
    Level 13  
    I set 9600 - the same as the inverter sends.
  • #17 21031204
    margas60
    Level 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?
  • #18 21031735
    globalinfo
    Level 13  
    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.
  • #19 21031980
    margas60
    Level 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.
  • #20 21032244
    globalinfo
    Level 13  
    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 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 ....
  • #22 21069946
    globalinfo
    Level 13  
    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.
  • #23 21070382
    margas60
    Level 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.
  • #24 21070410
    globalinfo
    Level 13  
    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 the language model.
    ADVERTISEMENT