NRF 24L01 ,sending and receiving the array of long data

hi
i want to send a array of data which is as long as 20 number with my NRF module
the data which should be send are stored in

int myArray1[20]={};
int myArray2[20]={};

there is two problem with this code

  1. is the coming data just count up to 16th one
  2. just one of arrays are received
    please see the attached picture

any kindly help is appreciated

this is my Send section code

#include <SPI.h>    
#include<nRF24L01.h> 
#include<RF24.h> 
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL;       
    RF24 radio(CE_PIN,CSN_PIN); 
int i;
  int data[500];
  int myArray1[20]={255,233,239,246,244,232,220,211,181,133,110,150,170,140,113,84,71,84,92,126};
 int myArray2[20]={157,224,248,253,244,224,200,188,174,157,190,220,208,165,114,80,62,80,87,125};  
 
 void setup(){
   Serial.begin(9600);   
  radio.begin();      
   radio.openWritingPipe(pipe);    
}
void loop(){
  for (i = 0; i < 20; i = i + 1) {
   data[i]=myArray1[i];
   data[i]=myArray2[i];
   radio.write(data,sizeof(data));
  delay(5000);
  }
  
}

this is my receive data

#include <SPI.h>               
#include<nRF24L01.h>         
#include<RF24.h>   
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL; 
int i; 
         
RF24 radio(CE_PIN,CSN_PIN);                 
    int  data[600];                              
    void setup(){
      Serial.begin(9600);                         
      radio.begin();                            
      radio.openReadingPipe(1,pipe);
      radio.startListening();                  
    }
    void loop(){ 
      if (radio.available()){ 

         Serial.println("data come "); 
    bool done=false;
    while(!done)
     {
       for (i = 0; i < 25; i = i + 1) {
    radio.read(data,sizeof(data));    
    Serial.print(i);
    Serial.print(":"); 
    Serial.print("DATA1:");Serial.print(data[i]);
    Serial.print(",");
    Serial.print("DATA2:");Serial.println(data[i]);
    
    Serial.println("------------------------------");

             if  (i>18){
       Serial.println("STOP");
       }
                     
    delay(5000); 
       }             
       }
    }
    else {
      Serial.println("No radio available");           
      delay(1000);                                     
    }
    }

hi
i want to send a array of data which is as long as 20 number with my NRF module
the data which should be send are stored in

int myArray1[20]={};
int myArray2[20]={};

there is two problem with this code

  1. is the coming data just count up to 16th one
  2. just one of arrays are received
    please see the attached picture

any kindly help is appreciated

this is my Send section code

#include <SPI.h>    
#include<nRF24L01.h> 
#include<RF24.h> 
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL;       
    RF24 radio(CE_PIN,CSN_PIN); 
int i;
  int data[500];
  int myArray1[20]={255,233,239,246,244,232,220,211,181,133,110,150,170,140,113,84,71,84,92,126};
 int myArray2[20]={157,224,248,253,244,224,200,188,174,157,190,220,208,165,114,80,62,80,87,125};  
 
 void setup(){
   Serial.begin(9600);   
  radio.begin();      
   radio.openWritingPipe(pipe);    
}
void loop(){
  for (i = 0; i < 20; i = i + 1) {
   data[i]=myArray1[i];
   data[i]=myArray2[i];
   radio.write(data,sizeof(data));
  delay(5000);
  }
  
}

this is my receiver code

#include <SPI.h>               
#include<nRF24L01.h>         
#include<RF24.h>   
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL; 
int i; 
         
RF24 radio(CE_PIN,CSN_PIN);                 
    int  data[600];                              
    void setup(){
      Serial.begin(9600);                         
      radio.begin();                            
      radio.openReadingPipe(1,pipe);
      radio.startListening();                  
    }
    void loop(){ 
      if (radio.available()){ 

         Serial.println("data come "); 
    bool done=false;
    while(!done)
     {
       for (i = 0; i < 25; i = i + 1) {
    radio.read(data,sizeof(data));    
    Serial.print(i);
    Serial.print(":"); 
    Serial.print("DATA1:");Serial.print(data[i]);
    Serial.print(",");
    Serial.print("DATA2:");Serial.println(data[i]);
    
    Serial.println("------------------------------");

             if  (i>18){
       Serial.println("STOP");
       }
                     
    delay(5000); 
       }             
       }
    }
    else {
      Serial.println("No radio available");           
      delay(1000);                                     
    }
    }

  for (i = 0; i < 20; i = i + 1) {
   data[i]=myArray1[i];
   data[i]=myArray2[i];
   radio.write(data,sizeof(data));
  delay(5000);
  }

What is the point of putting the 0th value from myArray1 into the 0th element of data, and then putting the 0th element of myArray2 in the same location?

What is the point of sending all 1000 bytes of data after putting 1 value in the array?

Why do you need a 500 element array to hold 20 ints?

Why do you need ints to hold byte values?

Why do you send data 20 times, and read data 25 times?

So many questions...

Please edit your posts instead of double posting:
http://forum.arduino.cc/index.php?topic=505368
Now you have one copy of this with a reply and another with an image attachment.

hi thanks for your kindly email

What is the point of putting the 0th value from myArray1 into the 0th element of data, and then putting the 0th element of myArray2 in the same location?

answer: just i wanted to send the data in a loop means the oth number of array till the 20 th one

What is the point of sending all 1000 bytes of data after putting 1 value in the array?
answer : any help appreciated

Why do you need a 500 element array to hold 20 ints?
answer : any help appreciated

Why do you need ints to hold byte values?
answer : any help appreciated

Why do you send data 20 times, and read data 25 times?
answer :i wanted to receive this 20 data any help appreciated
So many questions...

Date Registered: Dec 04, 2014, 12:34 am

You've been here 2.86 years. I am truly disheartened I have to write this: Please stop cross-posting. Threads merged. Again.

Please help me to sort both problem its happened by the weak net ability

You seem to have two arrays each with 20 values. At the moment the arrays are defined as ints so the 20 values occupy 40 bytes and the nRF24 can only send 32 bytes in a message.

However none of your values exceeds 255 so you could define the arrays as bytes and then they would occupy 20 bytes which would easily fit in a single nRF24 message.

...R
Simple nRF24L01+ Tutorial

Tnx for your replay
i check your solution but it didn't work

//***************************
//     JAHAN  Send
//*************************

#include <SPI.h>    
#include<nRF24L01.h> 
#include<RF24.h> 
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL;       
    RF24 radio(CE_PIN,CSN_PIN); 
int i;
  const byte data[20];
  const byte myArray1[20]={255,233,239,246,244,232,220,211,181,133,110,150,170,140,113,84,71,84,92,126};
const byte myArray2[20]={157,224,248,253,244,224,200,188,174,157,190,220,208,165,114,80,62,80,87,125};  
 
 void setup(){
   Serial.begin(9600);   
  radio.begin();      
   radio.openWritingPipe(pipe);    
}
void loop(){
  for (i = 0; i < 20; i = i + 1) {
   data[i]=myArray1[i];
   data[i]=myArray2[i];
   radio.write(data,sizeof(data));
  delay(5000);
  }
  
}

You want to send the entire message each time a single element is copied? You want to copy from myArray1 and then immediately overwrite it with data from myArray2? It's not hard to see that this code does that.

void loop(){
  for (i = 0; i < 20; i = i + 1) {
   data[i]=myArray1[i];
   data[i]=myArray2[i];
   radio.write(data,sizeof(data));

MOSHAYEDI:
i check your solution but it didn't work

"It didn't work" is useless statement. It provides no information with which to help you.

I think you need to change your code so that the wireless call is outside the FOR loop - like this

void loop(){
  for (i = 0; i < 20; i = i + 1) {
   data[i]=myArray1[i];
   data[i]=myArray2[i];
  }
  radio.write(data,sizeof(data));
  delay(5000);
}

Also, as you want to change the data in the array called data[] you should not make it constant.

And this piece of code

  data[i]=myArray1[i];
  data[i]=myArray2[i];

does exactly the same thing as this

   data[i]=myArray2[i];

Can you see why?

...R

tnx for your help
but the attached picture showed the result

//***************************
//     JAHAN  Send
//*************************

#include <SPI.h>    
#include<nRF24L01.h> 
#include<RF24.h> 
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL;       
    RF24 radio(CE_PIN,CSN_PIN); 
int i;
  const byte data[30];
  const byte myArray1[30]={255,233,239,246,244,232,220,211,181,133,110,150,170,140,113,84,71,84,92,126,0,0,0,0,0,0,0,0,0,0};
const byte myArray2[30]={157,224,248,253,244,224,200,188,174,157,190,220,208,165,114,80,62,80,87,125,0,0,0,0,0,0,0,0,0,0};  
 
 void setup(){
   Serial.begin(9600);   
  radio.begin();      
   radio.openWritingPipe(pipe);    
}
void loop(){
  for (i = 0; i < 30; i = i + 1) {
  myArray1[i];
//   data[i]=myArray2[i];

  }
     radio.write(data,sizeof(data));
  delay(5000);
}
//***************************
//     JAHAN  RECIEVE
//*************************
#include <SPI.h>               
#include<nRF24L01.h>         
#include<RF24.h>   
#define CE_PIN 9
#define CSN_PIN 10

const uint64_t pipe=0xE8E8F0F0E1LL; 
int i; 
         
RF24 radio(CE_PIN,CSN_PIN);                 
    int  data[600];                              
    void setup(){
      Serial.begin(9600);                         
      radio.begin();                            
      radio.openReadingPipe(1,pipe);
      radio.startListening();                  
    }
    void loop(){ 
      if (radio.available()){ 

         Serial.println("data come "); 
    bool done=false;
    while(!done)
     {
       for (i = 0; i < 25; i = i + 1) {
    radio.read(data,sizeof(data));    
    Serial.print(i);
    Serial.print(":"); 
    Serial.print("DATA1:");Serial.print(data[i]);
    Serial.print(",");
    Serial.print("DATA2:");Serial.println(data[i]);
    
    Serial.println("------------------------------");

             if  (i>18){
       Serial.println("STOP");
       }
                     
    delay(5000); 
       }             
       }
    }
    else {
      Serial.println("No radio available");           
      delay(1000);                                     
    }
    }

Images from Reply #12 so we don't have to download them. See this Image Guide

...R

As you can see I can't read your pictures. Don't post pictures of text. Just copy and paste the text.

...R

ok

the result is :

0:DATA1:0,DATA2:0

1:DATA1:0,DATA2:0

2:DATA1:0,DATA2:0

3:DATA1:0,DATA2:0

4:DATA1:0,DATA2:0

  for (i = 0; i < 30; i = i + 1)
  {
    myArray1[i];
  }

What do you think this code is doing? Any answer other than NOTHING is wrong.

I have had a look at your programs in Reply #12 and, to be honest, neither of them makes any sense.

In the Send program you have the line

myArray1[i];

which does nothing
and you have defined data[] as 30 bytes (which is fine).

But in your Receive program you have defined data[] as 600 ints or 1200 bytes
The array into which data is received must be identical to the array from which data is sent

And, as I mentioned earlier, the nRF24 can only send 32 bytes in a messge.

I think you should scrap your Receive program altogether and write a new Receive program that matches your Send program.

...R