Report
1 week ago.

NRF24L01P pipe / address for nework

Hi,

I'm trying to etablish a RF network composed of: PRX - STM32F746Disovery with NRF24L01+ (the gateway) PTX1- NucleoL053 with NRF24L01+ (the Node1) PTX2- NucleoF401 with NRF24L01+ (The Node2)

Actually I can communicate between a PRX and PTX only through Pipe0 with the default adress Tx and Rx (0xE7E7E7E7EE) on all board. This is successfull by using NRF24L01P Hello Word example.

But I woud like to communicate with more than 2 devices. I'm testing the PRX will send data to each PTX and use Pipe0, Pipe1 and Pipe2 with the following setup:

PRX: RX_ADDR_P0: 0x7878787878 RX_ADDR_P1: 0xB3B4B5B6F1 RX_ADDR_P2: 0xB3B4B5B6CD

PTX1: TX_ADDR: 0xB3 B4 B5 B6 F1 RX_ADDR_P0: 0xB3 B4 B5 B6 F1

PTX2: TX_ADDR: 0xB3 B4 B5 B6 CD RX_ADDR_P0: 0xB3B4B5B6CD

Does this setup is correct ? Because I'am not able communicate by this way.

Thank you for any suggestion.

Comment on this question

1 Answer

6 days, 22 hours ago.

Hello rom,

The datasheet says: "An nRF24L01 configured as primary RX (PRX) will be able to receive data trough 6 different data pipes. A data pipe will have a unique address but share the same frequency channel. This means that up to 6 different nRF24L01 configured as primary TX (PTX) can communicate with one nRF24L01 configured as PRX, and the nRF24L01 configured as PRX will be able to distinguish between them."

So PRX is a server (or slave) and PTXs are clients (or masters). But only a client (or master) can initialize the communication with a server (or slave) - It means send data to the server (or slave). The server (PRX), after receiving data, can respond (either acknowledge or acknowledge + send back some data). Such setup is suitable for a situation when the PRX (server) is collecting (receiving) data from up to 6 remote sensors (clients).

However, to achieve your plan you should rather configure one nRF24L01 as primary transmitter - PTX (client) and the other nRF24L01s as primary receivers - PRXs (servers). Then each PRX (server) will wait for the PTX (client) to send it some data. It means that each PRX (server) shall have a unique address and the PTX (client) can send data to the addressed PRX over pipe 0.

Hello Zoltan, and thank you for your help.

I'm ok to follow you method as 1 PTX as client send data to 2 PRX (PRX1 & PRX2) as server. But PTX will transmit to each PRX with P0 And each PTX transmit to PRX (one at a time) with respectively P1 and P2 (with unique TX adress) ? Is it correct ?

posted by rom r 03 Dec 2018

See below an example of a PTX (master) capable to send messages up to 32 PRXes (slaves) :

PTX master (client)

const uint8_t   ON = 1;
const uint8_t   OFF = 0;
const uint64_t  BASE_ADDR = 0xF0F0F0F0F0F0F000L;
RF24            radio(PB_15, PB_14, PB_13, PA_9, PA_8);     // mosi, miso, sck, 
uint64_t        address[32] = { };

bool sendRadioMsg(uint8_t slave, uint8_t payload)
{
    radio.stopListening();
    radio.openWritingPipe(address[slave]);
    return radio.write(&payload, sizeof(payload));
}

int main()
{
    // Create 32 addresses that this primary TX master (client)  is going to use for transmission up to 32 PRXes (slaves).
    // They shall match the RX addresses of the target primary RX'es (slaves).
    // To receive atomatic acknowledge, pipe 0 RX address (RX_ADDR_P0) of this PTX
    // is set to the actual TX_ADDR when calling the stopListening() function.
    for (uint8_t i = 1; i <= 32; i++)
        address[i] = BASE_ADDR + i;

    // Initialize nRF24L01
    radio.begin();
    radio.setPALevel(RF24_PA_LOW);
    radio.setRetries(5, 15);
    radio.setPayloadSize(1);
    radio.setAutoAck(true);

//...

    sendRadioMsg(1, ON);   // send ON to slave #1
    sendRadioMsg(2, OFF);  // send OFF to slave #2

// ...

}

PRX slave #1 (server #1)

const uint64_t  SLAVE = 1;
const uint64_t  BASE_ADDR = 0xF0F0F0F0F0F0F000L;
const uint64_t  ADDRESS = BASE_ADDR + SLAVE; // pipe 0 address of this receiver

RF24        radio(PB_15, PB_14, PB_13, PA_9, PA_8);     // mosi, miso, sck, 
uint8_t     payload;

int main(void)
{
    radio.begin();
    radio.setPALevel(RF24_PA_LOW);
    radio.setRetries(5, 15);
    radio.setPayloadSize(1);
    radio.setAutoAck(true);
    radio.openReadingPipe(0, ADDRESS);  // use pipe 0 of this slave to receive messsages and send back auto acknowledgement
    radio.startListening();

    while(1) {
        if (radio.available())
            radio.read(&payload, 1);

// ...

    }
}
posted by Zoltan Hudak 03 Dec 2018

is it an Arduino example ?

posted by rom r 03 Dec 2018

It's MBED example using this Arduino library ported to MBED.

posted by Zoltan Hudak 03 Dec 2018

To post an answer, please log in.