Page 1 of 1

How to create a connection without knowing the remote IP address?

Posted: Sun Apr 03, 2022 10:41 am
by Arnaud_Girard
Hello,
We have a customer application for which we need, via Wifi, to send it 2 information (delay and temperature) and then upload historical data.

I expect to use ESP32 module in AT command.
Imagine the remote object consisting of a small simple controller connected to the ESP32 module via the UART. The microcontroller controlling the ESP32 module via AT commands on serial port.

On the other side, a computer application (or mobile phone) to send the temperature and a time, then retrieve the history.

How can the PC connect to the ESP32?
In all the TCP or UDP connection examples, we need to know the IP address on both sides, even with a UDP connection!

I am therefore looking for a way for the PC to first connect in SoftAP to configure the ESP32 (SSID and PSWD of the local networks),
Then with that the ESP32 connects to the Wifi network.
The PC will then be able to access the ESP32 on this Wifi network.

But in all these steps, with the examples, we must create a connection on the ESP32 side with the PC's IP address and the PC must connect with the ESP32's IP address (Assigned dynamically by a DHCP server)

How to connect and send data (SSID, PSWD, PC IP) so that the ESP32 then connects to the network (SSID, PSWD) and create a Client/Server connection with the PC IP it received. ..?

ESP32 and local microcontroler will not have any display to get its IP address assigned by the DHCP.

Have you an example for that?

Re: How to create a connection without knowing the remote IP address?

Posted: Thu Apr 07, 2022 2:04 am
by ESP_Sun
Your usage scenario is that after the ESP32 and the PC are connected to the same wifi, the ESP32 cannot automatically obtain the IP address of the PC, but when the ESP32 establishes a connection with the PC, it needs the IP address assigned by the PC when connecting to the wifi? Because I don't know your usage scenario very well, I hope the following information can help you:
1. ESP-AT can use domain name for TCP connection
2. When ESP-AT creates a UDP transmission, it can be set to broadcast (the remote address is set to: 255.255.255.255)
3. AT+CWLIF: Obtain the IP address of the site connected to the ESP SoftAP. After the PC is connected to the SoftAP of the ESP32, you can use AT+CWLIF to query the IP address of the PC