ESP8266 and NFR24l01

I’ve been having ago at making an ESP8266 work with the NRF24L01 module to work with Alexa, First of all I got the Alexa code working and outputting the Light on/off through serial port. Then I got the NRF24L01 sending data so I knew everything worked, Then I’ve tried to add them together. But I just keep getting this over the serial port

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v4ceabea9
~ld

And it does not work, I’ve tried to search for a solution, I’ve double checked my connections.
My idea was to have a central control unit and then send the command to other units to control lights and stuff rather than trying to run wires every where, Here is the main code I’ve done.
Was wondering of some one may be able to help or point my error out

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiUdp.h>
#include <functional>
#include "switch.h"
#include "UpnpBroadcastResponder.h"
#include "CallbackFunction.h"
#include "RF24.h"  // Download and Install (See above)
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
RF24 myRadio (8,2); // "myRadio" is the identifier you will use in following methods
// prototypes
boolean connectWifi();

//on/off callbacks 
bool officeLightsOn();
bool officeLightsOff();
bool kitchenLightsOn();
bool kitchenLightsOff();

// Change this before you flash
const char* ssid = "SKYAEB8C";
const char* password = "RVWMXMTYRL";

boolean wifiConnected = false;

UpnpBroadcastResponder upnpBroadcastResponder;

Switch *office = NULL;
Switch *kitchen = NULL;

bool isOfficeLightsOn = false;
bool isKitchenLightstsOn = false;
struct MyData {
  byte ID_No;
  byte Power;
  };

MyData data;
void setup()
{
  Serial.begin(115200);
   myRadio.begin();  // Start up the physical nRF24L01 Radio
 myRadio.setChannel(108);  // Above most Wifi Channels
 myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
  myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
  myRadio.openWritingPipe( addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  // Initialise wifi connection
  wifiConnected = connectWifi();
  
  if(wifiConnected){
    upnpBroadcastResponder.beginUdpMulticast();
    
    // Define your switches here. Max 10
    // Format: Alexa invocation name, local port no, on callback, off callback
    office = new Switch("office lights", 80, officeLightsOn, officeLightsOff);
    kitchen = new Switch("kitchen lights", 81, kitchenLightsOn, kitchenLightsOff);

    Serial.println("Adding switches upnp broadcast responder");
    upnpBroadcastResponder.addDevice(*office);
    upnpBroadcastResponder.addDevice(*kitchen);
  }
}
 
void loop()
{
	 if(wifiConnected){
      upnpBroadcastResponder.serverLoop();
      
      kitchen->serverLoop();
      office->serverLoop();
	 }
}

bool officeLightsOn() {
    Serial.println("Switch 1 turn on ...");
    data.ID_No = 100;
    data.Power=55;
    Serial.println(data.Power);
    Serial.println(data.ID_No);
   myRadio.write(&data, sizeof(MyData));
    isOfficeLightsOn = true;    
    return isOfficeLightsOn;
}

bool officeLightsOff() {
   data.ID_No = 100;
    data.Power=60;
    
    Serial.println("Switch 1 turn off ...");
    Serial.println(data.Power);
    Serial.println(data.ID_No);
    myRadio.write(&data, sizeof(MyData));
    isOfficeLightsOn = false;
    return isOfficeLightsOn;
}

bool kitchenLightsOn() {
    Serial.println("Switch 2 turn on ...");

    isKitchenLightstsOn = true;
    return isKitchenLightstsOn;
}

bool kitchenLightsOff() {
  Serial.println("Switch 2 turn off ...");

  isKitchenLightstsOn = false;
  return isKitchenLightstsOn;
}

// connect to wifi – returns true if successful or false if not
boolean connectWifi(){
  boolean state = true;
  int i = 0;
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");
  Serial.println("Connecting to WiFi");

  // Wait for connection
  Serial.print("Connecting ...");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    if (i > 10){
      state = false;
      break;
    }
    i++;
  }
  
  if (state){
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  }
  else {
    Serial.println("");
    Serial.println("Connection failed.");
  }
  
  return state;
}

If I highlight out the NRF24L01 code everything works ok with Alexa
Thanks

I’ve managed the ESP8266 stopping in the watch dog timer, I now can get Alexa to turn the lights on/off in serial debug with the NRF24l01 added but still it does not transmit any data, Which I think is how the program runs ?
Here is the New code

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiUdp.h>
#include <functional>
#include "switch.h"
#include "UpnpBroadcastResponder.h"
#include "CallbackFunction.h"
#include "RF24.h"  // Download and Install (See above)
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
RF24 myRadio (4,2); // "myRadio" is the identifier you will use in following methods
// prototypes
boolean connectWifi();

//on/off callbacks 
bool officeLightsOn();
bool officeLightsOff();
bool kitchenLightsOn();
bool kitchenLightsOff();

// Change this before you flash
const char* ssid = "SKYAEB8C";
const char* password = "RVWMXMTYRL";

boolean wifiConnected = false;

UpnpBroadcastResponder upnpBroadcastResponder;

Switch *office = NULL;
Switch *kitchen = NULL;

bool isOfficeLightsOn = false;
bool isKitchenLightstsOn = false;
struct MyData {
  byte ID_No;
  byte Power;
  };

MyData data;
void setup()
{
  Serial.begin(115200);
  // myRadio.begin();  // Start up the physical nRF24L01 Radio
 myRadio.setChannel(108);  // Above most Wifi Channels
 myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
  myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
  myRadio.openWritingPipe( addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  // Initialise wifi connection
  wifiConnected = connectWifi();
  
  if(wifiConnected){
    upnpBroadcastResponder.beginUdpMulticast();
    
    // Define your switches here. Max 10
    // Format: Alexa invocation name, local port no, on callback, off callback
    office = new Switch("office lights", 80, officeLightsOn, officeLightsOff);
    kitchen = new Switch("kitchen lights", 81, kitchenLightsOn, kitchenLightsOff);

    Serial.println("Adding switches upnp broadcast responder");
    upnpBroadcastResponder.addDevice(*office);
    upnpBroadcastResponder.addDevice(*kitchen);
  }
  data.Power =33;
    data.ID_No = 74;
}
 
void loop()
{
  myRadio.write(&data, sizeof(MyData));
 if(wifiConnected){
      upnpBroadcastResponder.serverLoop();
      
      kitchen->serverLoop();
      office->serverLoop();
 }
}

bool officeLightsOn() {
    Serial.println("Switch 1 turn on ...");
    data.ID_No = 100;
    data.Power=55;
    Serial.println(data.Power);
    Serial.println(data.ID_No);
  // myRadio.write(&data, sizeof(MyData));
    isOfficeLightsOn = true;    
    return isOfficeLightsOn;
}

bool officeLightsOff() {
   data.ID_No = 100;
    data.Power=60;
    
    Serial.println("Switch 1 turn off ...");
    Serial.println(data.Power);
    Serial.println(data.ID_No);
   // myRadio.write(&data, sizeof(MyData));
    isOfficeLightsOn = false;
    return isOfficeLightsOn;
}

bool kitchenLightsOn() {
    Serial.println("Switch 2 turn on ...");

    isKitchenLightstsOn = true;
    return isKitchenLightstsOn;
}

bool kitchenLightsOff() {
  Serial.println("Switch 2 turn off ...");

  isKitchenLightstsOn = false;
  return isKitchenLightstsOn;
}

// connect to wifi – returns true if successful or false if not
boolean connectWifi(){
  boolean state = true;
  int i = 0;
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");
  Serial.println("Connecting to WiFi");

  // Wait for connection
  Serial.print("Connecting ...");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    if (i > 10){
      state = false;
      break;
    }
    i++;
  }
  
  if (state){
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  }
  else {
    Serial.println("");
    Serial.println("Connection failed.");
  }
  
  return state;
}

Just to make sure that the ESP8266 worked the NRF24L01 I testeded it with this code and it transmits the data to the Nano.
This is the test TX code

#include <TimedAction.h>
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
//RF24 myRadio (9, 10); // "myRadio" is the identifier you will use in following methods
RF24 myRadio (4,2); // "myRadio" is the identifier you will use in following methods
int Out_count[1];
//on/off callbacks 
bool officeLightsOn();
bool officeLightsOff();
bool isOfficeLightsOn = false;
bool isKitchenLightstsOn = false;
#define  menubuttonPin 5//pin to which the button is conected to
int menubuttonState = 0;
int lastmenuButtonState = 0;
boolean menubuttonbool = false;
int lastupbuttonState;
int menubuttonPushCounter = 0;
const int ledPin =  LED_BUILTIN;// the number of the LED pin
//####################################################
//#  Initializes TimedAction - Timer Interrupt       #
//####################################################
void TimerService01();// Timer service routinte
TimedAction Timedact01 = TimedAction(1000, TimerService01);// Timer1 for ADC'S, called every 80 Ms seconds
void TimerService02();// Timer service routinte
TimedAction Timedact02 = TimedAction(50, TimerService02);// Timer2 for LCD display, called every 80 Ms seconds
// The sizeof this struct should not exceed 32 bytes
// This gives us up to 32 8 bits channals
struct MyData {
  byte ID_NO;
  byte Data;
  
};

MyData data;

void setup() {
  Serial.begin(115200);
  pinMode(menubuttonPin, INPUT);
  digitalWrite(menubuttonPin, HIGH);
   pinMode(ledPin, OUTPUT);
  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
  myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
  myRadio.openWritingPipe( addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
    data.ID_NO = 71;
    data.Data = 33;
  
}
//####################################################
//#  Main Loop,runs Timed_actions                    #
//####################################################
void loop() {
 
  
 
  Timedact01.check(); // Reads the ADC
  Timedact02.check(); // Display hte data
 

}
//####################################################
//#   TimedAction - Timer Interrupt                  #
//####################################################

void TimerService01() {// Displat the data
  //  data.ID_NO = data.ID_NO +1;
 //   data.Data =  data.Data +1 ;
  }

void TimerService02() { //send the data out to NRF24L01 module
  myRadio.write( &data, sizeof(MyData) ); //  Transmit the data
  Serial.println("eys");
}

The is the RX code running on a nano

//####################################################
//# Include all the libraries                        #
//####################################################
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
#include <TimedAction.h>

byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.

RF24 myRadio (9, 10); // "myRadio" is the identifier you will use in following methods
int dataReceived;  // Data that will be received from the transmitter
struct MyData {
 byte ID_No;
  byte Power;
  };

MyData data;
//####################################################
//#  SwitchManger routines checks switches           #
//####################################################
// Note: last parameter is optional (defaults to 2 seconds if omitted)
void TimerService01();// ADD THIS FUNCTION PROTOTYPE
TimedAction Timedact01 = TimedAction(50, TimerService01);// mS
void TimerService02();// Timer service routinte
TimedAction Timedact02 = TimedAction(50, TimerService02);// Timer2 for LCD display, called every 80 Ms seconds

void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(115200);
  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
  myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
  myRadio.openReadingPipe(1, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  myRadio.startListening();
 
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
    
  
  Timedact02.check();
  Timedact01.check(); 
}
void TimerService01() {
  Serial.println("###############");
   Serial.println(data.Power);
    Serial.println(data.ID_No);
     Serial.println("###############");
}
void TimerService02() { //send the data out to NRF24L01 module
 if ( myRadio.available()) // Check for incoming data from transmitter
  {
    while (myRadio.available())  // While there is data ready
    {
      myRadio.read(&data, sizeof(MyData)); // Get the data payload (You must have defined that already!)
    }

   }

}

Not sure where I’m going wrong, This TX&RX code works on the ESP and nano