- Notifications
You must be signed in to change notification settings - Fork4
ESP32 + GitHub Actions + Husarnet. A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.
License
husarnet/esp32-internet-ota
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Caution
Husarnet for ESP32 has undergone a major refactor making it compatible with the latest upstream core codebase, latest ESP-IDF releases and newest Espressif microcontrollers. Because of that, code inthis repository is outdated and it should not be used for new designs. It may or may not be updated to reflect the changes later in the future.
ESP32 + GitHub Actions + Husarnet.
A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.
Prerequisites
Install platformio CLI:
pip3 install -U platformioIf you are working inVisual Studio Code thePlatformIO extension will be helpful.
ClickUse this template button to create your own copy of this repo. Clone the repo, and open it:
git clone https://github.com/husarnet/esp32-internet-otacd esp32-internet-ota/Erase the ESP32 flash
pio run --target erase# or# esptool.py erase_flash
Prepare the
.envfile:cp .env.template .env
And edit its content:
export WIFI_SSID="<place-your-wifi-ssid-here>"export WIFI_PASS="<place-a-password-to-your-wifi-here>"export HUSARNET_JOINCODE="<place-your-husarnet-joincode-here"
Tip
If your SSID or WLAN Password contains special characters (ex.
$ & ( ) ? ; : , . < > | `) you need to escape them like this::If WiFi password is
$&()?then:export WIFI_PASS="\$\&\(\)\?"Some special characters (ex.
' " \) can't be escaped.We recommend to not use special characters and emojis in WiFi SSID/Password.
The first time you need to upload the firmware over the USB cable:
source .envpio run -e serial_upload --target uploadOpen the Platformio Device Monitor:
pio device monitor
If you will open a serial monitor you will see the similar output (the first time you may wait up to 2 minutes):
**************************************GitHub Actions OTA example**************************************📻 1. Connecting to: FreeWifi Wi-Fi network ..done⌛ 2. Waitingfor Husarnet to be ready ...done🚀 HTTP server startedVisit:http://my-esp32:8080/Known hosts:my-laptop (fc94:a4c1:1f22:ab3b:b04a:1a3b:ba15:84bc)my-esp32 (fc94:f632:c8d9:d2a6:ad18:ed16:ed7e:9f3f)
Visithttp://my-esp32:8080/ from your laptop (that should be in the same Husarnet group) and if the website is avaialble you can test OTA upgrade from the level of your laptop:
source .envpio run -e ota_upload --target uploadIf it works you can configure your GitHub repository.
Source environment variables from.env file before opening VS Code.
cd esp32-internet-ota/source .envcode.
warning!
Before launching an Internet OTA, you need to upload theinitial firmware at first to make your board accessible over the Husarnet VPN.
Create the folowing GitHub repository secrets (
Settings>Secrets>New repository secret):Secret Sample Value Desription WIFI_SSIDFreeWifi just your WiFi network name WIFI_PASShardtoguess ... and password HUSARNET_JOINCODEfc94:...:932a/xhfqwPxxxetyCExsSPRPn9 find your ownsecret Join Code at your user account athttps://app/husarnet.com > choosen network>add elementbutton. Anyone with this Join Code can connect to your Husarnet networkHUSARNET_DASHBOARD_LOGINme@acme.com A login for your account athttps://app.husarnet.com (needed byHusarnet Action) HUSARNET_DASHBOARD_PASSWORDhardtoguess A password for your account athttps://app.husarnet.com (needed byHusarnet Action) Push changes to your repo:
git add*git commit -m"triggering the workflow"git push
And trigger the workflow manually (
workflow_dispatch) in your GitHub repository.In ~3 minutes the GitHub workflow should finish its job. Visit:
http://my-esp32:8080URL with a sample "Hello world" website hosted by your ESP32.Of course your laptop need to be connected to the same Husarnet network - you will find quick start guide showing how to do it here:https://husarnet.com/docs/
sudo tcpflow -p -c -i hnet0
Here is a blog post showing how to configure Nginx Proxy Manager toprovide a public access to web servers hosted by Husarnet connected devices:https://husarnet.com/blog/reverse-proxy-gui
It can be also used o provide the access to a web server hosted by ESP32 using a nice looking link like:https://my-awesome-esp32.mydomain.com.
About
ESP32 + GitHub Actions + Husarnet. A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.