A minimal AtomVM project that:
- Provisions Wi-Fi credentials via environment variables
- Saves them to NVS (non-volatile storage)
- Connects to Wi-Fi and syncs time via SNTP
- Logs local time to the console once per second
For the most up-to-date ESP32 hardware and software requirements, refer to the official AtomVM Getting Started Guide.
- An ESP32 development board supported by AtomVM (e.g. ESP32-DevKitC, Seeed XIAO-ESP32S3)
- Erlang/OTP 27
- Elixir 1.17.x
- AtomVM toolchain (via
exatomvm) - A serial monitor tool such as:
picocomscreenminicom
- A 2.4 GHz Wi-Fi network
- Internet access (required for SNTP time synchronization)
# Clone the example AtomVM project with Wi-Fi + SNTP support
git clone https://github.com/mnishiguchi/hello_atomvm_wifi_sta.git
# Enter the project directory
cd hello_atomvm_wifi_sta
# Fetch Elixir dependencies
mix deps.get
# Flash the AtomVM runtime to your ESP32 (one-time setup)
mix atomvm.esp32.install
# Set your Wi-Fi credentials as environment variables
export ATOMVM_WIFI_SSID="your-ssid"
export ATOMVM_WIFI_PASSPHRASE="your-passphrase"
# Build and flash the application firmware to the device
mix atomvm.esp32.flash --port /dev/ttyACM0
# Open a serial monitor to view runtime logs
picocom /dev/ttyACM0Adjust the serial port if needed (for example /dev/ttyUSB0).
From the project root:
mix deps.getFlash the AtomVM runtime to your ESP32:
mix atomvm.esp32.installExport your Wi-Fi credentials as environment variables before building/flashing:
export ATOMVM_WIFI_SSID="your-ssid"
export ATOMVM_WIFI_PASSPHRASE="your-passphrase"Optional:
# If set (any non-empty value), overwrite NVS credentials on every boot
export ATOMVM_WIFI_FORCE=truemix clean
mix atomvm.esp32.flash --port /dev/ttyACM0During the first boot, the firmware will:
- Store Wi-Fi credentials in NVS
- Connect to the access point (STA mode)
- Synchronize time via SNTP
- Start logging local time once per second
Open a serial console:
picocom /dev/ttyACM0You should see logs like:
wifi: first-time provision (stored Wi-Fi credentials in NVS)
wifi: started
wifi: connected to AP
wifi: got IP {192,168,1,123}
sntp: synced {tv_sec, tv_usec}
time: 2026-01-23 21:42:01 (JST)
Wi-Fi credentials can be provisioned at build time using environment variables. On boot, they are stored in ESP32 NVS and reused on subsequent boots.
| Environment variable | NVS key | Description |
|---|---|---|
ATOMVM_WIFI_SSID |
wifi_ssid |
Wi-Fi SSID to store in NVS |
ATOMVM_WIFI_PASSPHRASE |
wifi_passphrase |
Wi-Fi passphrase (optional for open networks) |
ATOMVM_WIFI_FORCE |
— | If set, forces credentials overwrite at boot |
-
First boot (NVS empty)
- If
ATOMVM_WIFI_SSIDis set, credentials are written to NVS.
- If
-
Subsequent boots
- Stored NVS credentials are reused.
-
Forced provisioning (
ATOMVM_WIFI_FORCEset)- NVS credentials are overwritten on every boot.
- If no passphrase is provided, any existing passphrase is removed (open network).
This allows you to:
- Flash once and reboot freely without re-exporting credentials
- Re-provision Wi-Fi by flashing again with
ATOMVM_WIFI_FORCE=true