Good morning,
I have an ESP32 that works 24h/24, which I can update with vscode remotely (OTA) from the local network.
On the same home LAN I have a NAS with reverse proxy. So from the internet, a:
ping esp.xxx.synology.me
reaches the NAS
My question: is it possible to reprogram the ESP32 from the internet?
Hello
Sorry I don’t understand the first point. I did not enter this instruction anywhere.
And no, I did not modify the env[“PROGNAME”] paragraph in the platformio.ini file.
I don’t know if Synology’s reverse proxy sends messages in UDP because I have configured it as follows :
Besides, I haven’t opened any particular ports on my internet box. I thought it was not useful because I am accessing all machines on my local network correctly.
But neither the destination not source protocol is HTTP. And if you configured the SRC to be on port 80, then you would also need to tell PlatformIO to access that port from the outside. Do you have the option to setup a 1:1 relationship between Source UDP 3232 and Destination UDP 3232? That should make it work without modifications.
Hello
I just changed the settings of my internet box to transfer everything that comes in UDP port 3232 to my esp with the same port 3232.
Obviously it’s a little bit better
Oh, actually this process is more complicated. It starts off with UDP, but then it will ask the ESP to connect to the given TCP server port opened by the computer, i.e., from the ESP32 (source port probably random) to the computer, target port 23524 in this case. See source code. This port number is however random
So what you should do:
Use upload_flags in the platformio.ini to add --host_port, then it should have a fixed TCP server port on the PC side
Make another rule so that the ESP32 can reach your computer’s TCP server port as decided above
First, thank you Maxgerhardt for your help !
Then, I’ve fixed host_port in platformio.ini
upload_port = 176.xxx.yyy.zzz ; it's the IP adress of my internet box
upload_flags =
--port=3232
--auth=password
--host_port=22564 ; selected by me
upload_protocol = espota
Then something is still wrong with the port forwarding. I guess you could a very minimal sketch for the ESP32 (uploaded via serial) that tries to connect to TCP 22564 on your computer’s IP address (e.g. derived from this) while a minimal TCP server is opened by e.g. this program.
I just stumbled across this thread, but I got this to work using PlatformIO/VSCode and regular consumer grade routers at each location. A Linksys router on one end, and an ASUS router on the other.
In the platformio.ini of the new sketch to be uploaded I set:
upload_protocol = espota
upload_flags =
–port=3232
–host_port=22564 ;
upload_port = 199.XXX.XXX.XXX ; redacted Public IP address
On the router where the ESP32 is located (about 1500 miles away), I remotely forwarded port 3232 (both TCP and UDP) to the internal/private IP address of the ESP32.
On the router where the PC running PlatformIO/VSCode is located (and me), I forwarded port 22564 (both TCP and UDP) to the internal/private IP address of the PC I was using.
I clicked the upload button in PlatformIO and boom…It worked.
Of course the remote ESP32 sketch was already running ArduinoOTA/ESPOTA code, but I’d only ever used it when the device was on the same LAN as the PC. The settings above allowed me to update with a new sketch over the internet.
Oh, and of course I knew the public IPv4 address of the remote router. The remote location internet has dynamic IP, but it doesn’t change often, and the sketch running on the ESP32 there reports the some data back to my NAS every 15 minutes which includes the Public IP address on that end. I’m sure setting up a DDNS on the remote router would work too, but I haven’t tested whether the Upload port flag on the PlatformIO.ini can lookup the IP address directly.