Hi all
I wonder if someone could please assist me with how to solve what I suspect is a conflict somewhere between libraries or hardware (????) I'm really not sure at the moment and could use a little help.
I current have an Arduino UNO , a DS1307 and an NRF24L01 module connected.
All work perfectly well individually as well as in the following combinations:
Arduino on its own = Working
Arduino + DS1307 = Working
In the current code I would normally see the time and date displayed every second. I can also run most of the examples just fine.
The libraries I am using here are:
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>
Arduino + NRF24L01 = Working
Also working great when using the RF24 library and I am able to run a simple continuous send and transmit without issues. As well as the examples
The libraries I am using here are:
#include <SPI.h>
#include "RF24.h"
When I connect both the DS1307 and the NRF24L01 it looks like all is good in terms of hardware until I run the code.
I set the code to do a clock update every second as well as a simple transmit of a message on every loop of the ""void loop"".
The code compiles just fine without issues.
The problem is that when I open the serial monitor I see absolutely nothing. It's just blank
and the receiving NRF24L01 receives nothing.
//for NRF
#include <SPI.h>
#include "RF24.h"
// Your chosen radio CE,CS pins
RF24 radio(9,10);
uint64_t addresses[] = {
0xABABABABABLL, 0xC3C3C3C3C3LL};
/****** Configure this for sender or receiver *****/
boolean sender = 1; // Change this from 0 to 1 to switch between sending or receiving sketch
//for DS1307 RTC
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>
void setup() {
Serial.begin(9600);
//DS1307
while (!Serial) ;
setSyncProvider(RTC.get);
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
//test field for setTime
Serial.println("Time is now set using setTime");
setTime(21,30,50,12,4,2015);
RTC.set(now());
//NRF24L01
radio.begin();
if(sender == 0){
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1,addresses[0]);
radio.startListening();
}
else{
radio.openWritingPipe(addresses[0]); //*Edit to correct address assignments
radio.openReadingPipe(1,addresses[1]);
radio.stopListening();
}
}
char myArray[] = "This is not a test";
//*****ALL WORKING UP TO HERE !!
void loop() {
if (timeStatus() == timeSet) {
digitalClockDisplay();
}
else { //add or change later
Serial.println("The time has not been set. Please run the Time");
Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
Serial.println();
delay(1000);
}
//*****ALL WORKING UP TO HERE
//BUT WHEN I ADD THIS IN THE COMPILE IS FINE BUT NOTHING APPEARS
//IN THE SERIAL MONITOR :-(
//NRF 24L01
if(sender == 0){
if(radio.available()){
char tmpArray[19];
radio.read(&tmpArray,sizeof(tmpArray));
Serial.println(tmpArray);
delay(200);
}
}
else{
bool ok = radio.write(&myArray,sizeof(myArray));
if(ok){
Serial.println("Transfer OK");
}
else {
Serial.println("Transfer Fail");
}
delay(500);
}
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
I would appreciate and look forward to any help or advice.
D