I have the weather board with an esp32 processor. All works OK except the SD slot. I can get the SD slot to initialise using the SD.h library but it will not read or write to the card. For example compiling the ‘SD card read/write’ example it initialises OK but the opening of the file (the card is blank and re-formatted) gets the “error opening test.txt” text. I’ve tried reformatting, resetting the board etc. but no luck. I’ve tried 32GB cards and 2GB cards with the same result. I’ve read elsewhere that the speed of the SPI connection could be the issue.
/*
Measure and log the humidity in a room using Sparkfun micromod board and ESP32 processor.
Also using the PCF8523 rtc breakout board via the Quicc connector.
*/
#include "RTClib.h" //Adafruit PCF8523 RTC
#include <SPI.h>
#include <SD.h>
#include "SparkFunBME280.h" //Temp/Humid sensor
#include "SparkFun_AS3935.h" //Lightening detector to powerdown to save battery
#include <SparkFun_VEML6075_Arduino_Library.h> //UV Detector
File myFile;
BME280 aht;
SparkFun_AS3935 lightning;
VEML6075 uv;
RTC_PCF8523 rtc;
const int chipSelect = 5;
String tem="";
void setup() {
Serial.begin(115200);
while (!Serial) {}
if (!SD.begin(chipSelect)) {
Serial.println("SD initialization failed!");
while (1);
}
Serial.println("SD initialization done.");
if (SD.exists("Humid.csv")) SD.remove("Humid.csv");
myFile = SD.open("Humid.csv", FILE_WRITE);
if (!myFile)
{
Serial.println("Problem creating/opening file, stopping");
while (1);
}
It initialises the card OK but always fails at the opening of the file. I’ve checked it’s using the proper SD library for the ESP32 processor and that is OK.