Arduino Uno Adafruit SD Card Module and nRF24L01 Issue

I am fairly new to programming and Arduinos. For a project, I am using an Adafruit SD card module and an nRF24L01 together for a project that sends data between two nRF24L01's and then saves the data on the receiver end to the SD card module. I am able to get them to work separately, but when connected I am unable to use the code that I have for them together. For example, combining the code for sending the data and then storing the data, all within the loop causes the received data to not be sent at all. Thanks!

This is the code I have of them working separately, with one in the loop and the other in setup:

#include <SD.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN 7 // 
#define CSN_PIN 8 //chip select for rf
#define csPin 10 // chip select for SDCard

RF24 radio(CE_PIN, CSN_PIN); // rf ce,cs

const byte address[6] = "00001";
 
File myFile;
 
void setup()
{
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  Serial.print("Initializing SD card...");

//  pinMode(10, OUTPUT);
 
  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);
 
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
  // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}
 
void loop()
{
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

I am not sure if this portion would help, but this is what I am sending with the transmitter:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

show schematic of your project
nRF need it's own 3,3V supply + capacitor.

How would I be able to tell if the SD module would let the MISO free? This is what I found for a schematic for the module: Download | Micro SD Card Breakout Board Tutorial | Adafruit Learning System

Adafruit is very probably ok. check then powering of nRF. show your setup.

I'm not sure how useful this image will be, but I am sharing the CLK, DO, and DI between the two modules. They are both powered straight from the 5 V supplied by the Arduino. The SD module is going into digital 10 and the nRF is going into digital 7 and 8.

do you say nRF24L01 work from 5V if no SD module?

Yes it was working from 5V without the SD module.

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