#include <Wire.h>
#include "RTClib.h"

// RTC variables
RTC_DS1307 rtc;
const int sclPin = D1;
const int sdaPin = D2;
char daysOfTheWeek[7][12] = {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};


void setup () {
// Pinout Setup
  Wire.begin(sdaPin, sclPin);

//Communication Setup
  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    rtc.adjust(DateTime(2019, 8, 28, 3, 15, 44)); // 
  }
  
}

void loop () {
// RTC Part
   DateTime now = rtc.now();
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(",  ");
   
    if (now.day() < 10)    {Serial.print('0');}
    Serial.print(now.day(), DEC);
    Serial.print('.');
    if (now.month() < 10)  {Serial.print('0');}
    Serial.print(now.month(), DEC);
    Serial.print('.');
    Serial.print(now.year(), DEC);
    Serial.print(",  ");
   
    if (now.hour() < 10)   {Serial.print('0');}
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    if (now.minute() < 10) {Serial.print('0');}
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    if (now.second() < 10) {Serial.print('0');}
    Serial.print(now.second(), DEC);
    Serial.print(",  ");
    Serial.println(); 
    delay(1000);
}


