nRF24L01 communication problem with int array[5]

Experiencing a new problem when trying to receive a transmission of an integer array (int mySensVals[5]) over an nRF24L01 network between 2 Arduino Uno's.

I can receive the first 3 of the integers transmitted but not the last 2. Because values 2 (mySensVals[1] & 3 mySensVals[2] are currently 0, I substituted the values 1, 2, 3, 4, 5 in the array mySensVals[5].

I received the values 1, 2 & 3 but not 4 & 5?

All values appear correctly on the serial monitor of the Tx station but for some reason the last 2 integers do not show on the Rx serial monitor HOWEVER, occasionally, the Tx values 4 & 5 appear on the Rx side in positions 1 & 2 ie mySensVals[0] & mySensVals[1] before returning to the previous pattern of only receiving the first 3 integers?

I've spent 2 days trying to resolve this problem. Any ideas would be gratefully appreciated (keep it simple please!)

LEM_PV_NRF24L01_Tx_3_12_2015_DC_1.ino (22.4 KB)

LEM_PV_NRF24L01_Rx_3_12_2015_DC_1.ino (3.27 KB)

if ( radio.available() )
{   
  for (int i = 0; i < 5; i = i + 1)
   {    
    radio.read( &mySensVals[i], sizeof(int) ); 
   }
 
}

If there is at least one byte to read, it is NOT OK to read all 10 of them.

"If there is at least one byte to read, it is NOT OK to read all 10 of them."

Sorry, don't understand your reply; can you explain?

PaulS:
If there is at least one byte to read, it is NOT OK to read all 10 of them.

It would be for an NRF24. It sends all the data or nothing.

@dominator99, I think your problem is in this line (from the TX code) and there is probably a corresponding error in the RX code

radio.write( &mySensVals[i],  sizeof(int) );

it should be

radio.write( mySensVals,  sizeof(mySensVals) );

and then you don't need the preceding FOR loop.

...R

Thanks Robin2; that suggested mod sorted it (at last!!)

dominator99:
Thanks Robin2; that suggested mod sorted it (at last!!)

I believe that what I suggested is the standard way to use the NRF24

...R

There's a lot of confusing sketches out there regarding the nRF24L01