(SOLVED) ESP8266 ESP_Now not receiving data in COMBO mode

I'm sending data (99) to the Master that is in COMBO mode, When the Master receives this Data (99) is will tell the Master to send different Data (dt=1or 0) to other Slaves. The Master worked fine before I turned it into a COMBO adding the receive Code. I've been trying some different codes to get it to work but the Master will not receive the Code from the other Master as far as I can tell. I will post both Codes here labeled MasterTX and MasterTXRX (COMBO). This is currently just Blinking onboard LED'S to show activities of the boards, the MasterTXRX led just stay's on, not showing any activity, so no Data being received. Any help would be appreciated.
Shelley.

MasterTX

/*
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp-now-one-to-many-esp8266-nodemcu/
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*/

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

// REPLACE WITH RECEIVER MAC Address
uint8_t broadcastAddress1[] = {0x58, 0xBF, 0x25, 0xD9, 0x8F, 0x28};
//uint8_t broadcastAddress2[] = {0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
//uint8_t broadcastAddress3[] = {0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
//uint8_t broadcastAddress4[] = {0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
//uint8_t broadcastAddress5[] = {0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

int type = 99;
int dt1 = 0;
int dt2 = 0;
int dt3 = 0;
int dt4 = 0;
int dt5 = 0;
int dt6 = 0;
int dt7 = 0;
int dt8 = 0;
int dt9 = 0;
int dt10 = 0;
int dt11 = 0;
int dt12 = 0;
int sw1 = 0;
int ew1 = 0;
int mtcd = 0;
//int sendDelay = 1;

// Structure example to send data
// Must match the receiver structure

typedef struct dtgroup99_struct {
  int type;
  int dt1;
  int dt2;
  int dt3;
  int dt4;
  int dt5;
  int dt6;
  int dt7;
  int dt8;
  int dt9;
  int dt10;
  int dt11;
  int dt12;
  int sw1;
  int ew1;
} dtgroup99_struct;

// Create a dtgroup1_struct called test
dtgroup99_struct test;
//dtgroup2_struct test2;


// Create a dtgroup1_struct called test to store variables to be sent
//test_struct test;

unsigned long lastTime = 0;  
unsigned long timerDelay = 3000;  // send readings timer

// Callback when data is sent
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
  char macStr[18];
  Serial.print("Packet to:");
  snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
         mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
  Serial.print(macStr);
  Serial.print(" send status: ");
  Serial.print(type);
 
  digitalWrite(2, LOW);  // turn the LED on (HIGH is the voltage level)
  delay(50);                      // wait for a second
  digitalWrite(2, HIGH);   // turn the LED off by making the voltage LOW
  delay(50);

  if (sendStatus == 0){
    Serial.println("Delivery success");
  }
  else{
    Serial.println("Delivery fail");
  }
}


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Init Serial Monitor
  Serial.begin(115200);
 
  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();

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

  esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
  
  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);
  
  // Register peer
  esp_now_add_peer(broadcastAddress1, ESP_NOW_ROLE_CONTROLLER, 1, NULL, 0);
  //esp_now_add_peer(broadcastAddress2, ESP_NOW_ROLE_SLAVE, 2, NULL, 0);
  //esp_now_add_peer(broadcastAddress3, ESP_NOW_ROLE_SLAVE, 3, NULL, 0);
  //esp_now_add_peer(broadcastAddress4, ESP_NOW_ROLE_SLAVE, 4, NULL, 0);
  //esp_now_add_peer(broadcastAddress5, ESP_NOW_ROLE_SLAVE, 5, NULL, 0);

}
 
void loop() {
  if ((millis() - lastTime) > timerDelay) {
    static int type = 99;
      // Set values to send
    test.type = type;
    test.dt1 = random(1, 50);
    test.dt2 = random(1, 50);
    test.dt3 = random(1, 50);
    test.dt4 = random(1, 50);
    test.dt5 = random(1, 50);
    test.dt6 = random(1, 50);
    test.dt7 = random(1, 50);
    test.dt8 = random(1, 50);
    test.dt9 = random(1, 50);
    test.dt10 = random(1, 50);
    test.dt11 = random(1, 50);
    test.dt12 = random(1, 50);
    test.sw1 = random(1, 50);
    test.ew1 = random(1, 50);
          // Send message via ESP-NOW
    esp_now_send(0, (uint8_t *) &test, sizeof(test));
    lastTime = millis();
  }    
}


MasterTXRX

/*
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp-now-one-to-many-esp8266-nodemcu/
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*/

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

// REPLACE WITH RECEIVER MAC Address
uint8_t broadcastAddress1[] = {0x40, 0x91, 0x51, 0x4F, 0x31, 0x73};
uint8_t broadcastAddress2[] = {0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t broadcastAddress3[] = {0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t broadcastAddress4[] = {0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t broadcastAddress5[] = {0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

int type;
int dt1 = 0;
int dt2 = 0;
int dt3 = 0;
int dt4 = 0;
int dt5 = 0;
int dt6 = 0;
int dt7 = 0;
int dt8 = 0;
int dt9 = 0;
int dt10 = 0;
int dt11 = 0;
int dt12 = 0;
int sw1 = 0;
int ew1 = 0;
int mtcd = 0;
// Structure example to send data
// Must match the receiver structure

typedef struct dtgroup1_struct {
  int type;
  int dt1;
  int dt2;
  int dt3;
  int dt4;
  int dt5;
  int dt6;
  int dt7;
  int dt8;
  int dt9;
  int dt10;
  int dt11;
  int dt12;
  int sw1;
  int ew1;
} dtgroup1_struct;

typedef struct dtgroup99_struct {
  int type;
  int dt1;
  int dt2;
  int dt3;
  int dt4;
  int dt5;
  int dt6;
  int dt7;
  int dt8;
  int dt9;
  int dt10;
  int dt11;
  int dt12;
  int sw1;
  int ew1;
} dtgroup99_struct;

// Create a dtgroup1_struct called test
dtgroup1_struct test;
dtgroup99_struct test99;

unsigned long lastTime = 0;  
unsigned long timerDelay = 3333;  // send readings timer

// Callback when data is sent
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
  char macStr[18];
  Serial.print("Packet to:");
  snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
         mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
  Serial.print(macStr);
  Serial.print(" send status: ");
 
  digitalWrite(2, LOW);  // turn the LED on (HIGH is the voltage level)
  delay(50);                      // wait for a second
  digitalWrite(2, HIGH);   // turn the LED off by making the voltage LOW
  delay(50);

  if (sendStatus == 0){
    Serial.println("Delivery success");
  }
  else{
    Serial.println("Delivery fail");
  }
}


// when data is received
void OnDataRecv(uint8_t *mac, uint8_t *incomingData, uint8_t len) {
  Serial.print("Bytes received: ");
  Serial.println(len);
  int type;
  memcpy(&type, incomingData, sizeof(int));
  
  if(type == 99){
    memcpy(&test99, incomingData, sizeof(test99));
    mtcd = 99;
    Serial.print("mtcd: ");
    Serial.print(mtcd);
    Serial.print(" type: ");
    Serial.println(type);
  digitalWrite(2, LOW);  // turn the LED on (HIGH is the voltage level)
  delay(50);                      // wait for a second
  digitalWrite(2, HIGH);   // turn the LED off by making the voltage LOW
  delay(50);
  }
}


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Init Serial Monitor
  Serial.begin(115200);
 
  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();

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

  esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
  
  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);
  
  // Register peer
  esp_now_add_peer(broadcastAddress1, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
  //esp_now_add_peer(broadcastAddress2, ESP_NOW_ROLE_SLAVE, 2, NULL, 0);
  //esp_now_add_peer(broadcastAddress3, ESP_NOW_ROLE_SLAVE, 3, NULL, 0);
  //esp_now_add_peer(broadcastAddress4, ESP_NOW_ROLE_SLAVE, 4, NULL, 0);
  //esp_now_add_peer(broadcastAddress5, ESP_NOW_ROLE_SLAVE, 5, NULL, 0);

}
 
void loop() {
   if (mtcd == 99){
    static int type = 1;
      // Set values to send
    test.type = type;
    test.dt1 = random(1, 50);
    test.dt2 = random(1, 50);
    test.dt3 = random(1, 50);
    test.dt4 = random(1, 50);
    test.dt5 = random(1, 50);
    test.dt6 = random(1, 50);
    test.dt7 = random(1, 50);
    test.dt8 = random(1, 50);
    test.dt9 = random(1, 50);
    test.dt10 = random(1, 50);
    test.dt11 = random(1, 50);
    test.dt12 = random(1, 50);
    test.sw1 = random(1, 50);
    test.ew1 = random(1, 50);

  
    // Send message via ESP-NOW
      esp_now_send(0, (uint8_t *) &test, sizeof(test));
      //type = 0;
      
   }
else {
    Serial.println(test.dt1);
    Serial.println(test.dt2);
    Serial.println(test.dt3);
    Serial.println(test.dt4);
    Serial.println(test.dt5);
    Serial.println(test.dt6);
    Serial.println(test.dt7);
    Serial.println(test.dt8);
    Serial.println(test.dt9);
    Serial.println(test.dt10);
    Serial.println(test.dt11);
    Serial.println(test.dt12);
    Serial.println(test.sw1);
    Serial.println(test.ew1);
    delay(2000);
    }

      
mtcd = 0;
}


Just an FYI, it is NEVER codes, only code. Try asking the NERDS since it's their code.

i forgot to add codes

esp_now_register_recv_cb(OnDataRecv);

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