Helo!
I want to build a system, where multiple transmitters (in my case - Arduino Pro Mini) send data to one RPi 2 over NRF24L01. I'm using C++ library for NRF24 from here. On basis of examples/extra/rpi-hub.cpp I managed to receive from two arduinos. However, when I print pipe number inside loop, it is always set to 0. I need to know from which arduino/pipe I received data and that's the point I've stuck.
My RPi code:
const uint64_t pipes[6] = { 0xF0F0F0F0D2LL, 0xF0F0F0F0E1LL,
0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL,
0xF0F0F0F0F1, 0xF0F0F0F0F2 };
radio.begin();
// optionally, increase the delay between retries & # of retries
radio.setRetries(15,15);
// Dump the configuration of the rf unit for debugging
radio.setChannel(70);
// radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]);
radio.openReadingPipe(2,pipes[2]);
radio.startListening();
radio.printDetails();
while (1)
{
uint8_t pipe = 2;
while ( radio.available(&pipe) )
{
radio.read( &data, sizeof(myData) );
printf("Recv: pipe=%i\n", pipe);
cout << " Temp: " << data.temp << " humidity: " << data.humid << endl;
delay(1000); //Delay after payload responded to, minimize RPi CPU time
pipe++;
// reset pipe to 0
if ( pipe > 3 )
pipe = 2;
}
}
I assume that it is not a problem with pipe addresses (beacuse data is coming to RPi), but I have no idea what other thing can be wrong. As I mentioned before, the only thing I found to be incorrect is pipe number set to 0, no matter what I assign in the beginning of the loop.