logo elektroda
logo elektroda
X
logo elektroda

Configuration of ESP8266 as UDP server with RS232 - IP 10.10.2.1, port 22000, AT?

heyka 5226 78
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17824897
    heyka
    Level 17  
    Please advise me how to configure the ESP8266 module to work:
    - as a UDP server
    - to listen on IP address 10.10.2.1 and port 22000
    - to send everything that comes to it via RS232 to the processor and if the processor responds to something to send it back to the client via WiFi

    Added after 18 [minutes]:

    Is it possible to set all this up using AT commands?
  • ADVERTISEMENT
  • #2 17824939
    khoam
    Level 42  
    heyka wrote:
    Please tell me how to configure the ESP8266 module to work:
    - as a UDP server
    - so that it listens on IP address 10.10.2.1 and port 22000
    - so that everything that comes to it sends via RS232 to the processor and if the processor responds, it sends back to the client via WiFi
    .
    Link

    heyka wrote:
    Can this all be set up with AT commands?
    .
    Link .
  • ADVERTISEMENT
  • #3 17826908
    heyka
    Level 17  
    Code: C / C++
    Log in, to see the code
    .

    does not accept my command to set up the server
  • #4 17826945
    khoam
    Level 42  
    heyka wrote:
    doesn't accept my server setting command
    .

    What mode is the ESP set to? Station, AP or both?
    Did you connect to the WiFi router first with the AT+CWJAP command?
    What is the AT firmware version?
  • #5 17827032
    heyka
    Level 17  
    Code: C / C++
    Log in, to see the code
    .

    From the above information , it appears that the module is set as an AP, it sends received data to the serial port, it handles one connection at a time.
    How do I check if it is acting as a UDP server with IP 10.10.100.254 and has a listening port set to 32000?
  • #6 17827073
    khoam
    Level 42  
    heyka wrote:
    How do I check if it is running as a UDP server with IP 10.10.100.254 and has a port set to listen of 32000?
    .
    Use nmap.

    And the AT firmware is upgradeable, to version 1.6.2 - link .
  • #7 17827076
    heyka
    Level 17  
    Code: C / C++
    Log in, to see the code
    .
    I have set the IP, still only the port , but I do not know with what command
  • ADVERTISEMENT
  • #8 17827087
    khoam
    Level 42  
    heyka wrote:
    I set the IP, still only the port , but I don't know with what command
    .
    You set the port in AT+CIPSTART.

    Check with AT+CIPSTATUS.

    And you also forgot AT+CIPSERVER

    The whole sequence you need is already given in the link in post #2.
  • #9 17827186
    heyka
    Level 17  
    Code: C / C++
    Log in, to see the code
    .

    When I set according to the link, something is wrong

    Added after 27 [minutes]:

    Code: C / C++
    Log in, to see the code
    .
    I reset the module and set everything as above
    what does the Cipstatus number 12819 and that zero at the end mean?

    Can it be assumed that everything is set correctly?

    Added after 1 [minute]:

    Code: C / C++
    Log in, to see the code
    .
  • #10 17827222
    kaczakat
    Level 34  
    In my opinion the method from the first link will be more effective, you upload the code exactly as you need it and the ESP is immediately in that mode after the reset. With AT commands you will have to be careful if you accidentally do a reset and set it up again.
    Helpful post? Buy me a coffee.
  • #11 17827471
    heyka
    Level 17  
    kaczakat wrote:
    upload the code exactly as you need it
    .
    OK

    I need the module to work in AP mode as a UDP server listening on IP 10.10.100.254 on port 32000 and everything that arrives to it forwarded to RS232 with ASCII transmission.

    I have no experience with these modules and with Arduino.

    So do I need to write code in Arduino and program the module?
  • #12 17827888
    kaczakat
    Level 34  
    You don't need to know too much with Arduino, in the sticky in this section it is described what you need to do to install ESP8266 boards to Arduino. But it's still a lot of work ahead of you, I've been playing with Arduino for over 2 years and I still learn what I didn't know every day. If you have a NODE MCU/ WEMOS, a MICRO USB cable + Arduino is enough for programming. For the ESP-01 you need a 3.3V UART converter and a sequence of shorted pins to program, some 3.3V power supply, a tad harder to start with. In both cases you open a new sketch, paste the ready-made from the link from @khoam, modify the ready-made to send only the buffer to the serial (delete the extra lines) and you're almost done. ESP can be configured for a fixed IP and all network parameters, you need to add reading the response from Serial and writing back with either an incoming UDP or serial message (now the default is acknowledged) . For testing, you can use the TCP/UDP client SocketTeset v3.0.0 or something like that on a PC, there are also some for Android. It is also a question of how much of this data flies and how often. Whether AP or station this is specified when initialising WIFI in the sketch, for everything there are plenty of examples and in the Arduino IDE and on google. With Arduino you are most likely to even find something exactly like you need, there are many other hits for UDP - e.g. https://github.com/roboremo/ESP8266-WiFi-UART-Bridge/tree/master/v1.1 A week is not enough to review, copy, compile and test everything.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #13 17827968
    heyka
    Level 17  
    I've got the Arduino installed, I've got the ESP8266 board installed, I've got the converter, I've got everything ( how little it takes to have everything :) )

    I need some code as simple as possible that will set up the module according to what I need to be able to analyze and understand it. This example pd mate khoma is heavily elaborated and I don't know how to go about it.
  • #14 17828289
    khoam
    Level 42  
    heyka wrote:
    I have the Arduino installed, I have the ESP8266 board installed, I have the converter, I have everything ( how little does it need to be everything :) ).
    I need some code as simple as possible that will set up the module according to what I need to be able to analyze and understand it. This example pd mate khoma is very elaborate and I don't know how to go about it.


    It probably can't get any simpler: Link .
  • #16 17828710
    khoam
    Level 42  
    heyka wrote:
    I fired up the Arduino today and my ESP 8266 board disappeared in the board manager.


    Is it even visible in the "Tile Manager" in the list?
  • #18 17828720
    khoam
    Level 42  
    Check in File => Preferences whether the address for it is listed under "Additional URLs to the tile manager".
  • #19 17828728
    heyka
    Level 17  
    address is posted , but I have a download error message as I have attached on screean
  • #20 17828737
    khoam
    Level 42  
    This, oddly enough. I uninstalled and reinstalled "http://arduino.esp8266.com/stable/package_esp8266com_index.json" a while ago, so the server itself is available.
  • #21 17828743
    heyka
    Level 17  
    At my place yesterday everything was OK, strange, Arduino doesn't like me. Something makes me think I'll stick with C and Eclipse
  • #22 17828769
    khoam
    Level 42  
    heyka wrote:
    I was OK yesterday, strange, Arduino doesn't like me. Something makes me think I'll stick with C and Eclipse
    .

    You can always use the Espressif SDK .
    Here you have a simple example for a UDP server: Link .
  • #23 17828989
    kaczakat
    Level 34  
    heyka wrote:
    I fired up the Arduino today and the ESP 8266 board disappeared in the board manager.
    .
    But how did it disappear, did you manage to install it? If you can't connect to the Arduino IDE somewhere, it's not likely to be a problem of network blocking software. Confirm by trying to fire up the library/board manager. The program in the first link from @khoam works OK, upload, test, disable what you don't need, upload, test, add what you need from the UART side (I recommend the serialEvent example), upload, etc.
    Helpful post? Buy me a coffee.
  • #24 17829051
    heyka
    Level 17  
    I can't upload because I don't have a board available in Arduino in the board manager, yesterday I installed it was available,and today I turned on Arduino and it's not there and I can't install it.
  • #25 17829056
    kaczakat
    Level 34  
    Well, download again/uninstall/install, you didn't have the day before yesterday so it's a small loss too. It will go faster the second/next time. There are also ZIP versions, which do not require installation.
    Helpful post? Buy me a coffee.
  • #26 17829113
    heyka
    Level 17  
    kaczakat wrote:
    .
    The program from the first link from @khoam works OK.


    Where to enter in the code
    - IP no. of the UDP server
    - port no. on which the server should receive


    I get an error when trying to compile

    Code: C / C++
    Log in, to see the code
    .
  • #27 17829132
    khoam
    Level 42  
    heyka wrote:
    Where to enter in the code
    - server UDP IP no.
    - port no. on which the server is to receive
    .
    I'm a bit confused. Which code are you referring to? The one from post #14 or from post #2?
  • Helpful post
    #28 17829149
    kaczakat
    Level 34  
    Well, it works OK, but there is something wrong with the fonts, I changed the inverted commas to Polish.
    See this version, my modifications towards your requirements:
    Code: C / C++
    Log in, to see the code
    .
    Helpful post? Buy me a coffee.
  • #29 17830044
    heyka
    Level 17  
    Code: C / C++
    Log in, to see the code
    .

    Is this the IP setting of the module or the UDP server?
  • #30 17830051
    khoam
    Level 42  
    heyka wrote:
    Is this the IP setting of the module or the UDP server?


    UDP is one of the IP protocols.

Topic summary

The discussion revolves around configuring the ESP8266 module to function as a UDP server with a specific IP address (10.10.2.1) and port (22000), while also facilitating RS232 communication. Users explore the feasibility of using AT commands for setup, troubleshooting connection issues, and the limitations of the AT firmware. Several users share their experiences with command sequences, firmware versions, and the necessity of using Arduino for more complex configurations. The conversation highlights the importance of setting the correct operating mode (AP or Station), managing IP addresses, and handling incoming and outgoing data through UDP. Additionally, users discuss programming the ESP8266 using Arduino IDE, including code snippets for establishing UDP communication and responding to UART data.
Summary generated by the language model.
ADVERTISEMENT