Class DS1307 has no member named begin

Can anyone help me with this error because I don't understand what I did wrong?
The error is that class DS1307 has no member named begin.
This is my code


#include <Wire.h>
#include <MFRC522.h> // for the RFID
#include <SPI.h> // for the RFID and SD card module
#include <SD.h> // for the SD card
#include <DS1307RTC.h> // for the RTC

// define pins for RFID
#define CS_RFID 10
#define RST_RFID 9
// define select pin for SD card module
#define CS_SD 4

// Create a file to store the data
File myFile;

// Instance of the class for RFID
MFRC522 rfid(CS_RFID, RST_RFID);

// Variable to hold the tag's UID
String uidString;

// Instance of the class for RTC
DS1307RTC rtc;

// Define check in time
const int checkInHour = 9;
const int checkInMinute = 5;

//Variable to hold user check in
int userCheckInHour;
int userCheckInMinute;

// Pins for LEDs and buzzer
const int redLED = 6;
const int greenLED = 7;

void setup() {

// Set LEDs and buzzer as outputs
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);

// Init Serial port
Serial.begin(9600);
while(!Serial); // for Leonardo/Micro/Zero

// Init SPI bus
SPI.begin();
// Init MFRC522
rfid.PCD_Init();

// Setup for the SD card
Serial.print("Initializing SD card...");
if(!SD.begin(CS_SD)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");

// Setup for the RTC
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)));
}
if(!rtc.isrunning()) {
Serial.println("RTC is NOT running!");
}
}

void loop() {
//look for new cards
if(rfid.PICC_IsNewCardPresent()) {
readRFID();
logCard();
verifyCheckIn();
}
delay(10);
}

void readRFID() {
rfid.PICC_ReadCardSerial();
Serial.print("Tag UID: ");
uidString = String(rfid.uid.uidByte[0]) + " " + String(rfid.uid.uidByte[1]) + " " +
String(rfid.uid.uidByte[2]) + " " + String(rfid.uid.uidByte[3]);
Serial.println(uidString);

delay(100);
}

void logCard() {
// Enables SD card chip select pin
digitalWrite(CS_SD,LOW);

// Open file
myFile=SD.open("DATA.txt", FILE_WRITE);

// If the file opened ok, write to it
if (myFile) {
Serial.println("File opened ok");
myFile.print(uidString);
myFile.print(", ");

// Save time on SD card
DateTime now = rtc.now();
myFile.print(now.year(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.day(), DEC);
myFile.print(',');
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.println(now.minute(), DEC);

// Print time on Serial monitor
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.println(now.minute(), DEC);
Serial.println("sucessfully written on SD card");
myFile.close();

// Save check in time;
userCheckInHour = now.hour();
userCheckInMinute = now.minute();

}
else {
Serial.println("error opening data.txt");
}
// Disables SD card chip select pin
digitalWrite(CS_SD,HIGH);
}

void verifyCheckIn(){
if((userCheckInHour < checkInHour)||((userCheckInHour==checkInHour) && (userCheckInMinute <= checkInMinute))){
digitalWrite(greenLED, HIGH);
delay(2000);
digitalWrite(greenLED,LOW);
Serial.println("You're welcome!");
}
else{
digitalWrite(redLED, HIGH);
delay(2000);
digitalWrite(redLED,LOW);
Serial.println("You are late...");
}
}

Maybe it is spelled Begin. Or maybe the include doesn't match your code.

Which specific library are you trying to use?
This one, does not use .begin().

https://github.com/PaulStoffregen/DS1307RTC/blob/master/DS1307RTC.h

It's always good to like at the example code which usually comes with a library.

The error proves that this is not your code....

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