0

This is my sample RX code for 4 Tx and 1 Rx nRF24l01+ modules. I want to store all the data received from 4 pipes into an array (recArray).

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const uint64_t pipes[4] = {0xF0F0F0F0E1LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0E4LL};
char text[32] = {0}; #received data
int recArray[4]={0, 0, 0, 0}; # array to store the received bytes
void setup() {
 Serial.begin(9600);
 radio.begin();
 radio.openReadingPipe(1, pipes[0]);
 radio.openReadingPipe(2, pipes[1]);
 radio.openReadingPipe(3, pipes[2]);
 radio.openReadingPipe(4, pipes[3]);
 radio.startListening();
}
void loop() {
 if (radio.available()) {
 radio.read(&text, sizeof(text));
 Serial.println(text);
 }
}
dda
1,5951 gold badge12 silver badges17 bronze badges
asked Apr 18, 2017 at 17:23

1 Answer 1

1

I would suggest to send 2 bytes to this module
the first byte is the pipe number (0xE1,0xE2,0xE3,0xE4)
and in the second byte Data

void loop()
{
 if (radio.available())
 {
 radio.read(&text, sizeof(text));
 for (int i=0; i < 4 ; i ++)
 {
 if( text[0] == ((unsigned char *)(&pipes[i]))[0] 
 recArray[i] = text[1];
 }
 Serial.println(text[1]);
 }
}
answered Apr 28, 2017 at 20:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.