MuTech RoboticsLearning Hub
← Back to learning path

Wi-Fi and ESP-NOW

8 min read

An ESP32 has a radio built in, so it can talk without wires. There are two common ways, and they suit different jobs.

Wi-Fi

Wi-Fi connects your board to a router and then to the internet. Use it to show data on a phone, send an alert, or get the time.

#include <WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.begin("your-network", "your-password");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  Serial.println(WiFi.localIP());
}

void loop() {}

Most boards use the 2.4 GHz band only, so a 5 GHz network will not appear.

ESP-NOW

ESP-NOW sends short messages straight from one ESP32 to another. It needs no router and no internet, and it connects almost at once. This makes it a good choice for a glove that controls a robot arm, or a remote sensor.

  • Each message is small, up to 250 bytes.
  • Range is often tens of metres in open space, and less through walls.
  • Each board is found by its MAC address.

Serial.println(WiFi.macAddress());

Set up ESP-NOW

  1. Upload a small sketch to the receiver and note its MAC address.
  2. Put that address in the sender's code.
  3. Define one struct for the data, the same on both boards.
  4. Send it, and read it in the receive callback.

Which should you use?

  • Need the internet or a phone app? Use Wi-Fi.
  • Need two boards to talk quickly, anywhere? Use ESP-NOW.

Never share code that contains your real Wi-Fi password. Remove it before you post or send the file.

Quick quiz

1. Does ESP-NOW need a router?

2. ESP-NOW finds a board by its…

3. Which band do most ESP32 boards use?

Score: 0 / 3
Sign in to track progress