ESP-NOW is a short-range, low-power communication protocol that enables multiple devices to communicate without Wi-Fi. This protocol is similar to the low-power 2.4GHz wireless connection found in wireless mice—devices are paired before communicating. After pairing, the connections between devices are continuous, peer-to-peer, and do not require a handshake protocol.
Get mac addr Get the mac address of this machine.
Add peer ff as id Add the specified mac address and set it to id
Set pmk Set the pairing key
Broadcast data Broadcast specified data
Receive mac_addr data Receive data, get the sender's mac address and the data content carried
After send message flag Send a callback function, automatically execute the callback function after executing the send message, and return whether the flag bit flag is successfully sent. The success is True and the failure is False.
Send message id with data Send data to the device with the specified id.
Display the local mac address on the screen, use the data receiving block and create two variables for receiving the sender's address and data content. The data is processed inside the receiving block function for display or judgment and other operations. For example, the following program controls the LED light switch by judging whether the received data is "1".
__Note: The created variable name is not allowed to be consistent with the parameter name, ie variables with the names "addr" and "data" are not allowed to be used for data acquisition __
Add the mac address of the receiving device, fill in the sent data content in the sending program, select the id of the receiving device. Use the button program to control the data transmission. Using the callback function can help us determine whether the data is successfully sent from the machine. We need to use a variable to get its return result.
__Note: The created variable name is not allowed to be consistent with the parameter name, ie variables with the name "flag" are not allowed to be used for data acquisition __
Complete the program editing, respectively run the receiver and transmitter programs, you can achieve ESP-NOW short-range wireless communication.
Note: When running ESP-NOW, if the communication devices are connected to the same Wi-Fi network, there is no need to configure the communication channel, and the communication can be normal. Otherwise, please configure the communication channel in the program and download the program to the device for runinng.