NRF24L01 - Transmit failed

Hello,
I have two sketches:

NANO:

/*-----( Import needed libraries )-----*/
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
/*-----( Declare objects )-----*/
// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio (7, 8); // "myRadio" is the identifier you will use in following methods
/*-----( Declare Variables )-----*/
#define ledPin 4
byte addresses[1] = {11}; // Create address for 1 pipe.
byte fixAddresses[1] = {2};
int dataReceived;  // Data that will be received from the transmitter

struct dataStruct {
  int Xposition;          // The Joystick position values
} myData;                 // This can be accessed in the form:  myData.Xposition  etc.

boolean test;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
  Serial.begin(115200);
  delay(1000);
  Serial.println(F("RF24/Receive Nano Data"));
  Serial.println(F("Questions: terry@yourduino.com"));

  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  // PALevelcan be one of four levels: RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
  myRadio.setPALevel(RF24_PA_MIN);

  myRadio.openReadingPipe(1, addresses[1]); // Use the first entry in array 'addresses' (Only 1 right now)
  myRadio.openWritingPipe(fixAddresses[0]); //this is the address of the listingpipe on the MEGA
   
  myRadio.startListening();

  // initialize digital pin LED_BUILTIN as an output.
  pinMode(ledPin, OUTPUT);

test = true;

//  radio.printDetails(); //Uncomment to show LOTS of debugging information
  
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{

if (test == true){ //run this only once to say "hello, I am online"
  myRadio.stopListening();
  myData.Xposition = 7;
  Serial.print(F("Now sending  -  "));
    if (!myRadio.write( &myData, sizeof(myData) )) { // Send data, checking for error ("!" means NOT)
      Serial.println(F("Transmit failed "));
    }else{ 
      Serial.println(F("Transmit succesfull "));
    }
    myRadio.startListening(); 
    test = false;
    }

    
  if ( myRadio.available()) // Check for incoming data from transmitter
  {
    
    while (myRadio.available())  // While there is data ready
    {
      myRadio.read( &dataReceived, sizeof(dataReceived) ); // Get the data payload (You must have defined that already!)
    }

    
    // DO something with the data, like print it
    if (dataReceived == 1) {
    
    digitalWrite(4, HIGH);
    Serial.print("AAN: ");
    }
    if (dataReceived == 0) {  
    
    digitalWrite(4, LOW);
    Serial.print("UIT: ");
    }
    
    Serial.print("Data received = ");
    Serial.println(dataReceived);


    
  } //END Radio available

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

//None yet
//*********( THE END )***********

MEGA:

/*-----( Import needed libraries )-----*/
#include <SPI.h>   // NRF24L01 - Comes with Arduino IDE
#include "RF24.h"  // NRF24L01 - Download and Install (See above)

/*-----( Declare Constants and Pin Numbers )-----*/
#define ELEMENTS(x) (sizeof(x)/sizeof(x[0])) //see also https://www.arduino.cc/en/Reference/Sizeof
const int pins[] = {2,6,7,8,11, 22, 23, 24, 25, 26, 27, 28}; //Set all the pin numbers, addresses staring from address "1"
/*One of the nice things about this parameterized macro is that it is "typeless". That is, you can use it with whatever data type you need: char, float, int...whatever.*/
int statPins[ELEMENTS(pins)] = {}; //int statPins[] = {0,0,0,0};

/*-----( Declare objects )-----*/
// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio (9,53); // "myRadio" is the identifier you will use in following methods

/*-----( Declare Variables )-----*/
byte addresses[ELEMENTS(pins)] = {}; // Create addresses
byte fixAddresses[1] = {2};
int dataTransmitted;  // Data that will be Transmitted from the transmitter
int contact = 0;
struct dataStruct {
  int Xposition;          // The Joystick position values
} myData;                 // This can be accessed in the form:  myData.Xposition  etc.




void setup()
{
  // Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
  Serial.begin(115200);
  delay(1000);
  dataTransmitted = 100; // Arbitrary known data to transmit. Change it to test...
  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
    myRadio.setPALevel(RF24_PA_MAX); 
    myRadio.openReadingPipe(1, addresses[0]); //this is the address of the listingpipe on the MEGA
    myRadio.openWritingPipe(fixAddresses[0]);

}


void loop()
{
 

myRadio.startListening(); 
 if ( myRadio.available()) // Check for incoming data from transmitter
  {
    while (myRadio.available())  // While there is data ready
    {
      myRadio.read( &myData, sizeof(myData) ); // Get the data payload (You must have defined that already!)
      Serial.println(myData.Xposition);
    }
     }

myRadio.stopListening();
    

for (int i = 0; i< ELEMENTS(pins);i++){ 
  contact=digitalRead( pins[i]);
      
    myRadio.openWritingPipe(addresses[i]); // Use the first entry in array 'addresses' (Only 1 right now)
   
    dataTransmitted = contact;
    myRadio.write( &dataTransmitted, sizeof(dataTransmitted) ); //  Transmit the data
    
    Serial.print(F("Data Transmitted = "));
    Serial.print(dataTransmitted);
    Serial.println(F(" No Acknowledge expected"));

    statPins[i]  = contact;
 
}
    }

But when I look at the serial monitor of the NANO I got this:

RF24/Receive Nano Data
Questions: terry@yourduino.com
Now sending - Transmit failed

It always failed, the Mega can send something to the NANO, but no vice versa… Can anyone help me with this?

what do you think is at this index on the nano side?

byte addresses[[color=green][b]1[/b][/color]] = {11}; // Create address for 1 pipe.
....
myRadio.openReadingPipe(1, addresses[[b][color=red]1[/color][/b]]); // Use the first entry in array 'addresses' (Only 1 right now)

This Simple nRF24L01+ Tutorial may help get you started. I have deliberately made the examples very simple without any alternatives.

...R

@J-M-L: still the same..

The reading part works, the MEGA sends data to the NANO and the NANO receives them too

But the problem is the NANO doesn't want to send something to the MEGA

The first element in an array is [0], not [1].