Remote updates

A project log for Vehicle Detection With D1 Mini and Magnetometer

Detect vehicles using QMC5883L and actuate swinging gate using relay to allow exit

AndrewAndrew 09/08/2019 at 20:330 Comments

As I've observed MQTT data there have been a few things I needed to tweak. Traditionally with ESPHome you would edit code through the console and click "upload". Since this device is deployed remotely I needed a way to update the code without going on-site. Using ESPHome's web_server component and a raspberry pi I was able to make this happen.

I have a raspberry pi on the remote network create a persistent tunnel back to my server, allowing me to get back into it without creating NAT rules on the modem. After logging into the rpi I simply create another reverse tunnel between my local workstation and the D1's web server:

/usr/bin/autossh -M 0 username@local_workstation -p 24 -o "StrictHostKeyChecking=no" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -N -R 9993:

The above makes the D1's web server dashboard available on my localhost:9993. From there I can use the "OTA Update" to upload a compiled binary with my changes.