Lessons and the learning game

Wireless links: nRF24 and ESP-NOW

Board to board with no router: nRF24L01+ pipes, acks and retries on Unos, then ESP-NOW peers and a star network on ESP32-C3s, ending on Mars.

The benches

  • nRF24 lessons: two or three Unos, each with an nRF24L01+ on SPI (CE 7, CSN 8, SCK 13, MOSI 11, MISO 12) powered from 3.3 V. The acks lesson adds a button on the hub's pin 2 and a lamp on the node's pin 4.
  • ESP-NOW lessons: two to four ESP32-C3 boards with fixed MACs (02:4D:4F:00:00:01 for the hub or base, 02 to 04 for the others, in each board's wifiMac setting). The boss gives each pod a knob on GPIO 0 and a lamp on GPIO 10, and uses the hub's BOOT button.

Every radio on the canvas shares one air, so each board is wired only to its own parts. Take the course at /learn/path/wireless-sensor-networks on /learn.

The lessons

  1. Radios and addresses. Channel, data rate and address, a reading pipe, and the automatic ACK.
  2. nRF24 pipes. Six pipes, the shared-bytes rule for pipes 2 to 5, and telling senders apart by pipe.
  3. Acks and retries. setRetries, getARC, a deaf hub, and commands in ACK payloads.
  4. ESP-NOW peers. MAC addresses, peers, the send and receive callbacks.
  5. Broadcast vs unicast. Who hears and who acknowledges each.
  6. Many sensors, one hub. A star network with a table by MAC, staggered timing and silence detection.
  7. Boss: a base camp on Mars. Oxygen reports by unicast, a dust storm alert by broadcast, confirmations by unicast, and warnings for low oxygen and silent pods.

What each sketch does

Sketch Board What it does
wsping, wslisten Uno A hut that pings and a base that listens.
wspipehub, wspipea, wspipeb Uno A hub with two pipes and two huts.
wsackhub, wsacknode Uno ACK payload commands and automatic retries.
enhut, enbase ESP32-C3 An ESP-NOW peer and a base.
enbcast, enrecv ESP32-C3 Broadcast and unicast to two receivers.
enhub, enhutn ESP32-C3 A star network hub and its huts.
enmars, enpod ESP32-C3 The Mars habitat hub and pods.

Honest limits

  • Distance, walls, fading and WiFi interference are not modeled: every packet on the right channel and address arrives, and RSSI is fixed. Collisions between radios transmitting at once are modeled.
  • The nRF24's output power setting is stored and does nothing.
  • ESP-NOW encryption is explained, not used.

Device to cloud: telemetry that survives, and the protocol design course for framing and checksums.