Does wifi interfere with ESP_NOW?

Just wondering. I seem to get a lot of delivery fails easily 50%+. I've looked at a lot of similar questions but don't seen them doing anything different from what I am doing.

I think the code is ok, must be some interference somewhere. So how do I get the reliability better?

I also was not able to find an understandable definition of wifi_promiscuous_enable. any thoughts?

If you want to try this:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <espnow.h>

uint8_t broadcastAddress[] = {0x22, 0x22, 0x20, 0x22, 0x27, 0x24};

// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
  char a[32];
  int b;
  float c;
  String d;
  bool e;
} struct_message;

// Create a struct_message called myData
struct_message myData;

unsigned long lastTime = 0;  
unsigned long timerDelay = 90000;  // send readings timer
unsigned int readingId = 0;

// Insert your SSID
constexpr char WIFI_SSID[] = "xyz";

int32_t getWiFiChannel(const char *ssid) {
  if (int32_t n = WiFi.scanNetworks()) {
    for (uint8_t i=0; i<n; i++) {
      if (!strcmp(ssid, WiFi.SSID(i).c_str())) {
  return 0;

// Callback when data is sent
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
  Serial.print("Last Packet Send Status: ");
  if (sendStatus == 0){
    Serial.println("Delivery success");
    Serial.println("Delivery fail");
void setup() {
  // Init Serial Monitor
  // Set device as a Wi-Fi Station
  int32_t channel = getWiFiChannel(WIFI_SSID);
Serial.println("first printdiag");
  WiFi.printDiag(Serial); // Uncomment to verify channel number before
  Serial.println("second printdiag");
  WiFi.printDiag(Serial); // Uncomment to verify channel change after

  // Init ESP-NOW
  if (esp_now_init() != 0) {
    Serial.println("Error initializing ESP-NOW");

  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  // Register peer
  esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
void loop() {
  if ((millis() - lastTime) > timerDelay) {
    // Set values to send
    String msgS="arrived at  ";
    char msg2[30]={" "};
    strcpy(myData.a, msg2);
    myData.b = random(1,20);
    myData.c = 1.2;
    myData.d = "Hello";
    myData.e = false;

    // Send message via ESP-NOW
    esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));

    lastTime = millis();

I don't know about your "interference" problem. But I do know that your attempt to transfer this
type of struct:

typedef struct struct_message {
  char a[32];
  int b;
  float c;
  String d;
  bool e;
} struct_message;


esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));

will not work correctly. The dynamically allocated part of the String element ('d') won't transfer. All you'll get is the pointer and size information. At the receiving end, that pointer will be pointing to random data.

1 Like

This is stuff I copied from the internet this morning. The char part worked ok. But yeah, what you say makes a lot of sense!

I don't know how String is terminated of if it is.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.