Arduino: 1.8.16 (Windows 7), Board: "Arduino Uno"
C:\Users\HUA.DELLV-PC\Documents\Arduino\NRF24L01_R_1\NRF24L01_R_1.ino: In function 'void loop()':
NRF24L01_R_1:45:31: error: void value not ignored as it ought to be
done = radio.read(msg, 1);
^
NRF24L01_R_1:51:10: error: expected unqualified-id before '.' token
} Servo.h >
^
exit status 1
void value not ignored as it ought to be
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Thank you.
I used the examples of: RF24Network/examples/helloworld_tx/
and RF24Network/examples/helloworld_rx/
just can't make any communication, what can be wrong?
tx:
/**
* Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network
*
* TRANSMITTER NODE
* Every 2 seconds, send a payload to the receiver node.
*/
#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>
RF24 radio(10, 9); // WAS: 7,8 // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 01; // Address of our node in Octal format
const uint16_t other_node = 00; // Address of the other node in Octal format
const unsigned long interval = 2000; // How often (in ms) to send 'hello world' to the other unit
unsigned long last_sent; // When did we last send?
unsigned long packets_sent; // How many have we sent already
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void) {
Serial.begin(115200);
while (!Serial) {
// some boards need this because of native USB capability
}
Serial.println(F("RF24Network/examples/helloworld_tx/"));
if (!radio.begin()) {
Serial.println(F("Radio hardware not responding!"));
while (1) {
// hold in infinite loop
}
}
radio.setChannel(90);
network.begin(/*node address*/ this_node);
}
void loop() {
network.update(); // Check the network regularly
unsigned long now = millis();
// If it's time to send a message, send it!
if (now - last_sent >= interval) {
last_sent = now;
Serial.print(F("Sending... "));
payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header, &payload, sizeof(payload));
Serial.println(ok ? F("ok.") : F("failed."));
}
}
rx:
/**
* Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network,
*
* RECEIVER NODE
* Listens for messages from the transmitter and prints them out.
*/
#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>
RF24 radio(10, 9); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 00; // Address of our node in Octal format (04, 031, etc)
const uint16_t other_node = 01; // Address of the other node in Octal format
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void) {
Serial.begin(115200);
while (!Serial) {
// some boards need this because of native USB capability
}
Serial.println(F("RF24Network/examples/helloworld_rx/"));
if (!radio.begin()) {
Serial.println(F("Radio hardware not responding!"));
while (1) {
// hold in infinite loop
}
}
radio.setChannel(90);
network.begin(/*node address*/ this_node);
}
void loop(void) {
network.update(); // Check the network regularly
while (network.available()) { // Is there anything ready for us?
RF24NetworkHeader header; // If so, grab it and print it out
payload_t payload;
network.read(header, &payload, sizeof(payload));
Serial.print(F("Received packet: counter="));
Serial.print(payload.counter);
Serial.print(F(", origin timestamp="));
Serial.println(payload.ms);
}
}
Thanks.
I did test without the GND connected for both T/R and got:
Seems got communicated, but the receiver side didn't print out the received data, why?
Both T/R powered by a PC and by Arduino UNO.
I just wonder if the NRF24L01 is such unstable, how it be used? any better board ref. please.
If I used CheckConnection tested and got serial monitor as below, can I consider at least the hardware and wiring is OK?
/* https://forum.arduino.cc/t/simple-nrf24l01-2-4ghz-transceiver-demo/405123/2
*/
// 18 Mar 2018 - simple program to verify connection between Arduino
// and nRF24L01+
// This program does NOT attempt any communication with another nRF24
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
void setup() {
Serial.begin(9600);
Serial.println("xxx_setup!");
Serial.print("File : "), Serial.println(__FILE__);
const char compile_date[] = __DATE__ " " __TIME__;
Serial.print("Compile timestamp: ");
Serial.println(compile_date);
printf_begin();
Serial.println("CheckConnection Starting");
Serial.println();
Serial.println("FIRST WITH THE DEFAULT ADDRESSES after power on");
Serial.println(" Note that RF24 does NOT reset when Arduino resets - only when power is removed");
Serial.println(" If the numbers are mostly 0x00 or 0xff it means that the Arduino is not");
Serial.println(" communicating with the nRF24");
Serial.println();
radio.begin();
radio.printDetails();
Serial.println();
Serial.println();
Serial.println("AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1");
Serial.println(" and 250KBPS data rate");
Serial.println();
radio.openReadingPipe(1, thisSlaveAddress);
radio.setDataRate( RF24_250KBPS );
radio.printDetails();
Serial.println();
Serial.println();
}
void loop() {
}
serial monitor:
FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x000000000e 0x0000000038
RX_ADDR_P2-5 = 0x0e 0x1c 0x0e 0xe0
TX_ADDR = 0x000000000e
RX_PW_P0-6 = 0x1c 0x0e 0x38 0x0e 0x1c 0x0e
EN_AA = 0x1c
EN_RXADDR = 0x0e
RF_CH = 0x1c
RF_SETUP = 0x0e
CONFIG = 0x0e
DYNPD/FEATURE = 0x0e 0x1c
Data Rate = 2MBPS
Model = nRF24L01
CRC Length = 16 bits
PA Power = PA_MAX
AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x000000000e 0x0000000038
RX_ADDR_P2-5 = 0x0e 0x1c 0x0e 0xe0
TX_ADDR = 0x000000000e
RX_PW_P0-6 = 0x1c 0x0e 0x38 0x0e 0x1c 0x0e
EN_AA = 0x1c
EN_RXADDR = 0x0e
RF_CH = 0x1c
RF_SETUP = 0x0e
CONFIG = 0x0e
DYNPD/FEATURE = 0x0e 0x1c
Data Rate = 2MBPS
Model = nRF24L01
CRC Length = 16 bits
PA Power = PA_MAX