WiFi connect and HTTP

Join a network, log the link events, and poll an endpoint every five seconds — Request carries the whole HTTP call.

Click through the files — it's the whole project

WiFi connect and HTTP — Visual Studio Code
Select a file from the explorer
esp32s3_devkitc · HTTP WiFi · Request · events

What's going on

  • The WiFi constructor carries the whole link policy — credentials, a 15 s associate timeout, power saving. join() blocks until there's an IP; onUp/onDrop fire on the link's own schedule after that.
  • Each poll is one Request object: method, URL, headers, send, then ok()/text(). The body is valid until the next send() — copy it out if you need to keep it.
  • https:// is native — pass a caCert to verify, or insecure: true for a lab server you don't trust to have a real certificate.
  • WiFi needs an ESP32 target — esp32s3_devkitc here. One hardware note worth knowing: some ESP32-S3 dev kits reboot the moment the radio transmits. If the board restarts on join(), it's usually power, not code.

Flash and watch

terminal
npx @typecad/hal create my-project --target esp32s3_devkitc
cd my-project
npx @typecad/hal build --compile --upload --port COM4

Put your own SSID and PSK in src/main.ts before flashing. Then open a serial monitor at 115200 — you'll see the IP on join, and a health line every five seconds. Point the URL at anything on your LAN that answers GET.

Where to go next

  • Networking — static IPs, scanning, async joins, and the full Request options
  • MQTT — the next step up from polling
  • Boards — target names and what compiles where
© 2026 typeCAD — code-defined electronics github