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);
}
}