Learning Goals 5 min
Bluetooth is point-to-point and ~10 m. WiFi puts your Arduino on the same network as every laptop, phone and printer in the building — and through a router, on the public internet. The cheap, popular WiFi-capable boards are the ESP8266 family (2014) and the ESP32 family (2016, much more capable). Today you compare them and install the toolchain. By the end of this lesson you will:
- Identify the two boards: NodeMCU/Wemos D1 mini for ESP8266; ESP32 DevKit / WROOM for ESP32. Spot the differences (pin count, CPU cores, presence of Bluetooth).
- Install the ESP8266 and/or ESP32 board support packages in Arduino IDE.
- Upload a "Hello WiFi" sketch that boots, lists nearby WiFi networks, and prints them to Serial — no router login needed yet.
Warm-Up 10 min
Pull out your ESP-class board. The two most common in classrooms:
| Board | What to look for |
|---|---|
| NodeMCU ESP8266 | Long blue PCB, micro-USB, two rows of pins labelled D0..D8 + A0 + 3V3 + GND. Reset button on one end, FLASH button on the other. |
| Wemos D1 mini (ESP8266) | Tiny black board, micro-USB, single row each side. Same chip as NodeMCU, just smaller and pin-labelled D0..D8. |
| ESP32 DevKit (WROOM-32) | Bigger blue/black PCB, micro-USB, 30+ pins. Two rows of GPIO numbered 0..39 (not all usable). |
| ESP32-S3 / ESP32-C3 | Newer; USB-C, fewer pins, native USB instead of CH340. The 2024+ standard. |
One important question first
The ESP8266 and ESP32 are not Arduinos — they're different microcontroller families. We program them through the Arduino IDE thanks to the "Arduino core" project that adapts Arduino-style APIs (pinMode, digitalWrite, etc.) to the ESP's hardware.
So an ESP-flavoured sketch looks Arduino-y but uses ESP-specific libraries for WiFi, Bluetooth, etc. The basic APIs you learned in L01 carry over; the WiFi APIs are new.
New Concept · Two boards compared 20 min
The spec sheet, side by side
| Feature | ESP8266 (NodeMCU) | ESP32 (DevKit) |
|---|---|---|
| CPU | 80 MHz single core (Tensilica L106) | 240 MHz dual core (Xtensa LX6 — or RISC-V on C3) |
| RAM | 80 KB | 520 KB |
| Flash | 4 MB | 4 MB (some 16 MB) |
| WiFi | 2.4 GHz b/g/n (no 5 GHz) | 2.4 GHz b/g/n (no 5 GHz) |
| Bluetooth | None | Yes (Classic + BLE on most variants) |
| GPIO pins | ~11 usable | ~24 usable |
| ADC | 1 channel, 10-bit | 15+ channels, 12-bit |
| DAC | None | 2 channels, 8-bit |
| Logic level | 3.3 V (not 5 V tolerant on inputs) | 3.3 V (not 5 V tolerant on inputs) |
| Active current | ~80 mA | ~150 mA |
| Deep sleep | ~20 µA | ~10 µA |
| Price (2026) | ~£3 | ~£5 |
Which one to pick
For most school WiFi projects, either works fine. Choose based on:
- ESP8266 if: cheaper, smaller footprint, only need WiFi (no BLE), only need a few GPIO pins, just want to learn the basics.
- ESP32 if: need WiFi + BLE simultaneously, more GPIO needed, want to run TensorFlow Lite Micro (L04-34), want 12-bit ADC, want dual-core for advanced tasks.
For Cluster F's WiFi-only lessons, the ESP8266 is plenty.
The 3.3 V gotcha
Both boards are 3.3 V logic only. Plugging a 5 V signal into a GPIO can damage the chip. When connecting to 5 V sensors or 5 V Arduinos:
- 3.3 V → 5 V direction: usually fine (3.3 V is "HIGH" on 5 V inputs).
- 5 V → 3.3 V direction: must use a level shifter or voltage divider (1 kΩ + 2 kΩ resistor pair).
Two ways to use ESP boards in a project
- Standalone: the ESP is your main microcontroller. You write the whole sketch for it; no UNO involved. This is the modern, simpler path.
- WiFi co-processor: the ESP runs special firmware that exposes WiFi as AT commands. The UNO is the main brain; it sends AT commands over UART to the ESP. Older pattern; mostly obsolete now since standalone ESPs are cheaper and faster.
From L03-30 onwards we go standalone.
Installing the board support
In Arduino IDE: File → Preferences → "Additional boards manager URLs". Add (comma-separated if you want both):
https://arduino.esp8266.com/stable/package_esp8266com_index.json https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then Tools → Board → Boards Manager → search "esp8266" (install "esp8266 by ESP8266 Community") and "esp32" (install "esp32 by Espressif Systems").
After install, the Board menu has "NodeMCU 1.0", "Wemos D1 R2 & mini", "ESP32 Dev Module", etc. Pick the one matching your board.
Worked Example · Hello, WiFi scanner 25 min
This sketch boots, scans for nearby WiFi networks, and lists them to Serial. No router login needed — just power + USB.
Step 1 — select your board
Tools → Board → ESP8266 → "NodeMCU 1.0 (ESP-12E)" (or your specific board). Set the COM port. Set CPU frequency to 80 MHz (default).
Step 2 — the scanner sketch
// L03-29 · WiFi scanner (works on both ESP8266 and ESP32)
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#endif
void setup() {
Serial.begin(115200);
delay(500);
Serial.println();
Serial.println("# Boot.");
// Disconnect from any previous AP; switch into station (client) mode
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
}
void loop() {
Serial.println("# Scanning...");
int n = WiFi.scanNetworks();
if (n == 0) {
Serial.println("# No networks found.");
} else {
Serial.print("# Found "); Serial.print(n); Serial.println(" networks:");
for (int i = 0; i < n; i++) {
Serial.print(" ");
Serial.print(WiFi.SSID(i));
Serial.print(" RSSI: ");
Serial.print(WiFi.RSSI(i));
Serial.print(" dBm ");
// Encryption: 0 = open, 7 (ESP8266) / others = WEP/WPA/WPA2/...
Serial.println(WiFi.encryptionType(i) == 0 /* OPEN */ ? "(open)" : "(secured)");
}
}
Serial.println();
delay(10000);
}The #if defined(ESP8266) / ESP32 block at the top is a one-time compile-time switch — the right WiFi library is included depending on which board you compiled for. The rest of the API is identical.
Step 3 — upload + open Serial Monitor at 115200 baud
(Note: ESP boards default to 115200, not 9600. Watch out — set Serial Monitor to match.)
You should see something like:
# Boot. # Scanning... # Found 7 networks: Home-WiFi RSSI: -42 dBm (secured) Neighbour-5G RSSI: -78 dBm (secured) AisyahPhone RSSI: -64 dBm (secured) Cafe-Guest RSSI: -82 dBm (open) ...
Step 4 — understand RSSI
RSSI = Received Signal Strength Indicator, in dBm (decibels relative to 1 milliwatt). A more-negative number = weaker signal.
| RSSI | Quality |
|---|---|
| −30 to −50 dBm | Excellent (in the same room as the router) |
| −50 to −70 dBm | Good |
| −70 to −85 dBm | Poor but usable |
| < −85 dBm | Connection drops, retransmissions |
Move the ESP closer to your router — the RSSI for your home network should improve. Move it into the next room — it drops.
Step 5 — try to find your phone's hotspot
On your phone, turn on the personal hotspot (Settings → Hotspot). Re-run the scanner. Your phone's hotspot SSID should show up in the list — the ESP will see it from across the room. Useful in classrooms with no managed WiFi.
Step 6 — quick comparison if you have both boards
Upload the same sketch to an ESP8266 and an ESP32. Both list the same networks. The ESP32 typically completes a scan faster (~2 s vs ~5 s) and finds slightly more (better radio sensitivity). For most uses the difference is invisible.
Try It Yourself 15 min
Goal: Light the on-board LED (NodeMCU: D4 active-low; ESP32 DevKit: GPIO2) when scanning, off when waiting. Visible "heartbeat".
Hint
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // ON on NodeMCU (active-low)
int n = WiFi.scanNetworks();
digitalWrite(LED_BUILTIN, HIGH); // OFFNodeMCU's built-in LED is wired backwards (LOW = on). One of the classic ESP8266 gotchas.
Goal: Sort the scan results by RSSI so the strongest network appears first.
Hint
Both libraries support WiFi.scanNetworks(false, false) with a 3rd argument: WiFi.scanNetworks(false, false, true) may sort (varies by library). Easier: read all results into arrays, then sort with a simple bubble sort or qsort. For just listing 5 networks, brute-force is fine.
Goal: Triangulate using RSSI. Put the ESP somewhere in your home and record the RSSI of three known WiFi sources (your router, a smart speaker, your phone's hotspot). Move the ESP and re-record. With three values you can roughly estimate your position relative to the three. This is the basic idea behind every "indoor positioning" demo.
Hint
No code required — this is a paper / spreadsheet exercise. Record (location, RSSI for each AP). Plot. The trade-offs (multipath, reflections, body absorption) explain why this works much worse than GPS outdoors but is good enough for "am I in the living room or the kitchen".
Mini-Challenge · Document your ESP board 10 min
- In your engineering notebook, start an "ESP boards" section.
- Record for your specific board: model name, chip, flash size, USB-serial chip (CH340 vs CP2102), USB connector (micro vs USB-C), pin count, voltage.
- Note any quirks: BOOT-button-during-upload needed? Different default Serial baud? On-board LED active-low?
- Take a clear photo of the board and annotate pins you'll use for: power, GND, the on-board LED, a couple of free GPIO.
Future-you will be juggling 3 different ESP variants by Level 4. This card saves an hour of confusion each time.
Recap 5 min
ESP8266 = cheap and simple, WiFi only. ESP32 = more powerful, WiFi + BLE. Both program through the Arduino IDE via board support packages you install once. Both run 3.3 V logic — protect inputs from 5 V signals with a level shifter. The WiFi scanner sketch is the first useful demo: it confirms the board boots, the library compiles, and the radio works. Tomorrow we actually connect to a network, deal with credentials, and start being a real WiFi client.
- ESP8266
- Espressif's 80 MHz WiFi-only microcontroller (2014). Used in NodeMCU, Wemos D1 mini, and many cheap modules.
- ESP32
- Espressif's 240 MHz dual-core successor (2016). WiFi + Bluetooth Classic + BLE; many more GPIO; 12-bit ADC. The classroom standard now.
- NodeMCU
- A widely-cloned ESP8266 dev board with a CH340 USB-serial chip and a pin layout convention (D0..D8 + A0).
- WROOM
- The shielded module containing the ESP32 chip + flash + antenna. Most ESP32 dev boards have a WROOM-32 in the middle.
- Station mode (WIFI_STA)
- The board acts as a WiFi client — connects to an existing access point. The default for our lessons.
- Access Point mode (WIFI_AP)
- The board acts as its own WiFi router — other devices connect to it. Useful for captive-portal config, standalone setups.
- RSSI
- Received Signal Strength Indicator, in dBm. More negative = weaker. The most common signal-quality metric.
- 3.3 V logic
- All ESP boards run their GPIO at 3.3 V. Plugging a 5 V signal into them can damage the chip. Use a level shifter or voltage divider for 5 V → 3.3 V.
- Board support package
- The plugin you install via the Boards Manager that adds support for a chip family to the Arduino IDE. ESP8266 and ESP32 each need their own package.
Homework 5 min
- Install the ESP8266 and / or ESP32 board package. Upload the WiFi scanner. Confirm you see at least one network.
- In your notebook, list 3 WiFi networks your ESP can see, with their RSSI. Note which is your home / school network.
- Have your home WiFi's SSID and password ready for tomorrow. We'll connect.
- Read ahead to ARD-L03-30 (Connecting to a Network).
Bring back next class:
- Working scanner sketch + your scan list.
- WiFi credentials for the network you'll connect to.