Hi,
I am sending an array via the NRF24L01, but I'm having a problem where the receiving side is not getting the correct values. Specifically, when I send an array with 8 values, the receiver gets 0 0 1 0 2 0 3 0 instead of 0 1 2 3 4 5 6 7. Even if I increase the size of the array, I get the same thing with zeros in between ( 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0). This isn't a big problem for me, but I would like to know why this is happening or what I might be doing wrong.
Thank you.
Transmitter code:
#include <Arduino.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4, 5); // CE, CSN
const byte address[6] = "00001";
int values[8] = {0,1,2,3,4,5,6,7};
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
Serial.begin(9600);
}
void loop() {
radio.write(values, sizeof(values));
}
Receiver code:
#include <Arduino.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(A4, A5); // CE, CSN
const byte address[6] = "00001";
int values[8];
void setup() {
Serial.begin(9600);
radio.begin(A4, A5);
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
if (radio.available()) {
radio.read(values, sizeof(values));
for(int i = 0; i <8; i++){
Serial.print(values[i]);
Serial.print(" ");
}
Serial.println("");
}
}