I am trying to save data on a SD card through rf24 radio link and add the time, but can't get them to work together. the radio link works ok without the SD but not when the SD device is in place. The TX gets ack when SD device not fitted but no ack when it is fitted.
I have separate CS pins for each device, pin 10 for radio, pin 14 for SD, and switch them on/off when needed with no effect.
Below is a simplified test prog:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const int SDCS = 14; // CS pin of SD card
const int RadCE = 9; // CS pin of Radio card
const int RadCS = 10; // CS pin of Radio card
RF24 radio(RadCE, RadCS); // Tx/Rx Pins 9-CE, 10-CSN, 11-MOSI, 12-MISO, 13-SCK, 3.3V, GND
const byte address[6] = {"00003"}; // 5 letter pipe/address string of nodes
char dataReceived[10]; // Max text chars, matching Tx
int input = 0; // test data
void Receive_Remote_Count() { // Receive data from remote sensors
digitalWrite(RadCS, LOW);
if (radio.available()) {
radio.read(&dataReceived, sizeof(dataReceived)); // Receive "count" & no. of bit
Serial.println(dataReceived);
input = 1; // Data to save
}
else {
input = 0;
}
Serial.print(" Receiving "); Serial.println(input);
digitalWrite(RadCS, HIGH);
}
void setup() {
Serial.begin(9600);
Serial.println("Radio Test");
delay(1000); // Give time to read
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setPALevel(RF24_PA_LOW); // Power setting MIN, LOW, HIGH or MAX
radio.openReadingPipe(0, address);
radio.startListening(); // Set as Receiver
SPI.begin();
pinMode(SDCS, OUTPUT);
digitalWrite(RadCS, HIGH);
digitalWrite(SDCS, HIGH);
}
void loop() {
Receive_Remote_Count();
delay(1000);
}