ESP32-CAM timelapse

Not sure where to put this post, or even if Aruino.cc is appropriate. Hopefully someone can help out.

I'm trying to use the ESP32-CAM as a timelapse camera, storing the images on the module's SD card. I'm using this sketch:

I have it uploaded and running, but the Serial Monitor shows "No SD Card attached" message. And, of course, no images are being saved to the SD Card. I tried with 1GB, 2GB, and 16GB cards with no luck.

Anyone know anything about this?

The camera itself does work, as I can successfully run the "ESP32-CAM webserver" example sketch. Not sure what's going on the with the SD Card.

I tried a different sketch, which works:

So, something wrong with the sketch I first posted. And that's the one with time lapse functionality. Possibly something to do with the LED being on the same pin (4) as needed for the SD card and perhaps the sketch isn't properly handling that.

I figured it out. The card init sequence is the problem. I used the init sequence from the "demo" link in my second post and it all works now.

So to sum up, for this sketch:

Comment out this:

//uint8_t cardType = SD_MMC.cardType();
//if(!SD_MMC.begin()){Serial.println("SD Card Mount Failed");return;}
//if(cardType == CARD_NONE){Serial.println("No SD Card attached");return;}

And replace it with this:

if (!SD_MMC.begin("/sdcard", true)) {
        Serial.println("No SD Card detected"); 
      } else {
        uint8_t cardType = SD_MMC.cardType();
        if (cardType == CARD_NONE) {              // if invalid card found
            Serial.println("SD Card type detect failed"); 
        }
      }