Hi everyone,
I recently want to test the function of my Nrf24L01 board
However, it does not work as expected
if I write the program like this, it will shows"error: void value not ignored as it ought to be(at the "done = radio.read( data, sizeof(data) );" part)"
Program(Receiving):
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
char data[50] = "";
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();;
}
void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read( data, sizeof(data) );
Serial.print("Received!");
Serial.println(data);
}
}
else
{
Serial.println("No radio available");
}
}
I did try fixing this problem. However, when I change the code like this, it cannot receive any data:
Program:
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
char data[50] = "";
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();;
}
void loop()
{
bool done = false;
while (radio.available() && !done)
{
radio.read(data, sizeof(data));
Serial.print("Received!");
Serial.println(data);
done = true;
}
if (!done)
{
Serial.println("No radio available");
}
delay(1000);
}
Program(Transmit):
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t abc = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
char data[] = "Hello World, KinCony";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(abc);
}
void loop()
{
Serial.print("Sent!")
radio.write( data, sizeof(data) );
}
I just don't know how to fix, I have been debugging for 6 hours already
Hope you guys can help me!
Love you guys so much <3