Code for nrf240l with two transmitter and a single receiver

please check this code Tx1 and Tx2 and Rx respectively
my reciever doesnt show any data from transmitters

sketch_dec16b.ino (780 Bytes)

sketch_dec16a.ino (755 Bytes)

sketch_dec16c.ino (1.42 KB)

Have a look at this Simple nRF24L01+ Tutorial. The examples do work.

...R

Things that I see that are incorrect:

  1. Pipe addressing has declaration and usage errors
  2. Your transmit buffer is 105 bytes in length, the maximum NRF24 buffer size is 32 bytes
  3. Incorrect handling of receiver pipes and listening mode

Here are three programs tested and working. The biggest changes are to the receiver side. I maintained the separate struct's for each transmitter. Since the data format is the same, you can use one common buffer and just use the pipe number to determine the source, the same as I used to direct the read to the correct data buffer.

If you have any distance between your NRF devices, change the myRadio.setPALevel(RF24_PA_MIN) line to a more appropriate power level. I tested with all three devices within a few feet of one another.

// Transmitter Node 1

#include <SPI.h>
#include "RF24.h"

RF24 myRadio (9, 10);

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

struct package
{
  int id = 1;
  float temperature = 18.3;
  char  text[20] = "Mehru";
} data;

void setup()
{
  Serial.begin(115200);
  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MIN);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.openWritingPipe( addresses[0]);
  delay(500);
}

boolean result;

void loop()
{
  result = myRadio.write(&data, sizeof(data));
  if (result) {
    Serial.print("\nPackage:");
    Serial.print(data.id);
    Serial.print("\n");
    Serial.println(data.temperature);
    Serial.println(data.text);
    data.id = data.id + 1;
    data.temperature = data.temperature + 0.1;
  }
  else
    Serial.print("TxFailed\n");
  delay(1000);
}
// Transmitter Node 2

#include <SPI.h>
#include "RF24.h"

RF24 myRadio (9, 10);

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

struct package
{
  int id = 1;
  float temperature = 92.3;
  char  text[20] = "Nisa";
} data;

void setup()
{
  Serial.begin(115200);
  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MIN);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.openWritingPipe( addresses[0]);
  delay(500);
}

boolean result;

void loop()
{
  result = myRadio.write(&data, sizeof(data));
  if (result) {
    Serial.print("\nPackage:");
    Serial.print(data.id);
    Serial.print("\n");
    Serial.println(data.temperature);
    Serial.println(data.text);
    data.id = data.id + 1;
    data.temperature = data.temperature + 0.1;
  }
  else
    Serial.print("TxFailed\n");
  delay(1000);
}
// Receiver

#include <SPI.h>
#include "RF24.h"

RF24 myRadio (9, 10);

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

struct package1
{
  int id = 0;
  float temperature = 0.0;
  char  text[20] = "empty";
} data1;

struct package2
{
  int id1 = 0;
  float temperature1 = 0.0;
  char  text1[20] = "empty";
} data2;

void setup()
{
  Serial.begin(115200);

  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MIN);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.openReadingPipe(1, addresses[0]);
  myRadio.openReadingPipe(2, addresses[1]);
  myRadio.startListening();
}

uint8_t pipeNum;

void loop()
{
  if ( myRadio.available(&pipeNum)) {
    if (pipeNum == 1) {
      myRadio.read(&data1, sizeof(data1));
      Serial.print("\nPackage1:");
      Serial.print(data1.id);
      Serial.print("\n");
      Serial.println(data1.temperature);
      Serial.println(data1.text);
    }
    else {
      myRadio.read(&data2, sizeof(data2));
      Serial.print("\nPackage2:");
      Serial.print(data2.id1);
      Serial.print("\n");
      Serial.println(data2.temperature1);
      Serial.println(data2.text1);
    }
  }
}