The program is supposed to take photo and store the picture into the SD card with the timestamp.

My Program Code:

#include <SdFat.h>
#include <Adafruit_VC0706.h>
#include <SPI.h>
#include <SoftwareSerial.h>
#include <RTClib.h>
#include <Wire.h>
#include <SD.h>

#define SD_CS D8    //For NodeMCU Kit Set version 1
#define DS3231_ADDRESS  0x68  ///< I2C address for DS3231

SoftwareSerial mySerial (D4, D3); //D4-RX, D3 TX For NodeMCU Kit Set version 1
Adafruit_VC0706 cam = Adafruit_VC0706(&mySerial);
File myFile;  // test file
RTC_DS3231 RTC;  // define the Real Time Clock object

char timestamp[30];
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup()
  pinMode(SD_CS, OUTPUT);

  Wire.begin ( D1, D2); //D1=SDA D2=SCL
  if (!SD.begin(SD_CS))
    Serial.println("SD card is not inserted");

  Serial.println("SD Card Present");

  // Try to locate the camera
  if (cam.begin()) {
    Serial.println("Camera Found:");
  } else {
    Serial.println("No camera found?");

  if (!RTC.begin()) {
    Serial.println("RTC failed");
    while (1);

  //  ESP.deepSleep(0);  //deep sleep mode until RESET pin is connected to a LOW signal

void loop() {

void snapshot() {
  // Set the picture size - you can choose one of 640x480, 320x240 or 160x120

  cam.setImageSize(VC0706_320x240);        // medium

  //cam.setImageSize(VC0706_160x120);          // small

  // You can read the size back from the camera (optional, but maybe useful?)
  uint8_t imgsize = cam.getImageSize();
  Serial.print("Image size: ");
  // Serial.println("640x480");
  // Serial.println("160x120");


  if (!cam.takePicture())
    Serial.println("Failed to snap!");
    Serial.println("Picture taken!");
  // Create an image with the name IMGxxxx.JPG
  char filename[13];
  strcpy(filename, "IMG0001.JPG");
  for (int i = 1; i < 10000; i++) {
    filename[3] = '0' + i / 1000;
    filename[4] = '0' + i % 1000 / 10;
    filename[5] = '0' + i % 100 / 10;
    filename[6] = '0' + i % 10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {

  // Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);
  SdFile::dateTimeCallback(dateTime); //Timestamp for file
  // Get the size of the image (frame) taken
  uint16_t jpglen = cam.frameLength();
  Serial.print("Storing ");
  Serial.print(jpglen, DEC);
  Serial.print(" byte image.");

  int32_t time = millis();
  //pinMode(D8, OUTPUT);
  byte wCount = 0; // For counting # of writes
  while (jpglen > 0) {
    // read 32 bytes at a time;
    uint8_t *buffer;
    uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);
    imgFile.write(buffer, bytesToRead);
    if (++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
      wCount = 0;
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;

  time = millis() - time;
  Serial.print(time); Serial.println(" ms elapsed");
  Serial.println("Storing Time in Textfile");
  myFile = SD.open("DATES.txt", FILE_WRITE);
  DateTime now = RTC.now();
  myFile.print(' ');
  myFile.print(now.year(), DEC);
  myFile.print(now.month(), DEC);
  myFile.print(now.day(), DEC);
  myFile.print(" (");
  myFile.print(") ");
  myFile.print(now.hour(), DEC);
  myFile.print(now.minute(), DEC);
  myFile.print(now.second(), DEC);
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
  DateTime now = RTC.now();
  sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year() - 2000);
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());

  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());

The error message is too long so I can only copy paste some parts which I think might be relevant:

    In file included from C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SD\src/SD.h:25:0,

                     from C:\Users\ACER\Documents\Arduino\libraries\JPEGDecoder-master\src/JPEGDecoder.h:56,

                     from C:\Users\ACER\Desktop\Arduino IDE\Snapshot NodeMCU with RTC\Snapshot_NodeMCU___RTC\Snapshot_NodeMCU___RTC.ino:4:

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:190:5: error: 'sdfat' does not name a type

         sdfat::SdFat* getFs()


    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:215:5: error: 'sdfat' does not name a type

         sdfat::SdFat _fs;


    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h: In member function 'virtual bool sdfs::SDFSImpl::exists(const char*)':

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:98:27: error: '_fs' was not declared in this scope

             return _mounted ? _fs.exists(path) : false;


    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h: In member function 'virtual bool sdfs::SDFSImpl::rename(const char*, const char*)':

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:104:27: error: '_fs' was not declared in this scope

             return _mounted ? _fs.rename(pathFrom, pathTo) : false;


    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h: In member function 'virtual bool sdfs::SDFSImpl::info(fs::FSInfo&)':

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:113:26: error: '_fs' was not declared in this scope

             info.blockSize = _fs.vol()->blocksPerCluster() * 512;

reference to 'File' is ambiguous

    //There are a lot of '???' not declared in this scope and 'sdfat' does not name a type error.

At first, there was a different error that states that SdFile::dateTimeCallback(dateTime); is not declared. After doing some research online, I tried to install SdFat library here to see if it helps and after installing I got more error as shown above. How can I solve these errors?

  • Are these the very first errors reported by the compiler? Anything that follows the first ones may be noise. Sep 18, 2019 at 8:44
  • 1
    Why are you trying to use both SdFat and SD?
    – Majenko
    Sep 18, 2019 at 8:54
  • Before, I was using SD only but the error SdFile::dateTimeCallback(dateTime); is not declared comes out. I when online to see if there are only solution and I ended up downloading the SdFat library and use it. It got rid of the error but now I have all the other errors coming out.
    – Jessica
    Sep 19, 2019 at 1:10


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.