Using MicroSD noname board fails with R4 works on R3

I just got a R4 minima and was messing around with it. I made a little breadboard set up with an RTC board and a microsd card. The codes runs and works properly on a R3, but when I recompile for the R4 and move the breadboard connection over to the same digital ports on the R4. I can't get the SD card to initialize. Could this be because of the lower amperage of the output pins on the R4?

Here is the code:

/*
  SD card datalogger

  This example shows how to log data from three analog sensors
  to an SD card using the SD library. Pin numbers reflect the default
  SPI pins for Uno and Nano models

  The circuit:
   analog sensors on analog pins 0, 1, and 2
   SD card attached to SPI bus as follows:
 ** SDO - pin 11
 ** SDI - pin 12
 ** CLK - pin 13
 ** CS - depends on your SD card shield or module.
 		Pin 10 used here for consistency with other Arduino examples
    (for MKR Zero SD: SDCARD_SS_PIN)

  created  24 Nov 2010
  modified  24 July 2020
  by Tom Igoe

  This example code is in the public domain.

*/

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <I2C_RTC.h>

static DS3231 RTC;

const int chipSelect = 10;

void setup() {

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // wait for Serial Monitor to connect. Needed for native USB port boards only:
  while (!Serial)
    ;

  pinMode(chipSelect, OUTPUT);

  Serial.print("Initializing SD card...");

  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("1. is a card inserted?");
    Serial.println("2. is your wiring correct?");
    Serial.println("3. did you change the chipSelect pin to match your shield or module?");
    Serial.println("Note: press reset button on the board and reopen this Serial Monitor after fixing your issue!");
    while (true)
      ;
  }

  ///////////////////////// RTC ///////////////////////////

  RTC.begin();
  if (RTC.isConnected() == false) {
    Serial.println("RTC Not Connected!");
    while (true)
      ;
  }

  Serial.println("*** RTC DS3231 ***");
  Serial.print("Is Clock Running : ");
  if (RTC.isRunning()) Serial.println("Yes");
  else {
    Serial.println("No - Set the date and time");
    RTC.setDateTime(__DATE__, __TIME__);
    RTC.startClock();
  }

  Serial.print("Hour Mode : ");
  if (RTC.getHourMode() == CLOCK_H24)
    Serial.println("24 Hours");
  else
    Serial.println("12 Hours");

  /////////////////////////////////////////////////////////

  Serial.println("initialization done.");
}
String getNowString(bool hour24 = true) {
  String s(RTC.getYear());
  s += "/";
  s += RTC.getMonth();
  s += "/";
  s += RTC.getDay();
  s += " ";
  int h = RTC.getHours();
  if (!hour24 && h > 12) h -= 12;
  s += h;
  s += ":";
  s += RTC.getMinutes();
  return s;
}

void loop() {
  // make a string for assembling the data to log:
  String dataString = getNowString();
  dataString += " ";

  // read three sensors and append to the string:
  for (int analogPin = 0; analogPin < 3; analogPin++) {
    int sensor = analogRead(analogPin);
    dataString += String(sensor);
    if (analogPin < 2) {
      dataString += ",";
    }
  }

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }

  // Serial.print(getNowString());
  // Serial.print(" ");
  // Serial.print(getNowString(false));
  // Serial.print(", Unix Time: ");
  // Serial.println(RTC.getEpoch());
}

The wiring is pretty simple: VCC and GND with SCL and SDA are connected to the RTC board.

For the microcd board, VCC and GND, with pins 10-13 used for the SPI to it;

Like I said the exact same connections on the R3 works perfectly, but the same connections to the R4 do not.

Monty

Here is how it is wired up.

This is all on a breadboard, if that matters.

Weird - works great with R3

Monty

As Emily Litella once said: Nevermind.

I wired the sd directly to the R4 eliminating the breadboard and viola it works on R3 and R4

Monty

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