Français

Lessons · Lesson W1 · Wireless and connected things · 45 min

Wi-Fi and radio (alerts, web pages, board-to-board)

Join your Wi-Fi without sharing your password, send an alert to your phone, serve a tiny control page, and make two boards talk by radio. About 45 minutes.

Your board has a radio

So far your board has talked to you through a cable. But the ESP32 also contains a radio, and with it you can do three new things:

  1. Join your Wi-Fi like a phone does, and reach the internet [3].
  2. Send an alert to your phone, from anywhere in your home, with no cable.
  3. Talk to another board directly, without any router, with a protocol called ESP-NOW [5].

Picture a letter. Your board writes a short note, hands it to the router (the mailbox at your door), the note travels to a free message service called ntfy (the sorting centre), and the ntfy app on your phone (the neighbour who rings your bell) delivers it. Every step is a real machine, and in this lesson you build the first one.

From your board to your phone A journey map, left to right. 1, your ESP32 board, with a speech bubble POST: it writes the note. 2, the home router, the mailbox at your door, reached by Wi-Fi. 3, a cloud labelled ntfy.sh, the sorting centre, reached over the internet. 4, your phone with a ringing bell, the neighbour who rings your bell: the ntfy app shows Button pressed. A privacy card: the topic name works like a password, because all ntfy.sh topics are public; make it long and random, keep it in secrets.h, and never put a name or a place in a message or a topic. At the bottom, a separate dotted arrow between two boards, labelled ESP-NOW: no router. FIG. 1 — THE MESSAGE JOURNEYPOSTWi-Fiinternetntfy.shalertButtonpressed1your boardwrites the note2home routerthe mailbox at your door3ntfy servicethe sorting centre4your phonerings your bellThe topic name works like a password: every topic on ntfy.sh is public.Long and random (letters, digits, - and _, up to 64), kept in secrets.h.Never a name, an address or a room in a message or a topic.ESP-NOW: no routerboard Aboard B
Tap the diagram to open it full screen.

Join Wi-Fi, keep the password private

To join a home network, the board works in station mode: it behaves like a phone or a laptop [3]. Your sketch gives it the network name and the password with WiFi.begin(name, password), then waits until WiFi.status() says WL_CONNECTED [3]. Once connected, WiFi.localIP() gives the board’s address on your network [3].

Never write your password in a sketch you might share. A sketch you post on a forum, give to a friend or upload to a website carries everything inside it. So keep the private values in a second file:

  1. Next to your sketch, create a file named secrets.h (in Arduino IDE 2: the ⋯ button at the right of the tabs, then New Tab). It holds only the name, the password and (later) your topic.
  2. In the sketch, #include "secrets.h" reads it when you press upload.
  3. When you share your work, share the sketch and a placeholder copy named secrets.example.h with dummy values. Never share secrets.h.

Save it in the sketch’s own folder, next to the .ino file. If the sketch was open in the IDE, close and reopen it so the IDE picks up the new file. This is the placeholder:

// secrets.example.h : a PLACEHOLDER file. Dummy values only.
// Copy this file, name the copy secrets.h (same folder as the sketch), then type your real values in
// secrets.h. Never share secrets.h, never put it online: share only this example file.
#pragma once

#define WIFI_NAME  "YourWiFiName"        // your 2.4 GHz Wi-Fi network name
#define WIFI_PASS  "YourWiFiPassword"    // its password
// Your phone-alert topic: a long random name made only of letters, digits, - and _ (64 characters max).
// Anyone who guesses it can read your alerts: do not use your name, your street or a word you would say aloud.
#define NTFY_TOPIC "change-me-to-a-long-random-name-k7x2q9"

If you ever paste a real password into something public, change it at once on your router.

Two radio facts. Use a 2.4 GHz network: if your router offers separate 2.4 and 5 GHz names, pick the 2.4 one, because the ESP32 radio works on 2.4 GHz only [8]. And while Wi-Fi is on, the pins called ADC2 cannot read analog values [7]. Read analog sensors on ADC1 pins (GPIO 32 to 39) instead [7]. See lesson K3 for analog reading. The sketches below only use the pins as plain on/off.

What you share, what stays with you Two side-by-side panels. Left, Shared with friends: two files, sketch.ino, which says #include "secrets.h", and secrets.example.h, which holds only dummy values: YourWiFiName, YourWiFiPassword and change-me as the topic. Right, Stays on your computer: secrets.h with a padlock, holding your real network name, password and topic, drawn hidden. It sits in the sketch folder, next to the .ino file, and is never shared or put online. FIG. 2 — KEEP THE PASSWORD PRIVATEaShared with friendssketch.ino#include "secrets.h"WiFi.begin(WIFI_NAME, WIFI_PASS);secrets.example.h#define WIFI_NAME "YourWiFiName"#define WIFI_PASS "YourWiFiPassword"#define NTFY_TOPIC "change-me-…"dummy values onlyshare these two filesbStays on your computersecrets.hWIFI_NAMEWIFI_PASSNTFY_TOPICyour real valuesIn the sketch folder,next to the .ino file.Never shared, never online.
Tap the diagram to open it full screen.

A phone alert with ntfy

ntfy is a free service that turns a web request into a phone notification. You pick a topic, a name for your private channel. Anything posted to https://ntfy.sh/<your topic> pops up on every phone subscribed to that topic [1][2]. Your board posts with an HTTP POST: a web request whose body is your text [1].

Privacy first. There is no sign-up, so the topic works like a password [1]. And all topics on ntfy.sh are public: anyone who guesses yours can read it [1]. So:

  • Make the topic long and random, with letters, digits, dashes and underscores, up to 64 characters [1]. The ntfy page has a generator that adds a random ending [1].
  • Keep the topic in secrets.h, not in the shared sketch.
  • Never put a name, an address, a room or any personal detail in a message or a topic. Say “Button pressed”, not who or where.

Set up your phone: install the ntfy app (Android or iPhone) and subscribe to your topic [2].

Wiring: a push button between GPIO 27 and GND. Upload this sketch and open the Serial Monitor at 115200 baud:

// Tinker Mission, lesson W1: a phone alert with ntfy (press a button, your phone buzzes)
// Board: ESP32 DevKitC, "esp32 by Espressif" 3.3.x. No extra library: WiFi and HTTPClient come with the board package.
// Wiring: push button between GPIO 27 and GND (the board's built-in pull-up keeps the pin HIGH until you press).
// Before you upload: create secrets.h next to this sketch (copy secrets.example.h) and fill in your own values.
// Open the Serial Monitor at 115200 baud. Install the free ntfy app on your phone and subscribe to your topic.

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include "secrets.h"   // WIFI_NAME, WIFI_PASS and NTFY_TOPIC live here, in a file you never share

const int BUTTON_PIN = 27;                       // pressed = LOW
const unsigned long WIFI_TIMEOUT_MS = 15000;     // give up on Wi-Fi after 15 s
const unsigned long MIN_GAP_MS = 10000;          // at most one alert every 10 s
unsigned long lastAlert = 0;
bool alertSentOnce = false;

// Try to join the Wi-Fi network. Returns true when connected.
bool connectWifi() {
  if (WiFi.status() == WL_CONNECTED) {
    return true;
  }
  Serial.print("Connecting to Wi-Fi");
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_NAME, WIFI_PASS);
  unsigned long start = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - start < WIFI_TIMEOUT_MS) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("Connected. IP address: ");
    Serial.println(WiFi.localIP());
    return true;
  }
  Serial.println("No Wi-Fi. Check the name, the password and that it is a 2.4 GHz network.");
  return false;
}

// Send one short message to your ntfy topic: an HTTP POST whose body is the text.
void sendAlert(const char* text) {
  WiFiClientSecure client;
  client.setInsecure();                          // skips the server identity check, to keep this lesson short
  HTTPClient http;
  http.setConnectTimeout(5000);                  // never wait more than 5 s for the server
  http.setTimeout(5000);
  http.begin(client, String("https://ntfy.sh/") + NTFY_TOPIC);
  int code = http.POST(text);                    // the answer code, or a negative number if it failed
  Serial.print("Server answer: ");
  Serial.println(code);
  http.end();
}

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  connectWifi();
}

void loop() {
  bool pressed = (digitalRead(BUTTON_PIN) == LOW);
  unsigned long now = millis();
  bool waitedEnough = !alertSentOnce || (now - lastAlert >= MIN_GAP_MS);

  if (pressed && waitedEnough) {
    lastAlert = now;
    alertSentOnce = true;
    if (connectWifi()) {
      Serial.println("Sending the alert...");
      sendAlert("Button pressed on my ESP32.");  // keep names and personal details out of messages
    }
  }
  delay(20);   // a short pause: this sketch has no other job to do
}

Download the sketch folder (.zip)

Press the button: your phone should ring within a few seconds. How it works: http.begin gives the address, http.POST(text) sends the note and returns a number (negative if it could not reach the server). The sketch also waits 10 seconds between alerts, so a stuck button cannot flood your phone. One more thing to know: client.setInsecure() keeps the connection encrypted but skips checking that the server really is ntfy.sh, to keep the lesson short. A device on your network, or on the way to ntfy, could pretend to be ntfy and read or block the alert. That is acceptable for a hobby alert like “Button pressed”, never for passwords or personal data. A finished product checks the server’s certificate.

The mission 01 alarm uses the same ntfy idea for its phone bonus. That sketch keeps its values at the top: once you have typed yours in, do not share it.

Follow the alert (interactive)
Follow the alert (interactive) Interactive simulation, not a real network. Four stops in a row: your board, the home router, the ntfy.sh service and your phone. Press the button: an envelope travels from stop to stop, lighting each one, and the phone rings. Below, the topic name in the address ntfy.sh/topic. Toggle it: the short name ir-alarm shows a warning, anyone could guess this, and when the alert arrives a stranger's phone rings too; the long random name gets a tick. A panel lists what each stop can see. simulation, not a real networkntfyboardrouterntfy.shphonetopicntfy.sh/tm-k7x2q9-v4wz8n-p3rj

Simulation: nothing is sent, nothing leaves this page.

Press the button to send the alert.

What each stop can see

Envelope
“Button pressed on my ESP32.” No name, no place.
Router
That your board talks to ntfy.sh, when, and how much. Not the text: HTTPS hides it.
ntfy.sh
The topic, the text and your home's internet address.
Anyone with the topic
The text of every alert.

This is the starting state: the controls need JavaScript.


A web page on your board

Your board can also be a web server: a tiny website that lives on the board. Any phone or laptop on the same Wi-Fi can open it, just as it opens any page. The browser asks, the board answers [4].

Wiring: GPIO 26, a 220 Ω resistor, the long leg of an LED, then its short leg to GND. Upload this sketch, open the Serial Monitor at 115200 baud, and wait for an address like http://192.168.1.42:

// Tinker Mission, lesson W1: a tiny control web page served by the board (switch an LED from a phone)
// Board: ESP32 DevKitC, "esp32 by Espressif" 3.3.x. No extra library: WiFi and WebServer come with the board package.
// Wiring: GPIO 26 -> 220 ohm resistor -> LED long leg; LED short leg -> GND.
// Before you upload: create secrets.h next to this sketch (copy secrets.example.h) and fill in your own values.
// Open the Serial Monitor at 115200 baud: the board prints its address. Type it in a browser on the SAME Wi-Fi.
// The page has no password: anybody on your Wi-Fi can use it. Keep it on your home network.

#include <WiFi.h>
#include <WebServer.h>
#include "secrets.h"   // WIFI_NAME and WIFI_PASS live here, in a file you never share

const int LED_PIN = 26;
bool ledOn = false;

WebServer server(80);   // a web server on port 80, the usual web port

// Build the page: a title, the state, and two big links.
String makePage() {
  String page = "<!DOCTYPE html><html><head><meta charset=\"utf-8\">";
  page += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
  page += "<title>My ESP32</title></head><body style=\"font-family:sans-serif;text-align:center\">";
  page += "<h1>My ESP32</h1>";
  page += "<p>The LED is <strong>";
  page += ledOn ? "ON" : "OFF";
  page += "</strong>.</p>";
  page += "<p><a href=\"/on\" style=\"font-size:2em\">Turn ON</a></p>";
  page += "<p><a href=\"/off\" style=\"font-size:2em\">Turn OFF</a></p>";
  page += "</body></html>";
  return page;
}

void handleRoot() {
  server.send(200, "text/html", makePage());
}

// After a click, change the LED, then send the browser back to the main page.
void handleOn() {
  ledOn = true;
  digitalWrite(LED_PIN, HIGH);
  server.sendHeader("Location", "/");
  server.send(303);
}

void handleOff() {
  ledOn = false;
  digitalWrite(LED_PIN, LOW);
  server.sendHeader("Location", "/");
  server.send(303);
}

void handleNotFound() {
  server.send(404, "text/plain", "Nothing here.");
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_NAME, WIFI_PASS);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.print("Open this address in a browser: http://");
  Serial.println(WiFi.localIP());

  server.on("/", handleRoot);       // which function answers which address
  server.on("/on", handleOn);
  server.on("/off", handleOff);
  server.onNotFound(handleNotFound);
  server.begin();
}

void loop() {
  server.handleClient();   // answer any browser that is asking
  delay(2);                // lets the processor do its other tasks
}

Download the sketch folder (.zip)

Type that address in a browser on a phone or laptop connected to the same Wi-Fi. You should see a small page with two links that switch the LED.

How it works: WebServer server(80) makes a server on the usual web port [4]. server.on("/on", handleOn) says “when the browser asks for /on, run handleOn” [4]. server.handleClient() in loop() answers anybody who is asking [4]. server.send(200, ...) is the answer [4]. After a click, the board sends the browser back to the main page.

Safety note. This page has no password: anybody on your Wi-Fi can use it. Keep it for your home network, and never set your router to open it to the whole internet.

The browser asks, the board answers Left, a phone browser showing the board's page: My ESP32, The LED is ON, and two links, Turn ON and Turn OFF. An arrow labelled GET /on goes to the ESP32 board on the right. A second arrow, page again, comes back to the phone. Next to the board, GPIO 26, a 220 ohm resistor and an LED to GND, lit. Note: phone and board on the same Wi-Fi; the page has no password, so keep it on your home network. FIG. 3 — A WEB PAGE ON YOUR BOARD192.168.1.42My ESP32The LED is ONTurn ONTurn OFFthe page comes from the board(texts written in the sketch)GET /onpage again(the LED is now ON)ESP32: a tiny web server26220 ΩLEDPhone and board on the same Wi-Fi.No password on this page: anybody on your Wi-Fi can use it.Keep it on your home network.
Tap the diagram to open it full screen.

Two boards, no router: ESP-NOW

ESP-NOW lets boards send short messages straight to each other, with no connection set up first [5]. No router, no password, no internet. One board is the sender, the other the receiver.

What to know:

  • A message holds up to 250 bytes with the original version of the protocol, plenty for a short text [5].
  • To send to everybody in range, you add the broadcast address (FF:FF:FF:FF:FF:FF) as a peer first [5]. The receiver does not need to add anything to hear broadcasts [5].
  • Both boards must be on the same Wi-Fi channel [5][6]. The sketches below both pick channel 1.
  • Delivery is not guaranteed: a message can be lost [5].
  • Broadcast messages are not encrypted [5]. Never send private information this way.
  • The function that receives a message runs inside the Wi-Fi task, so keep it very short [5]: it only copies the text and raises a flag, and loop() does the rest.

Board A (sender). Button between GPIO 27 and GND:

// Tinker Mission, lesson W1: ESP-NOW, the sender (board A)
// Board: ESP32 DevKitC, "esp32 by Espressif" 3.3.x. No router, no password: the two boards talk directly.
// Wiring: push button between GPIO 27 and GND.
// Each press broadcasts a short text. Any receiver board on the same channel within range can hear it.
// Messages are NOT encrypted when broadcast: never send anything private. Open the Serial Monitor at 115200 baud.

#include <WiFi.h>
#include <esp_now.h>

const int BUTTON_PIN = 27;           // pressed = LOW
const int CHANNEL = 1;               // both boards must use the same channel
uint8_t BROADCAST_ADDRESS[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};   // "everybody"
int counter = 0;
bool wasPressed = false;

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  WiFi.mode(WIFI_STA);               // ESP-NOW needs the Wi-Fi radio switched on, but no network
  WiFi.setChannel(CHANNEL);
  while (!WiFi.STA.started()) {
    delay(100);
  }

  if (esp_now_init() != ESP_OK) {
    Serial.println("ESP-NOW did not start. Reset the board.");
    while (true) {
      delay(1000);
    }
  }

  esp_now_peer_info_t peer = {};     // fill the "address book entry" for the broadcast address
  memcpy(peer.peer_addr, BROADCAST_ADDRESS, 6);
  peer.channel = 0;                  // 0 = use the channel the board is on now
  peer.encrypt = false;
  if (esp_now_add_peer(&peer) != ESP_OK) {
    Serial.println("Could not add the broadcast address.");
  }
  Serial.println("Ready. Press the button to send.");
}

void loop() {
  bool pressed = (digitalRead(BUTTON_PIN) == LOW);
  if (pressed && !wasPressed) {      // only on the moment of pressing, not while held
    counter = counter + 1;
    char message[32];
    snprintf(message, sizeof(message), "TM1:press %d", counter);   // "TM1:" marks our own messages
    esp_err_t result = esp_now_send(BROADCAST_ADDRESS, (const uint8_t*)message, strlen(message) + 1);
    Serial.print("Sent \"");
    Serial.print(message);
    Serial.println(result == ESP_OK ? "\"" : "\" (the radio refused it)");
  }
  wasPressed = pressed;
  delay(20);   // a short pause also hides the button's tiny bounces
}

Download the sketch folder (.zip)

Board B (receiver). GPIO 26, a 220 Ω resistor, the LED’s long leg, then its short leg to GND:

// Tinker Mission, lesson W1: ESP-NOW, the receiver (board B)
// Board: ESP32 DevKitC, "esp32 by Espressif" 3.3.x. Upload this to the SECOND board.
// Wiring: GPIO 26 -> 220 ohm resistor -> LED long leg; LED short leg -> GND.
// Each message from the sender toggles the LED and prints the text. Open the Serial Monitor at 115200 baud.

#include <WiFi.h>
#include <esp_now.h>

const int LED_PIN = 26;
const int CHANNEL = 1;                 // must be the same as on the sender

volatile bool newMessage = false;      // set by the radio callback, read by loop()
char lastMessage[32] = "";

// Called by the radio when a message arrives. Keep it short: just copy the text and raise a flag.
void onReceive(const esp_now_recv_info_t* info, const uint8_t* data, int len) {
  if (len < 5 || len > (int)sizeof(lastMessage) || memcmp(data, "TM1:", 4) != 0) {
    return;                            // not one of our messages: ignore it
  }
  memcpy(lastMessage, data, len);
  lastMessage[len - 1] = '\0';         // make sure the text ends properly
  newMessage = true;
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);

  WiFi.mode(WIFI_STA);
  WiFi.setChannel(CHANNEL);
  while (!WiFi.STA.started()) {
    delay(100);
  }

  if (esp_now_init() != ESP_OK) {
    Serial.println("ESP-NOW did not start. Reset the board.");
    while (true) {
      delay(1000);
    }
  }
  esp_now_register_recv_cb(onReceive);
  Serial.println("Ready. Waiting for the sender...");
}

void loop() {
  if (newMessage) {
    newMessage = false;
    digitalWrite(LED_PIN, !digitalRead(LED_PIN));   // flip the LED
    Serial.print("Received: ");
    Serial.println(lastMessage);
  }
  delay(10);
}

Download the sketch folder (.zip)

Upload each sketch to its own board, one at a time. Power both, open the sender’s Serial Monitor, and press the button: the LED on board B should flip each time. The sender marks its messages with TM1: and the receiver ignores anything else, so a stranger’s board cannot flip your LED by accident.

Two boards, no router Two ESP32 boards face each other with radio-wave arcs between them. Left, board A, the sender, with a push button on GPIO 27. Right, board B, the receiver, with an LED on GPIO 26 that flips on each message. Between them, a message tag TM1:press 3. Above, a router icon crossed out: no router, no password. Notes: both boards on the same Wi-Fi channel, 1 here; up to 250 bytes per message; delivery not guaranteed; broadcast not encrypted, so never send anything private. FIG. 4 — ESP-NOW, BOARD TO BOARDno router, no passwordTM1:press 327GNDA: senderbutton on GPIO 2726GND220 ΩB: receiverLED on GPIO 26 flipsSame Wi-Fi channel on both boards (1 here). Up to 250 bytes per message.A message can be lost. Broadcast is not encrypted: never send anything private.
Tap the diagram to open it full screen.

Try your own changes

Change one thing, then observe.

  1. A different message. In the ntfy sketch, change the text to “Test 1”. Does your phone show it?
  2. One page, one LED. In the web page sketch, change the page title and the link texts. What happens if you ask for /blink, an address that does not exist?
  3. Count the presses. In the receiver, print how many messages arrived. Hint: add a counter next to newMessage.
  4. Walk away. Carry board A a few steps away, then through a wall. When does the LED stop reacting?

When it does not work

  • No Wi-Fi. Check the name and password in secrets.h, case included, and that your network is 2.4 GHz. Open the Serial Monitor at 115200 baud to read the messages. If the web page sketch prints dots forever, the name or password is wrong.
  • “Server answer” is a negative number. The board could not reach ntfy: check the internet connection, then try again.
  • Nothing on the phone. The topic must be spelled exactly the same in secrets.h and in the app. Check that the app is allowed to show notifications.
  • The web page does not open. The phone must be on the same Wi-Fi as the board (not mobile data). Re-read the address in the Serial Monitor: it may have changed after a restart. Some guest networks stop devices from talking to each other.
  • ESP-NOW: nothing happens. Both boards must use the same channel [5][6]. Check the sender’s Serial Monitor: if it prints “radio refused”, reset the board. Delivery is never guaranteed [5].
  • An analog sensor reads zero while Wi-Fi is on. It may be on an ADC2 pin: move it to an ADC1 pin [7].
  • The sketch does not compile: “secrets.h: No such file”. Create the file next to the sketch, as in screen 2.

Check yourself

Three short questions. Nothing is saved, take your time.

  1. Where should your Wi-Fi password go when you plan to share your sketch?

    • In a separate secrets.h file that you never share
    • At the top of the sketch, so friends can run it right away
    • In the message you send to your phone
    Show the answer

    In a separate secrets.h file that you never share. A shared sketch carries everything written in it. Keeping the name and password in a separate secrets.h, and sharing only a placeholder copy, keeps them private. This is the habit of the lesson.

  2. Anyone can read what is posted on ntfy.sh if they know the topic name. What do you do about it?

    • Nothing, nobody ever looks
    • Use a long random topic name and keep personal details out of the messages
    • Use your own first name as the topic so you remember it
    Show the answer

    Use a long random topic name and keep personal details out of the messages. On ntfy.sh all topics are public, and with no sign-up the topic works like a password, so it must be hard to guess [1]. A topic can be up to 64 characters of letters, digits, dashes and underscores [1].

  3. You make two boards talk with ESP-NOW. What must match on both?

    • The colour of the LED
    • The Wi-Fi password of your router, which both must know
    • The Wi-Fi channel they use
    Show the answer

    The Wi-Fi channel they use. ESP-NOW has no router and no password to join: the boards must simply be on the same Wi-Fi channel [5][6]. Delivery is still not guaranteed [5].


In short

  • Keep your Wi-Fi name, password and topic in secrets.h, and share only secrets.example.h.
  • The ESP32 joins 2.4 GHz Wi-Fi in station mode with WiFi.begin, then waits for WL_CONNECTED [3].
  • ntfy turns an HTTP POST into a phone notification. All ntfy.sh topics are public: use a long random topic and no personal information [1][2].
  • A WebServer makes a tiny page on your board, with no password: keep it at home [4].
  • ESP-NOW sends short messages (250 bytes) between boards with no router. Same channel needed, no delivery guarantee, broadcast not encrypted [5][6].
  • ADC2 pins cannot be read as analog while Wi-Fi is on [7].

Next steps: switch bigger things with a signal (C2), or try the phone bonus of mission 01.


Sources

Show the 8 sources
  1. ntfy, documentation, “Publishing” (messages sent with HTTP PUT or POST; topics are created on the fly; with no sign-up the topic acts as a password and should be hard to guess; topic names use letters, digits, underscores and dashes, up to 64 characters; a name generator adds a random suffix; “all topics on ntfy.sh are public”) — https://docs.ntfy.sh/publish/
  2. ntfy, documentation, “Subscribe from your phone” (Android and iOS apps; add a topic, then publish messages to it) — https://docs.ntfy.sh/subscribe/phone/
  3. Espressif, Arduino-ESP32 documentation, “Wi-Fi API” (802.11 b/g/n driver; station mode connects the board to an access point; WiFi.begin, loop until WL_CONNECTED, then WiFi.localIP()) — https://docs.espressif.com/projects/arduino-esp32/en/latest/api/wifi.html
  4. Espressif, arduino-esp32 repository, WebServer example “HelloServer” (WebServer server(80), server.on(path, handler), server.begin(), server.handleClient() in loop(), server.send(200, ...), onNotFound) — https://raw.githubusercontent.com/espressif/arduino-esp32/master/libraries/WebServer/examples/HelloServer/HelloServer.ino
  5. Espressif, ESP-IDF Programming Guide, “ESP-NOW” (connectionless protocol; 250 bytes per message in v1.0; broadcast address must be added as a peer before sending; a receiver needs no peer to get broadcasts; the channel must match the one the device is on; delivery is not guaranteed; no encryption for multicast frames; the receive callback runs in the Wi-Fi task and must be short) — https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/network/esp_now.html
  6. Espressif, Arduino-ESP32 documentation, “ESP-NOW” (broadcast sender and receiver examples; Wi-Fi in station mode, channel set with WiFi.setChannel, wait for WiFi.STA.started()) — https://docs.espressif.com/projects/arduino-esp32/en/latest/api/espnow.html
  7. Espressif, ESP-IDF Programming Guide, “GPIO & RTC GPIO” (ADC2 pins cannot be used when Wi-Fi is used; use an ADC1 pin instead; ADC1 channels are on GPIO 32 to 39) — https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/gpio.html
  8. Espressif, “ESP32 Series Datasheet” v5.3 (a single 2.4 GHz Wi-Fi and Bluetooth chip; 802.11 b/g/n in the 2.4 GHz band) — https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf

Pinch or double-tap to zoom, swipe to change diagram.Scroll with Ctrl or double-click to zoom. Arrow keys change diagram.