@jims123
I'm using the Arduino framework, but I initialize ESP-NOW using the IDF function. I include in the project library:
#include <esp_now.h>
#include <esp_wifi.h>
I initialize the WiFi interface like this:
wifi_init();
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
static void wifi_init()
{
ESP_ERROR_CHECK(esp_netif_init());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_protocol( WIFI_IF_STA, WIFI_PROTOCOL_LR ));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
ESP_ERROR_CHECK(esp_wifi_start());
int8_t defaultWiFiPower;
ESP_ERROR_CHECK(esp_wifi_get_max_tx_power(&defaultWiFiPower));
Serial.printf("Default power: %d\r\n",defaultWiFiPower);
ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(MAX_WIFI_POWER));
ESP_ERROR_CHECK(esp_wifi_set_country(&country));
}
I get a range on the built-in antennas of about 300m with the visibility of the antennas (no obstacles)