ESP-NOW – yet another way to communicate

After achieving the major goal of finding a final-product-worthy attachment solution of the left hand setup, it was decided to find out how to communicate between two ESP32s. Although the splitter and the mixer were still not working properly, the question of how to communicate between two (or more) ESP32s was still an important issue to solve. The manner of communication at this time of the project was MIDI-BLE so accordingly, solutions involving MIDI-BLE were investigated first. After doing some research, it was determined that communication between two ESP32s was possible via MIDI-BLE but quite complicated. However, another, entirely different option presented itself: apparently there is a way to communicate between several ESP32s using Espressif’s (inventor of ESP32s) native communication protocol called ESP-NOW.

According to the Espressif website, ESP-NOW is yet another protocol developed by Espressif, which enables multiple devices to communicate with one another without using Wi-Fi. The protocol is similar to the low-power 2.4GHz wireless connectivity that is often deployed in wireless mouses. So, the pairing between devices is needed prior to their communication. After the pairing is done, the connection is secure and peer-to-peer, with no handshake being required. Its features include:

  • Quick and automatic connectivity once two or more devices have been paired
  • Fast transmission speed
  • Low power-consumption
  • Improved Range and Reception

These qualities make it ideal for the GPRO project.

Following an online tutorial, it was quickly determined how to connect two ESP32 boards and establish a two-way communication between them. As always, a prototype sketch was made, focusing on the basic functionality of the ESP-NOW protocol. After basic communication capabilities had been achieved, ESP-NOW was integrated into the existing code for the left hand setup and the ToF sensor. The test was successful: now, ON/OFF commands based on the fret detected can be sent via ESP-NOW from the ESP32 connected to the sensor to the ESP32 simulating the future central hardware unit. It was noted that the transmission rate is indeed very fast and appears to be greater than the one of MIDI-BLE.

In a meeting prior to Christmas, the project’s supervisor suggested computing the frets and sending corresponding ON/OFF commands could be done by the ESP32 in the central hardware unit (ESP32-CU) instead of the ESP32 at the headstock (ESP32-HS). This would eliminate the need for the ESP32-CU to send the selected threshold to the ESP32-HS and a one-way communication would be sufficient. This will be done.

The ESP-NOW protocol must still be implemented in the code for the right hand setup and IMU sensor. However, it will likely be just as suitable for the right hand setup as it was for the left hand setup. The code for the right hand setup must still be changed anyways because by using the new and final attachment device for the right hand setup, the IMU sensor will be placed in a different position than before, resulting in the need to adapt the sensor readings. But more of this, in the next blog post…

Sources:

ESP-Now Overview | Espressif Systems

ESP-NOW: Espressif’s Wireless Communication Protocol | Espressif Systems

Getting Started with ESP-NOW (ESP32 with Arduino IDE) | Random Nerd Tutorials

Leave a Reply

Your email address will not be published. Required fields are marked *