1

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.

1

Use different variable for checking pipe number: Test whether there are bytes available to be read in the FIFO buffers.

Parameters
[out]   pipe_num    Which pipe has the payload available
uint8_t pipeNum;
if(radio.available(&pipeNum)){
  radio.read(&data,sizeof(data));
  Serial.print("Got data on pipe");
  Serial.println(pipeNum);
}
Returns
True if there is a payload available, false if none is
Definition at line 1055 of file RF24.cpp.

https://tmrh20.github.io/RF24/classRF24.html#ace7dd139fabc16b77cb8325faa07620f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.