NRF24l01(Master) only talking to One Slave at a time

Hello guys i have 3 nrf24lo1, i master and two slaves
master to one slave is working fine but when i introduce the 3rd slave the data is not been read by the master

here is the master code

#include "Arduino.h"
#include <SPI.h>
#include <RF24.h>
#include "DHT.h"
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include <TinyGPS++.h>

#define SD_CS 22

#define DHTPIN 2


HardwareSerial uart(1);
TinyGPSPlus gps;
// This is just the way the RF24 library works:
// Hardware configuration: Set up nRF24L01 radio on SPI bus (pins 10, 11, 12, 13) plus pins 7 & 8
//RF24 radio(7, 8);
RF24 radio(5, 15);
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

byte addresses[][6] = {"1Node", "2Node", "3Node"};


boolean buttonState = 0;
float h, t,lati, longi;
String temperature, humidity, latitude, longitude;

struct package
{
float temperature ;
float humidity ;
};

String hello ;
typedef struct package Package;
Package data;

typedef struct package Package;
Package data1;

// -----------------------------------------------------------------------------
// SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP
// -----------------------------------------------------------------------------
void setup() {
  uart.begin(9600, SERIAL_8N1, 17, 16);
  Serial.begin(9600);
  Serial.println("THIS IS THE TRANSMITTER CODE - YOU NEED THE OTHER ARDIUNO TO SEND BACK A RESPONSE");

  // Initiate the radio object
  radio.begin();
  dht.begin();

  // Set the transmit power to lowest available to prevent power supply related issues
  radio.setPALevel(RF24_PA_MIN);

  // Set the speed of the transmission to the quickest available
  radio.setDataRate(RF24_2MBPS);

  // Use a channel unlikely to be used by Wifi, Microwave ovens etc
  radio.setChannel(124);

  radio.enableDynamicPayloads();
  // Open a writing and reading pipe on each radio, with opposite addresses
  radio.openWritingPipe(addresses[1]);
  radio.openReadingPipe(1, addresses[0]);
  radio.openReadingPipe(2, addresses[0]);
 // radio.openReadingPipe(1, addresses[1]);

  
  
  
}

void senddata() {

  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  data.humidity = dht.readHumidity();
  // Read temperature as Celsius (the default)
  data.temperature = dht.readTemperature();
  radio.write( &data, sizeof(data) );
  gps_Info();
}

void loop(){
  // Ensure we have stopped listening (even if we're not) or we won't be able to transmit
  radio.stopListening(); 
  senddata();
  

  // Did we manage to SUCCESSFULLY transmit that (by getting an acknowledgement back from the other Arduino)?
  // Even we didn't we'll continue with the sketch, you never know, the radio fairies may help us
  if (!radio.write( &data, sizeof( data) )) {
    Serial.println("No acknowledgement of transmission - receiving radio device connected?");    
  }
  delay(5);
  radio.startListening();
  while (!radio.available());
  radio.read(&buttonState, sizeof(buttonState));
  if (buttonState == HIGH) {
    Serial.print("HIGH");
  }
  else {
    Serial.println("LOW");
  }
  //delay(10);
  radio.read(&data1, sizeof(data1));
  
  Serial.print(data1.humidity,2);
  Serial.println(data1.temperature,2);
  
  
}

Here's the slave thats always connecting

#include "Arduino.h"
#include <SPI.h>
#include <RF24.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#define button 6

// This is just the way the RF24 library works:
// Hardware configuration: Set up nRF24L01 radio on SPI bus (pins 10, 11, 12, 13) plus pins 7 & 8
RF24 radio(7, 8);
LiquidCrystal_I2C lcd(0x27,20,4);

byte addresses[][6] = {"1Node","2Node","3Node"};


struct package
{
float temperature ;
float humidity ;
};

typedef struct package Package;
Package data;
String hello = "Hello";

int red = 2;
int green = 3;
int blue = 4;
int mintemp1 = 23.00;
int maxtemp1 = 26.00;
int maxtemp2 = 30.00;
int minhum1 = 70;
int maxhum1 = 80;
int maxhum2 = 100;


boolean buttonState = 0;


// -----------------------------------------------------------------------------
// SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP
// -----------------------------------------------------------------------------
void setup() {
  lcd.init();
  //lcd.begin(16, 2);
  lcd.backlight();
  Serial.begin(9600);
  Serial.println("THIS IS THE RECEIVER CODE - YOU NEED THE OTHER ARDUINO TO TRANSMIT");

  // Initiate the radio object
  radio.begin();

  // Set the transmit power to lowest available to prevent power supply related issues
  radio.setPALevel(RF24_PA_MIN);

  // Set the speed of the transmission to the quickest available
  radio.setDataRate(RF24_2MBPS);

  // Use a channel unlikely to be used by Wifi, Microwave ovens etc
  radio.setChannel(124);

  radio.enableDynamicPayloads();

  // Open a writing and reading pipe on each radio, with opposite addresses
  radio.openWritingPipe(addresses[0]);
  radio.openReadingPipe(1, addresses[1]);

  // Start the radio listening for data
  
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
  digitalWrite(red, HIGH);
  digitalWrite(green, HIGH);
  digitalWrite(blue, HIGH);
  pinMode(button, INPUT);
}

// -----------------------------------------------------------------------------
// We are LISTENING on this device only (although we do transmit a response)
// -----------------------------------------------------------------------------
void loop() {

radio.startListening();
  if ( radio.available()) {

  
    // Go and read the data and put it into that variable
    while (radio.available()) {
    radio.read( &data, sizeof(data));
    lcd.setCursor(0, 0);
    lcd.print("Temp ");
    lcd.setCursor(0, 1);
    lcd.print(data.temperature,2);
    lcd.print(" C");
    lcd.setCursor(8, 0);
    lcd.print("Hum ");
    lcd.setCursor(8, 1);
    lcd.print(data.humidity,2);
    lcd.print(" %");
    Serial.println("Data Received");
  }
    }
    else
  {
//    lcd.clear();
//    lcd.print("No radio available");
    Serial.println("Data not Received");
    }
    delay(5);
    led();
    radio.stopListening();
    buttonState = digitalRead(button);
    radio.write(&buttonState, sizeof(buttonState));
}

void led(){
//  const int temp = data.temperature,2;
  if (data.temperature,2 <= mintemp1)
  {
    //digitalWrite(red, LOW);
    digitalWrite(green, LOW);
   // delay(1000);
    digitalWrite(red, HIGH);
//    digitalWrite(green, HIGH);
  }
   if (data.temperature,2 > mintemp1)
  {
    digitalWrite(red, LOW);
//    delay(1000);
    digitalWrite(green, HIGH);
  }
  Serial.println(data.temperature,2);
  
}

void ButtonState(){
}

Here's the 2nd slave

#include "Arduino.h"
#include <SPI.h>
#include <RF24.h>
#include <Wire.h> 
#include "DHT.h"


#define DHTPIN 5
// This is just the way the RF24 library works:
// Hardware configuration: Set up nRF24L01 radio on SPI bus (pins 10, 11, 12, 13) plus pins 7 & 8
RF24 radio(7, 8);

byte addresses[][6] = {"1Node","2Node","3Node"};

#define DHTTYPE DHT22   // DHT 11
DHT dht(DHTPIN, DHTTYPE);
struct package
{
float temperature ;
float humidity ;
};

typedef struct package Package;
Package data1;




// -----------------------------------------------------------------------------
// SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP   SETUP
// -----------------------------------------------------------------------------
void setup() {
  dht.begin();
  Serial.begin(9600);
  Serial.println("THIS IS THE RECEIVER CODE - YOU NEED THE OTHER ARDUINO TO TRANSMIT");

  // Initiate the radio object
  radio.begin();

  // Set the transmit power to lowest available to prevent power supply related issues
  radio.setPALevel(RF24_PA_MIN);

  // Set the speed of the transmission to the quickest available
  radio.setDataRate(RF24_2MBPS);

  // Use a channel unlikely to be used by Wifi, Microwave ovens etc
  radio.setChannel(124);

  radio.enableDynamicPayloads();

  // Open a writing and reading pipe on each radio, with opposite addresses
  //radio.openWritingPipe(addresses[0]);
  //radio.openReadingPipe(1,addresses[1]);
  radio.openWritingPipe(addresses[0]);
  //radio.openReadingPipe(1,addresses[1]);



  // Start the radio listening for data
  
}

// -----------------------------------------------------------------------------
// We are LISTENING on this device only (although we do transmit a response)
// -----------------------------------------------------------------------------
void loop() {
// Wait a few seconds between measurements.
 radio.stopListening();
 radio.openWritingPipe(addresses[0]);
  delay(2000);

  data1.humidity = dht.readHumidity();
  data1.temperature = dht.readTemperature();
  Serial.print(data1.humidity);
  Serial.println(data1.temperature);
  radio.write( &data1, sizeof(data1) );
}

the 2nd slave connects with master when the 1st slave is not powered on, but after i turn on the 1st slave the 2nd get disconnected and 1st slave stays connected.

all help will be appreciated, thanks...

Have a look at this Simple nRF24L01+ Tutorial.

It includes an example for a master and 2 slaves that can easily be extended to a larger number of slaves.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R

Robin2:
Have a look at this Simple nRF24L01+ Tutorial.

I use this with 8 slaves now, so can vouch for it being "bloody good"