WiFi connectivity for network access
Provides WiFi station mode for connecting to access points. Supports scanning for networks, connecting with SSID/password, and querying connection status. WiFi runs asynchronously - use is_connected() to check status after calling connect(). Useful for NTP time sync, firmware updates, and data transfer.
| Parameter | Description |
|---|---|
| ssid | Network name to connect to |
| password | Network password (use empty string for open networks) |
if ez.wifi.connect("MyNetwork", "password123") then
-- Wait for connection
if ez.wifi.wait_connected(10) then
print("Connected! IP:", ez.wifi.get_ip())
end
end
ez.wifi.disconnect()
print("Disconnected from WiFi")
print("DNS:", ez.wifi.get_dns())
print("Gateway:", ez.wifi.get_gateway())
local ip = ez.wifi.get_ip()
print("My IP:", ip)
print("MAC:", ez.wifi.get_mac())
local rssi = ez.wifi.get_rssi()
if rssi > -50 then
print("Excellent signal")
elseif rssi > -70 then
print("Good signal")
else
print("Weak signal")
end
local ssid = ez.wifi.get_ssid()
print("Connected to:", ssid)
print("WiFi status:", ez.wifi.get_status())
if ez.wifi.is_connected() then
print("Online!")
else
print("Not connected")
end
if ez.wifi.is_enabled() then
print("WiFi is on")
end
local networks = ez.wifi.scan()
for i, net in ipairs(networks) do
print(net.ssid, net.rssi .. "dBm")
end
| Parameter | Description |
|---|---|
| enabled | true to enable, false to disable |
ez.wifi.set_power(false) -- Turn off WiFi to save power
| Parameter | Description |
|---|---|
| ssid | Network name to advertise |
| password | Network password (8+ chars, empty = open) |
| channel | 1..13, default 1 |
| hidden | true to hide SSID from scan, default false |
| max_connection | Max simultaneous stations (1..10, default 4). Each |
ez.wifi.start_ap("tdeck-test", "tdeckpass") -- default 4 clients
ez.wifi.start_ap("party", "secret123", 6, false, 8) -- up to 8 clients
print("AP IP:", ez.wifi.get_ap_ip())
ez.wifi.stop_ap()
| Parameter | Description |
|---|---|
| ip | Target IP address |
| port | Target port |
| max_bytes | Safety cap on received bytes (default 1048576 / 1 MB) |
| timeout_ms | Connect timeout AND per-read idle timeout (default 30000) |
| Parameter | Description |
|---|---|
| port | 1..65535 |
| blob | Binary string with the full payload |
| timeout_ms | Default 30000. Applies to the accept phase AND to |
| Parameter | Description |
|---|---|
| port | 1..65535 |
| Parameter | Description |
|---|---|
| ip | Target IP |
| port | Target UDP port |
| timeout_ms | Default 1000 |
| Parameter | Description |
|---|---|
| timeout_seconds | Maximum seconds to wait (default 10) |
ez.wifi.connect("MyNetwork", "password")
if ez.wifi.wait_connected(15) then
print("Connected!")
else
print("Connection timeout")
end