ESP-NOW
Your "Secret Messaging"
Direct Wireless Communication Between D1 R32 Boards
What it is
The ESP-NOW category is dedicated to the special wireless communication system exposed by the ESP-NOW blocks in Clu-Blocks Pro.
For the course, the most useful conceptual model is communication directly between D1 R32 boards:
D1 R32 A → ESP-NOW → D1 R32 B
ESP-NOW can therefore be introduced as another communication family alongside:
- Serial
- Infrared
- Bluetooth
- Radio
- Wi-Fi / Network
However, students should treat each as a different communication mechanism with its own Clu-Blocks Pro blocks.
Think of ESP-NOW as a direct board-to-board wireless communication system. One D1 R32 can send information and another D1 R32 can receive and use that information.
Fun Guide to ESP-NOW Communication Blocks (Clu-blocks Pro)
What it does: Connects two or more D1 R32 boards directly witdout Wi-Fi.
Fast: Instant communication between D1 R32 boards
Direct: No routers, board-to-board communication
Important! ESP-NOW blocks let your robot send and receive messages directly to other ESP32 boards fast, secure, and witdout needing a router. It’s like walkie-talkies for robots!
ESP-NOW Wireless Communication Blocks
These blocks allow students to exchange messages wirelessly between ESP32 boards using ESP-NOW. Unlike traditional Wi-Fi communication, ESP-NOW allows compatible devices to communicate directly without needing a Wi-Fi router or internet connection.
ESP-NOW Setup and Device Information
| Block | Block Image | What It Does | What the Options Mean |
|---|---|---|---|
| Initialize ESP-NOW | Creates an ESP-NOW communication object and configures the wireless channel and transmission power. | radio.ESPNow: creates the ESP-NOW interface. channel: Wi-Fi channel used for communication; 1 selects channel 1. txpower: transmission power setting; 20 is the configured value in the library's expected units. |
Device Information
| Block | Block Image | What It Does | What the Options Mean |
|---|---|---|---|
| Get Device MAC Address | Returns the MAC address of the local ESP32 wireless interface. | mac identifies the board using a unique hardware address, usually represented as six hexadecimal pairs. | |
| Get ESP-NOW Information | Retrieves information about the ESP-NOW communication interface. | No arguments are required. The information returned depends on the radio library implementation. |
Receive ESP-NOW Messages
| Block | Block Image | What It Does | What the Options Mean |
|---|---|---|---|
| Receive Message | Receives a message from another ESP-NOW device. | No arguments are required. The returned data structure depends on the library implementation. | |
| Get Sender MAC Address | Accesses the first element of the received message, typically the sender's MAC address. | [0] selects the first element of the returned data. | |
| Get Received Message Data | Accesses the second element of the received message, typically the message data. | [1] selects the second element of the returned data. |
Send ESP-NOW Messages
| Block | Block Image | What It Does | What the Options Mean |
|---|---|---|---|
| Send ESP-NOW Message | Sends the message 'Clu-Bots' to another ESP-NOW device. | First value: destination MAC address. 'FFFFFFFFFFFF' represents the broadcast address, which sends the message to all compatible ESP-NOW devices listening on the same channel. Second value: message or data to send. |
Automatic Message Reception
| Block | Block Image | What It Does | What the Options Mean |
|---|---|---|---|
| Register Receive Callback | Registers a callback function that runs automatically when an ESP-NOW message is received. | handler: the function that processes the incoming message. It is called when the receive event occurs, according to the library implementation. |
Important notes
- No router required: ESP-NOW allows ESP32 boards to communicate directly without connecting to a Wi-Fi router.
- MAC address: Each board has a unique wireless MAC address. It can be used to identify the sender or specify the destination.
- Broadcast address:
'FFFFFFFFFFFF'sends a message to all compatible devices listening on the same channel. - Wireless channel: Both communicating boards must use compatible Wi-Fi channel settings.
- Message reception:
recv()retrieves received data. The callback methodrecv_cb(handler)allows the program to react automatically when a message arrives. - Callback function: A callback is a function that runs in response to an event, such as receiving a wireless message.
- Library dependency:
radio.ESPNow,info(),recv(),send()andrecv_cb()are specific to theradiolibrary used by Clu-Bots, not standard MicroPython commands.
Important programming note
espnow.recv() should generally be called once to obtain a message, and its result should be stored in a variable before accessing [0] and [1].
For example:
# Receive one messagemessage = espnow.recv()# Check that a message was receivedif message: sender = message[0] data = message[1] print("Sender:", sender) print("Message:", data)
This avoids calling recv() multiple times and potentially retrieving different messages or losing the message you intended to inspect.
Note: The descriptions of recv() return values, info(), and callback behavior are based on the apparent structure of these blocks. Their exact behavior should be confirmed against the specific radio library version used in Clu-Bots.
Quick Tips for Students
- Use setup + MAC address to create a secure, direct link between robots.
- Use callback functions to make your robot react instantly like replying or changing behavior.
- Use signal strengtd to check how far apart your robots can be.
- Use message content to send commands like
"forward","stop", or"dance".
1. The Basic ESP-NOW Communication Model
The easiest way to introduce ESP-NOW is with two boards.
Board A
Sends information.
↓
ESP-NOW
Provides the wireless communication path.
↓
Board B
Receives information.
Conceptually:
SENDER → MESSAGE → WIRELESS LINK → RECEIVER
Students should understand this basic relationship before introducing addressing or more advanced communication behavior.
2. Sender and Receiver
ESP-NOW exercises naturally involve at least two program roles.
Sender
Produces information and transmits it.
Conceptually:
DATA
↓
ESP-NOW SEND
↓
Wireless Communication
Receiver
Obtains the transmitted information.
Conceptually:
Wireless Communication
↓
ESP-NOW RECEIVE
↓
DATA
Students should create the sender and receiver programs separately before combining additional sensors or actuators.
3. Start with a Simple Message
The first ESP-NOW experiment should use a recognizable fixed message.
For example:
Plain Text
Clu-Block
Conceptually:
Board A
"Clu-Block" → ESP-NOW Send
↓
Board B
ESP-NOW Receive → "Clu-Block"
The purpose of this exercise is only to establish:
ONE BOARD CAN SEND INFORMATION TO ANOTHER
Nothing more should be added initially.
4. Observe the Received Message Through Serial
Because wireless communication is invisible, the receiving board should report the information through Serial.
Conceptually:
D1 R32 A
↓
ESP-NOW Message
↓
D1 R32 B
↓
Serial Port
↓
PC
This allows students to confirm what Board B actually received.
For your course, this step should be especially important.
🧠 Do not control hardware from received ESP-NOW information until students have first observed and verified that information on the PC.
5. The ESP-NOW Learning Pattern
I recommend using the same progression you established in the sensor exercises:
SEND
Transmit information.
↓
READ
Receive the information.
↓
OBSERVE
Report it through Serial.
↓
INTERPRET
Determine what the received information means.
↓
COMPARE
Use Logic when necessary.
↓
ACT
Control hardware.
So:
SEND → RECEIVE → SERIAL → INTERPRET → ACT
6. Sending a Variable
Once fixed text works, transmitted information can come from a variable.
Conceptually:
Variable
↓
ESP-NOW Send
↓
Receiving Board
For example, a counter could change:
Plain Text
1
2
3
4
and each changing value could conceptually be transmitted to another D1 R32.
This establishes that ESP-NOW communication can carry program-generated information, not only fixed messages.
7. Sending Sensor Information
The next step should introduce physical data.
Conceptually:
Sensor
↓
Reading
↓
ESP-NOW Send
↓
Second D1 R32
↓
Serial Port
↓
PC
For example:
DHT11 → Temperature → ESP-NOW
or:
Ultrasonic → Distance → ESP-NOW
or:
ADXL345 → X/Y/Z data → ESP-NOW
This creates a distributed robotics system:
ONE BOARD SENSES → ANOTHER BOARD RECEIVES
8. Raw Values vs. Readable Messages
As with Bluetooth and Serial, students should learn the difference between raw data and human-readable information.
Raw
Plain Text
23
Readable
Plain Text
Temperature: 23
Conceptually:
Sensor
↓
Measurement
↓
Text Formatting
↓
ESP-NOW Send
↓
Receiver
This combines:
SENSORS → TEXT → ESP-NOW
9. Receiving Commands
ESP-NOW does not need to be used only for sensor values.
A board can conceptually send a command such as:
Plain Text
ON
The receiving board can interpret it as:
Turn an output ON
The communication becomes:
Board A
↓
"ON"
↓
ESP-NOW
↓
Board B
↓
Compare Message
↓
Perform Action
This transforms ESP-NOW from data communication into wireless control.
10. ESP-NOW + Logic
Logic can determine whether the received information matches an expected command.
Conceptually:
Received Message
↓
Equals "ON"?
↓
TRUE / FALSE
Then Control decides what happens.
This creates:
ESP-NOW → LOGIC → CONTROL
11. ESP-NOW + Actuators
After received information has been verified through Serial, it can control physical outputs.
For example:
Board A
Button
↓
ESP-NOW command
↓
Board B
Receive
↓
Logic
↓
LED / Buzzer / Servo
This creates an important robotics model:
REMOTE INPUT → WIRELESS COMMUNICATION → REMOTE ACTION
12. ESP-NOW + Continuous-Rotation Servo
If an ESP-NOW exercise eventually controls the MG90S continuous-rotation servo, the servo side must continue using the real Clu-Blocks Pro generation you established:
Python
servo.servo360_speed(pin, value)
and the corresponding no-value form:
Python
servo.servo360_speed(pin)
The roles remain separate:
ESP-NOW
Provides the communication information.
Servo
Produces the physical rotation.
Conceptually:
ESP-NOW Command → Logic → Servo Control Value → Rotation
13. ESP-NOW + Joystick
A later robotics exercise could conceptually follow:
Joystick on Board A
↓
Direction
↓
ESP-NOW
↓
Board B
↓
Robot Action
This is a natural progression because students have already learned to interpret the joystick into:
- Up
- Down
- Left
- Right
- Center
The important learning concept is:
LOCAL INPUT → REMOTE ACTION
14. ESP-NOW + Displays
A receiving board can also present transmitted information locally.
For example:
Board A
DHT11
↓
ESP-NOW
↓
Board B
OLED / LCD
This produces:
REMOTE SENSOR → WIRELESS DATA → LOCAL DISPLAY
Serial should still be maintained during development so students can verify the received information on the PC.
15. Two-Way Communication
After simple one-direction communication is understood, the two boards can conceptually take both roles.
Board A
SEND → RECEIVE
Board B
RECEIVE → SEND
For example:
Board A sends request
↓
Board B receives request
↓
Board B obtains information
↓
Board B sends response
↓
Board A receives response
This gives students the more complete model:
REQUEST → RECEIVE → PROCESS → RESPONSE
Do not introduce this in the first ESP-NOW exercise.
16. ESP-NOW vs. Bluetooth
Students should keep these communication systems conceptually separate.
Bluetooth
Uses the Bluetooth categories and their associated block interface.
ESP-NOW
Uses the dedicated ESP-NOW category.
Both are wireless communication technologies, but students should not assume that their blocks, configuration, or generated code are interchangeable.
The correct teaching model is:
SAME GOAL: COMMUNICATE
but:
DIFFERENT TECHNOLOGIES → DIFFERENT BLOCKS
17. ESP-NOW vs. Network
ESP-NOW should also remain separate from the Network category.
Network
Students work with concepts such as:
- Wi-Fi connection
- STA/AP
- Network configuration
- TCP
- UDP
- Network services
ESP-NOW
Students should initially focus on:
- Board-to-board communication
- Sending information
- Receiving information
- Acting on received information
This prevents students from incorrectly thinking that all wireless communication requires the same networking workflow.
18. ESP-NOW vs. Radio
This distinction is especially important in your manual.
The previous Radio category was documented from confirmed generated code containing:
Python
ESPNow_radio = radio.ESPNow()
That establishes the internal implementation of the Radio abstraction in the supplied real generation.
However:
RADIO CATEGORY ≠ ESP-NOW CATEGORY DOCUMENTATION
The Radio category should continue to be documented according to its own blocks and confirmed radio.ESPNow() generation.
The dedicated ESP-NOW category must be documented from its own real Clu-Blocks Pro generation.
We should not copy Radio methods into ESP-NOW merely because the Radio implementation references ESPNow.
That distinction is essential.
19. Addressing and Peers
ESP-NOW communication commonly raises questions about which board should receive a message.
However, for this manual we should follow the same strict documentation rule:
Do not assign specific MAC-address syntax, peer-registration methods, broadcast constants, or peer-management procedures to the Clu-Blocks Pro ESP-NOW blocks until those operations are confirmed by the actual generator.
The student-facing model can still safely be:
SENDER → RECEIVER
without inventing the underlying implementation.
20. Message Received Events
Similarly, if the ESP-NOW toolbox contains blocks that visually represent:
When message received
or another event-like operation, we should explain the concept visually while avoiding invented callback methods.
Conceptually:
MESSAGE ARRIVES
↓
DO
↓
Run the blocks inside
But the technical reference should show a Python callback only after the real Clu-Blocks Pro generation confirms it.
Quick Guide for Students
Do I want two D1 R32 boards to exchange information?
Use the dedicated ESP-NOW category.
What should I transmit first?
A simple recognizable message.
What should the receiving board do first?
Send the received information to the PC through Serial.
Why?
To confirm that communication is working before controlling hardware.
Can I send sensor information?
Conceptually:
Sensor → ESP-NOW → Receiving Board
Can I send commands?
Yes:
Command → ESP-NOW → Logic → Action
Can the receiving board answer?
After one-way communication is understood:
Receive → Process → Send Response
Should I reuse the Radio category's generated methods for the dedicated ESP-NOW blocks?
No.
The dedicated ESP-NOW blocks must be documented from their own Clu-Blocks Pro generation.
Quick Reference
| Concept | Main Idea |
|---|---|
| Sender | Board transmitting information |
| Receiver | Board obtaining information |
| Message | Information exchanged between boards |
| Serial Verification | Make received information visible on the PC |
| Variable Data | Send changing program information |
| Sensor Data | Send physical measurements |
| Logic | Interpret received commands |
| Control | Decide what action occurs |
| Actuator | Produce physical response |
| Response | Receiver can later send information back |
| Two-Way Communication | Both boards can eventually send and receive |
