RF-NANO Combines Nano with nRF24L01

I have scoured the net for any kind of solutions to get either an Arduino UNO to work with the nRF24L01 X-mitters with no avail...BUT I found a RF_NANO which combines the two into one board...very cool.
I again scoured the net for some sort of code that works, again there is a hodge podge of stuff with no real solutions.
After hours of trying my patience, it worked.
many post reference the CS, CSN as 7,8. That was incorrect. the correct values are 10,9.
I wanted to setup two RF-Nanos one sending rtc data and the other receiving that data...sounds simple. It should have been.
This is how I wired the rtc to rf-nano.
RTC RF_Nano
SCL A5
SDA A4
VCC 5V
GND GND

I am posting my code so anyone else who has been trying to work a nRF24L01 into a project and are not happy can find some relief...

[code]
//transmitter
#include <nRF24L01.h>
#include <RF24.h>
#include <RTClib.h>

#include <SPI.h>
RTC_DS1307 rtc;

RF24 radio(10, 9); // CE, CSN
#define Write_Address 11111
const char text[32];
bool radioReady = false;

void setup() {
  Serial.begin(9600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();    
    while (1) delay(10);
  }
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
 
  // Configure the Radio
  radio.begin();
  radio.setChannel(115);
  radio.openWritingPipe(Write_Address); 
  radio.setDataRate(RF24_1MBPS); 
  radio.setPALevel(RF24_PA_MAX);
  radio.setPayloadSize(sizeof(text));
  radio.setAutoAck(true);
  radio.stopListening();
  Serial.println("Radio initialised!");
}

void loop() { 
  DateTime now = rtc.now();
  sprintf(text, "%i/%i/%i %i:%i:%i",
    now.year(),now.month(),now.day(),now.hour(),now.minute(),now.second());
  Serial.print(text);
  radio.write(&text, sizeof(text));
  delay(1000);
}
[/code]
//receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(10, 9); // CE, CSN
#define Read_Address 11111
char text[32];
bool radioReady = false;
uint8_t bytes;

void setup() {
  Serial.begin(9600);
  // Configure the Radio
  radio.begin();
  radio.setChannel(115);
  radio.openReadingPipe(0, Read_Address); 
  radio.setDataRate(RF24_1MBPS); 
  radio.setPALevel(RF24_PA_MAX); 
  radio.setPayloadSize(sizeof(text));
  radio.setAutoAck(true); 
  radio.startListening();
  bytes = radio.getPayloadSize();

  Serial.println("Radio initialised!");
}

void loop() {
  if (radio.available()) { 
    radio.read(text, bytes);
    Serial.print("msg=");Serial.println(text);
  }
}

This setting might be illegal in your country, it leaves the 2.4GHz band.

Will this be interpreted as LL or as a void*?
If it is the deprecated LL, it is prone to receive junk packets, it has too many zeros in a row.

I prefer something like

const char usedAdr[] = "aPipe";

The maximum bandwidth is 2MBPS.

Both settings are the default, no reason to set them.

I hate comments that are obviously false.

Retrieving a constant over and over is strange.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.