Hi,
maybe my problem is a trivial one but I'm still a newbie and, even after extensive googling, I was not able to find a solution.
Since i need to collect data on a SD card from a temp/hum sensor every ten minutes in an area where there is no available wifi i tried to use a DS3231RTC to timestamp the sensor readings while in the intervals the ESP goes to deepsleep and awakes at a fixed interval.
I was able to achieve this result by using an ESP 8266 but when I tried to use an ESP32 I found that the ESP was continuously rebooting even if the code was compiled without any problem.
So I tried to identify the problem by removing the SD card but it was still present and it disappeared ONLY when i removed the DS3231RTC.
Moreover, the serial monitor just displays garbage characters and even if I modify the baud rate I'm not able to obtain any usefui info on what's going on.
The code I'm using is the following
#include <SPI.h> //for the SD card 
#include <Wire.h>
#include <SD.h> // for the SD card
const int chipSelect = 15;
// Create a file to store the data
File myFile;
#include <RTClib.h> // for the RTC
RTC_DS3231 rtc; 
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_ADDR   0x3C
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 1  // Pin 8
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#include <SHT3x.h>
SHT3x Sensor; //This operates in Celsius
float temp;
float hum;
uint64_t uS_TO_S_FACTOR = 1000000; 
uint64_t TIME_TO_SLEEP = 600;
void setup() {
  //initializing Serial monitor
  Serial.begin(115200);
    while(!Serial);
  delay(1000);
    
 Sensor.Begin();
 Sensor.UpdateData();
  
   // setup for the RTC
  while(!Serial); 
  delay(1000);
 if(! rtc.begin()) {
      Serial.println("Couldn't find RTC");
      while (1);
    }
    else {
      // following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    }
  
  temp = Sensor.GetTemperature();
  hum = Sensor.GetRelHumidity();
  // setup for the SD card
  Serial.print("Init SD");
  if(!SD.begin(chipSelect)) {
    Serial.println("Failed");
    return;
  }
    
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
 
  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.clearDisplay();  //Pulisce il buffer da inviare al display
  display.setTextSize(1);  
  display.setTextColor(WHITE);
  display.ssd1306_command(SSD1306_DISPLAYON); 
  loggingTime();
  loggingTemperature();
  displayReadings();
  SD_writing();
  delay(5000);
   display.ssd1306_command(SSD1306_DISPLAYOFF);
   Serial.println("Sensor data logged successfully! Going to sleep");
 esp_deep_sleep_start();
    
}
void loggingTime() {
  DateTime now = rtc.now();
char dateString[11];
  sprintf(dateString, "%04i-%02i-%02i  ", now.year(), now.month(), (now.day()));
  
char timeString[9];
  sprintf(timeString, "%02i:%02i:%02i", now.hour(), now.minute(), now.second());
}
 void loggingTemperature() {
Serial.print("Temperature_SHT31 = ");
  Serial.print(Sensor.GetTemperature());
  Serial.println(" *C");
 Serial.print("Humidity_SHT31 = ");
  Serial.print(Sensor.GetRelHumidity());
  Serial.println(" %");
    }
 
void SD_writing() {
      DateTime now = rtc.now();
char dateString[11];
  sprintf(dateString, "%04i-%02i-%02i  ", now.year(), now.month(), (now.day()));
  
char timeString[9];
  sprintf(timeString, "%02i:%02i:%02i", now.hour(), now.minute(), now.second());
 myFile = SD.open("DATA.txt", FILE_WRITE);
  if (myFile) {
    myFile.print(timeString);
    myFile.print(",");
    myFile.print(temp);
    myFile.print(",");
   myFile.print(hum);
    myFile.println(","); 
  myFile.close();
} 
}
void displayReadings() {
   DateTime now = rtc.now();
char dateString[11];
  sprintf(dateString, "%04i-%02i-%02i  ", now.year(), now.month(), (now.day()));
  
char timeString[9];
  sprintf(timeString, "%02i:%02i:%02i", now.hour(), now.minute(), now.second());
  
display.clearDisplay();
display.setCursor(0,0); 
//display.println(dateString);
display.setCursor(0,24); 
display.print("T_SHT31   ");
display.print(Sensor.GetTemperature());
display.println(" C"); 
display.print("Hum_SHT31  ");
display.print(Sensor.GetRelHumidity());
display.println(" %");
display.setCursor(0,48);
display.print("going to sleep for 1 min");
display.display(); //Invia il buffer da visualizzare al display
}
void loop() {
}
  
Thx in advance for your help

