I'm using a DS1307 RTC (https://www.adafruit.com/product/3296) and an Arduino mega microcontroller trying to simply set and read the time of the RTC. However, whenever I try to output anything to the Serial Monitor, I get stuff like this:

Example Output

The code and the wiring is fairly straightforward which is why I'm confused. I'm just directly attaching the Vcc, GRND, SCL and SDA pins of the clock to the Arduino and using a slightly modified version of the example code as a part of the RTC library Adafruit supplied.

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

RTC_DS1307 rtc;

void setup () {
  while (!Serial); // for Leonardo/Micro/Zero


  rtc.adjust(DateTime(2017, 11, 17, 20, 33, 0));


void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print(now.month(), DEC);
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(now.minute(), DEC);
    Serial.print(now.second(), DEC);


So I know I'm doing something wrong but I'm not sure what. Any help would be hugely appreciated.

  • Can you post a schematic of how you have the DS1307 wired?
    – ThreePhaseEel
    Nov 18 '17 at 0:50
  • Looks like a baud rate issue. Check your clock speed and settings.
    – Trevor
    Nov 18 '17 at 1:54
  • Set the serial monitor to 57600 and check.
    – ammar.cma
    Nov 18 '17 at 2:38
  • @ammar.cma In the code above you can see that I did set the serial monitor to 57600
    – chrispy
    Nov 19 '17 at 0:24
  • @Trevor What should I be changing it too exactly?
    – chrispy
    Nov 19 '17 at 0:25

Change the baud rate to 57600, it specifies at: Serial.begin(57600);

  • Thank you for the advice @senpaiscuba. I am new to stackoverflow and did not realize you could edit after posting.
    – jpo43
    Apr 17 '18 at 18:58

Your Answer

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