I get around 70 m range when the receiver is placed indoors but very close to a large window, and the transmitter is outside. It's not bad, but not what I need.
Here's what I'm doing initializing ESP-NOW on the transmitters ("nodes"):
Code: Select all
// Configuring ESP-NOW
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
// WiFi.mode(WIFI_STA);
// Set Long Range Mode
ESP_ERROR_CHECK(esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR));
//Set the lowest espnow phy rate to maximum range
ESP_ERROR_CHECK(esp_wifi_config_espnow_rate(WIFI_IF_STA, WIFI_PHY_RATE_LORA_250K));
// Init ESP-NOW
if (esp_now_init() != ESP_OK)
{
Serial.println("Error initializing ESP-NOW");
return;
}
// Set transmission power, max 84.
ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(84));
//Register callback to verify if data was sent successfully
esp_now_register_send_cb(OnDataSent);
And the receiver:
Code: Select all
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
// WiFi.mode(WIFI_STA);
// Set custom MAC
esp_wifi_set_mac(WIFI_IF_STA, localCustomMac);
// Set the Long Range mode
ESP_ERROR_CHECK(esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR));
ESP_ERROR_CHECK(esp_wifi_config_espnow_rate(WIFI_IF_STA, WIFI_PHY_RATE_LORA_250K));
// Initialize
if (esp_now_init() != ESP_OK)
{
Serial.println("Error initializing ESP-NOW");
return;
}
// Set transmission power, max 84.
ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(84));
// Register for recv CB to get recv packet info
esp_now_register_recv_cb(OnDataRecv);
Is there anything else I can do?