How To Enable ESP NOW Long Range Mode in Arduino
Posted: Sat Apr 22, 2023 9:40 am
Hello,
I am developing a Serial to Serial via WiFi (Radio Modem) using a pair ESP32 WROOM-32 boards.
This project is in test and is running reliable for hours sending 250 byte packets to each other.
This radio modem project is for an autonomous wheeled Robot.
Where one ESP32 is driven by an App in a PC, with the other ESP32 is in the Robot.
Now this is working well although the range seems limited to about 11m through three brick walls before I get lost massages.
So I thought I would try to configure these ESP32 WROOM-32 boards in Long Range Mode.
Well I have researched much and tried many permutations of Arduino setup to enable Long Range Mode but none seem to work.
Can someone take a look at this setup code below to see if correct please.
Many thanks in advance imk
WiFi.mode( WIFI_AP_STA );
// Initilize ESP-NOW
if( esp_now_init() != ESP_OK )
{
Serial.println("Error initializing ESP-NOW");
return;
}
// Set Long Range Mode
esp_wifi_set_protocol( WIFI_IF_STA , WIFI_PROTOCOL_LR);
// Register callback function
esp_now_register_recv_cb( OnDataRecv );
// Register the send callback
esp_now_register_send_cb( OnDataSent );
// Register peer to Send To
memcpy( peerInfo.peer_addr, broadcastAddress, 6 );
peerInfo.channel = 0;
peerInfo.encrypt = false;
// Add peer
if( esp_now_add_peer( &peerInfo ) != ESP_OK )
{
Serial.println("Failed to add peer");
return;
}
I am developing a Serial to Serial via WiFi (Radio Modem) using a pair ESP32 WROOM-32 boards.
This project is in test and is running reliable for hours sending 250 byte packets to each other.
This radio modem project is for an autonomous wheeled Robot.
Where one ESP32 is driven by an App in a PC, with the other ESP32 is in the Robot.
Now this is working well although the range seems limited to about 11m through three brick walls before I get lost massages.
So I thought I would try to configure these ESP32 WROOM-32 boards in Long Range Mode.
Well I have researched much and tried many permutations of Arduino setup to enable Long Range Mode but none seem to work.
Can someone take a look at this setup code below to see if correct please.
Many thanks in advance imk
WiFi.mode( WIFI_AP_STA );
// Initilize ESP-NOW
if( esp_now_init() != ESP_OK )
{
Serial.println("Error initializing ESP-NOW");
return;
}
// Set Long Range Mode
esp_wifi_set_protocol( WIFI_IF_STA , WIFI_PROTOCOL_LR);
// Register callback function
esp_now_register_recv_cb( OnDataRecv );
// Register the send callback
esp_now_register_send_cb( OnDataSent );
// Register peer to Send To
memcpy( peerInfo.peer_addr, broadcastAddress, 6 );
peerInfo.channel = 0;
peerInfo.encrypt = false;
// Add peer
if( esp_now_add_peer( &peerInfo ) != ESP_OK )
{
Serial.println("Failed to add peer");
return;
}