Integer data transmission and reception using NRF24L01

Hi, Friends.

I am using Arduino DUE board and i need to send Array data which is 32 bit wide integer. I am new to wireless communication using nrf24l01 . i am using RF24 github library. i have tested basic communication which sends Hello World from DUE to another arduino board wirelessly.

how to send integer values of array using nrf24l01.

array size is 20000.

how to send integer values of array using nrf24l01.
array size is 20000

sending "Hello World" or some bytes is the same thing. Put the bytes in a reasonably sized buffer and send it (don't hope to send 20000 in one go - if I remember correctly the maximum payload size is 32 bytes)

Something like this would do (assuming proper setup)

struct message_t {
  uint32_t chrono;     // 4 bytes timestamp
  uint32_t data[5];    // 5 unsigned long
} message;


void sendMessage(message_t &msg)
{
  radio.stopListening();   // stop listening so that we can send the message

  if (!radio.write( &msg, sizeof(message_t) )) {
    Serial.println(F("Send error"));
  }
  radio.startListening(); // listen again
}

On the other end you would check if you have a message with something like this

boolean checkMessage(message_t &msg)
{
  boolean incomingMessage = false;
  if ( radio.available()) {
    radio.read( &msg, sizeof(message_t));  // read it
    incomingMessage = true;
  }
  return incomingMessage;
}

okay, where to put for loop to send data of the all the location one by one some thing like.

uint32_t data[5];

for (int i=0;i<+5;i++)
{
Send value of array data one by one wireleslly.
}

my question is how do i bifurcate all 20000 point data at receiver end. each locations data should be bifurcate at receiver end. using serial communication we use for loop to send each location data to serial print and we get the right things. but in this nrf24l01 i m stuck at how to bifurcate.
Thanks for all help.

i hope u understand my problem.

I’m not sure I get what you mean with bifurcate. also unclear about your setup… how many emitters, how many receivers ? can you describe the use case?

EJLED:
okay, where to put for loop to send data of the all the location one by one some thing like.

uint32_t data[5];

for (int i=0;i<+5;i++)
{
Send value of array data one by one wireleslly.
}

you don’t need to loop through the small buffer, you can send 32 bytes in one go. For your data array above you could do radio.write( data, sizeof(data));to send the whole buffer in one go

as you have tons of data to send, you should reach about auto-ack and auto-retry features (see examples)

J-M-L Thank u for the help. but let me try to explain u.

I have attached senors at digital pins of DUE they all together reads data and packet it in 32 BITS (4 Byte). i am sampling it about 20 K points and store it into Array. now each location of array among 20K have 32 bits ( 4 bytes) wide data. and right from array index 0 to 19999 we have data . now what i want to do is first send all these array data wirelessly to another PC and on the receiver end i want to parse it . for example array index 0 to index 19999 with their data.

Why do you pack them in an Array?
Why can’t you just send them as you read them to the PC? then that will be very short messages and the PC - which has tons of memory - will have no problem storing tens of thousands of them

assuming you have a good reason to pack the data in auint32_t hugeArray[20000];then as you can’t send 20000 x 4 bytes in one go you need to go through your data by groups of 8 (32 bytes max)

Note that your DUE has 96 KB of SRAM available for your code… and your array will use more than 78KB… that’s a lot - hopefully you can do what you need in the remaining memory space

for (uint16_t i = 0; i < 20000; i+=8) {
   radio.write( &(hugeArray[i]), 32); // works because 20000 / 8 = 2500 so we don't need to worry about the end of the array
}

The challenge though with this approach is that it’s a mess to handle auto-ack and auto-retry… So if you can send as you capture, it will probably be easier to manage.