I want to read the IP address assigned to esp32s3 board via serial port (/dev/ttyACM0)
This board is connected to internet via SPI-Ethernet module (w5500) and will be connected to internet on boot up.
Is it possible to read IP address (refer attached image) from bash script?
esp32s3 - how to read IP address from serial port?
esp32s3 - how to read IP address from serial port?
- Attachments
-
- 2023-09-07 11-48-44.png (69.99 KiB) Viewed 5006 times
Re: esp32s3 - how to read IP address from serial port?
What is the underlying problem you want to solve?
What you want is possible, but I have a gut feeling that it's not the right solution.
What you want is possible, but I have a gut feeling that it's not the right solution.
Re: esp32s3 - how to read IP address from serial port?
I need to upload few files to a location in the server that is running inside the esp32s3 using -
where ipaddr is the local ip address that was assigned to the board.
I'm trying to write a bash script to automate this process.
Something like reading ip address before from board via serial port and then pass it to another script as an argument.
Any better ideas are welcome!
Code: Select all
curl -F 'file=@somefile.zip' http://ipaddr/app/main/
I'm trying to write a bash script to automate this process.
Something like reading ip address before from board via serial port and then pass it to another script as an argument.
Any better ideas are welcome!
Re: esp32s3 - how to read IP address from serial port?
How about the otherway around? So the esp uploads to a server?
Or use a broadcast message when the device boots that the other device detects.
btw, still not explaining what the underlying problem is that you want to solve.
Or use a broadcast message when the device boots that the other device detects.
btw, still not explaining what the underlying problem is that you want to solve.
Re: esp32s3 - how to read IP address from serial port?
esp is the one that has the a tiny web server running inside itvanBassum wrote: How about the otherway around? So the esp uploads to a server?
I am not sure what you are expecting.btw, still not explaining what the underlying problem is that you want to solve.
The device boots and connects automatically to internet.
Or I can issue this command via bash script (echo "$CMD" > "$PORT") to connect manually - https://realtimelogic.com/ba/ESP32/sour ... etwork-cfg
It then prints out some IP address (192.168.xxx.xxx) which I use to upload files like in my previous posts.
Similarly, is there any command to read that obtained IP address from bash script itself?
I checked the documentation but could not find information related to IP address.
Hope I am clear now. Let me know if you need any other information..
Re: esp32s3 - how to read IP address from serial port?
It's certainly possible to extract the IP address, although I'm not proficient in bash scripting. You might want to explore regular expressions (regex) for this purpose.
However, I'd like to reiterate the importance of understanding the underlying problem you're trying to solve. Currently, you're describing the solution you have in mind, but it's crucial to clarify the specific problem you're addressing with this solution. For instance, is the problem something like this:
"During production, I need to configure the ESP project with a settings file before shipping to the customers."
In my previous message, I suggested an alternative approach where the ESP32 acts as a client and downloads the required files from a web server. This change in perspective can simplify your setup and potentially lead to a more effective solution. But to evaluate its suitability, I need to grasp the core issue you're aiming to resolve.
Could you please provide more details about the problem you're trying to solve? This will enable us to offer a more targeted and effective solution.
If you really want to stick with your solution, I guess you can do something like this: (This script came from AI, haven't tested this.)
However, I'd like to reiterate the importance of understanding the underlying problem you're trying to solve. Currently, you're describing the solution you have in mind, but it's crucial to clarify the specific problem you're addressing with this solution. For instance, is the problem something like this:
"During production, I need to configure the ESP project with a settings file before shipping to the customers."
In my previous message, I suggested an alternative approach where the ESP32 acts as a client and downloads the required files from a web server. This change in perspective can simplify your setup and potentially lead to a more effective solution. But to evaluate its suitability, I need to grasp the core issue you're aiming to resolve.
Could you please provide more details about the problem you're trying to solve? This will enable us to offer a more targeted and effective solution.
If you really want to stick with your solution, I guess you can do something like this: (This script came from AI, haven't tested this.)
Code: Select all
#!/bin/bash
# Serial port device
SERIAL_PORT="/dev/ttyACM0"
# Command to send to ESP32 to obtain IP address
CMD="get_ip_address_command" # Replace with the actual command
# Send the command to the ESP32 and capture the output
IP_ADDRESS=$(echo "$CMD" > "$SERIAL_PORT" && cat "$SERIAL_PORT")
# Parse the IP address from the captured output (adjust this part based on the actual output format)
IP_ADDRESS=$(echo "$IP_ADDRESS" | grep -oE "Ethernet ip: ([0-9]{1,3}\.){3}[0-9]{1,3}")
Re: esp32s3 - how to read IP address from serial port?
Thanks! It is working.
Actually I'm using a script which is very similar to what you have posted. Of course it was generated by AI as well.
I will surely look into your suggestion about the other way of downloading data via server when I get time.
Actually I'm using a script which is very similar to what you have posted. Of course it was generated by AI as well.
I will surely look into your suggestion about the other way of downloading data via server when I get time.
Who is online
Users browsing this forum: No registered users and 61 guests