ESP32 WiFi Cheatsheet
ESP32 WiFi Cheatsheet
WiFi.begin, HTTP requests, web server, and AP mode at a glance.
Station Mode
| WiFi.begin(ssid, pass) | Connect to a WiFi access point |
| WiFi.status() == WL_CONNECTED | Check if connected before making requests |
| WiFi.localIP() | Returns the IP address assigned by the router |
| WiFi.setAutoReconnect(true) | Reconnect automatically if the connection drops |
HTTP Client
| #include <HTTPClient.h> | Include the HTTP client library |
| http.begin("http://url") | Initialise a connection to a URL |
| int code = http.GET() | Perform a GET request ߀” returns HTTP status code |
| String body = http.getString() | Get the response body as a String |
| http.end() | Release the connection resources |
Web Server
| WebServer server(80) | Create a web server on port 80 |
| server.on("/", handler) | Register a handler function for a URL path |
| server.send(200, "text/html", s) | Send an HTTP response with status and body |
| server.begin() | Start listening for incoming requests |
| server.handleClient() | Must be called in loop() to process incoming requests |
AP & Scan
| WiFi.softAP(ssid, pass) | Start ESP32 as a WiFi Access Point |
| WiFi.softAPIP() | Returns the AP IP (usually 192.168.4.1) |
| WiFi.scanNetworks() | Scan and return the number of nearby networks |
| WiFi.SSID(i) / RSSI(i) | Get SSID name and signal strength for network index i |