Nrf24L01 One Rx multiple Tx's

Hi All,
I have 2 of these nRF24's transmitting data (float type) to a single receiver. I want to be able to map the data received to the particular sensor. This surely cannot be too hard?

The Transmitter code is as follows - they are the same - even using the same sensor.

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

// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio(7, 8);
					
byte addresses[][6] = { "PipeTemp" }; // Create address for 1 pipe.
float tempC;
int reading;
int tempPin = 0;

void setup()   
{
	//For the LM35 Temperature sensor, use more of the ADC range
	analogReference(INTERNAL);

	// Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
	Serial.begin(115200);
	delay(1000);
	
	myRadio.begin();  // Start up the physical nRF24L01 Radio
	myRadio.setChannel(108);  
	myRadio.setPALevel(RF24_PA_MIN);
	myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
	myRadio.openWritingPipe(addresses[0]); // Use the first entry in array 'addresses' 
	delay(1000);
}


void loop()  
	//TempSense
	reading = analogRead(tempPin);
	tempC = reading / 9.31;
	Serial.println(tempC);
	myRadio.write(&tempC, sizeof(tempC)); //  Transmit the data

	//Wireless Tx
	Serial.print(F("Data Transmitted = "));
	Serial.print(tempC);
	Serial.println(F(" No Acknowledge expected"));
	delay(500);

}

I have a receiver that grabs the data from 2 sensors, but i can't tell which sensor it came from. There are 6 possible 'pipes', but i can't work out how to differentiate the data between the transmitters. Do i need to send the data in a different pipe? How then do i grab the data from each pipe? The received data is not time critical, it's ok to miss a few packets, but i need to be able to map the data received with the tx that sent it. Has anybody done this?

I'm using this library.

Thanks

S

A simple solution is to include an ID number in each message that lets the receiver know which device sent the message.

Another option is to use two separate pipes on the receiver so that the two senders can send to separate addresses. This works fine if you don't have more than 6 senders. But if you have larger numbers of senders you will need the first solution.

Yet another option is to have the master poll the slaves in turn and use the ackPayload feature to return the data. That way the master knows which data comes from which slave. This mechanism is illustrated in my tutorial. However it is not suitable if the slaves spend most of their time asleep to save energy.

...R
Simple nRF24L01+ Tutorial

I use the first of Robin2's sollutions. I am no C++ expert at all, but this is what I do:

On the transmitters and receiver:

const uint64_t pipe= {0x1AAAAAAAAALL};

I use the same "pipe" on both reveiver and transmitters.

Then, on all units:

struct dataStruct {
int sensor;
double temp;
double humidity;
double battery;
} data;

in the setup for transmitters, you give them a number each:

sensor=001;

and 002 for the next one.

Then, in the loop on the receiver you can do

if( radio.available(&pipe)) 
    {

          if (pipe==1){
           
 
               radio.read( &data, sizeof(data) );
               
               radio.stopListening();  



if (data.sensor==001) {
temperature1=data.temp;
humidity1=data.humidity;
}

if (data.sensor==002) {
temperature2=data.temp;
humidity2=data.humidity;
}

etc.

fantastic guys - now to see it i can get it to work!

Worked like a charm - thanks guys - i went with the provide extra info in the data packet transmitted - as a struct - and then switched according to the channel number returned.

happy days.