# DS1307 not working

**URL:** <https://forum.arduino.cc/t/ds1307-not-working/1434904>\
**Category:** General Guidance\
**Created:** [March 12, 2026, 7:50am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904 "2026-03-12T07:50:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 7:50am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/1 "2026-03-12T07:50:26Z")

</div>

Hello, I need to have time information for a project and i'm using an RTC to get the time info but i couldn't get it to work, I tried a lot of codes online without any result, Same for the library sample code  
the library sample code sends me 2000 for yyyy and always 0 for date and time  
I've wired up all data pins to A0-A1-A2 and tried powering it using coin cell (3V) and arduino power, neither worked  
I would appreciate any help thanks ! if you need anymore informations don't hesitate !

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 8:01am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/2 "2026-03-12T08:01:56Z")

</div>

Try the following sketch which I have tested on DS1307 Breakout board (Fig-1):

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/1/1/0/1107550a2f6d7935fa26f7cd9837644ac15a9b79.png)  
Figure-1:

```arduino
#include "RTClib.h"
#include<Wire.h>
byte lastReadSecond = 0;

RTC_DS1307 rtc; //RTC_DS3231 rtc; //user data type RTC_DS3231 variable rtc or object
DateTime nowDT;

void setup ()
{
  Serial.begin(9600);
  rtc.begin();
  //rtc.adjust(DateTime(F( __DATE__ ), F( __TIME__ )));
  rtc.adjust(DateTime(2024, 7, 12, 4, 21, 10));//set date-time manualy:yr,mo,dy,hr,mn,sec
}

void loop ()
{
  nowDT = rtc.now();
  if (lastReadSecond != nowDT.second()) //RTC has crossed 1 sec time
  {
    lastReadSecond = nowDT.second();
    showTime();
  }
}

//===================================================
void showTime()
{
  nowDT = rtc.now(); //nowDT hold Date and Time
// lastReadSecond = nowDT.second();
  //---------------------------
  byte myHour = nowDT.hour(); //myHour holds Hour of time of daya
  if (myHour > 12)
  {
    myHour = myHour - 12;
  }
  Serial.print(myHour); //12:58:57 12:4:56
  Serial.print(':');
  //-------------------------------------------------
  byte myMin = nowDT.minute(); //to show leading zero of minute
   if (myMin < 10)
  {
    Serial.print('0');
  }
  Serial.print(nowDT.minute()); Serial.print(':');
  //--------------------------------------------------
  byte mySec = nowDT.second();
  if (mySec < 10)
  {
    Serial.print('0');
  }
  Serial.println(mySec);
}
//---------------------------------------------

```

---

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 8:11am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/3 "2026-03-12T08:11:53Z")

</div>

Hey thanks for helping, although

```arduino
 if (lastReadSecond != nowDT.second())

```

This part is never True, and if i get the showTime() function out it sends out this  
`09:09:14.015 -> 94:04:00`  
Maybe the problem is the board ?

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 8:19am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/4 "2026-03-12T08:19:34Z")

</div>

> [@hon38148lk](#):
>
> ` if (lastReadSecond != nowDT.second())`

You need this line to know when the RTC has crossed on second time and then update the time of the day.

---

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 8:22am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/5 "2026-03-12T08:22:28Z")

</div>

I've noticed that yes but the lastReadSecond is never updated and therefor is always == to nowDT

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 8:38am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/6 "2026-03-12T08:38:28Z")

</div>

Do you have any other DS1307 RTC or DS3231 RTC to try?

---

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 8:44am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/7 "2026-03-12T08:44:38Z")

</div>

I'm considering changing board anyway yes, Thanks for the help tho  
i'll try out a few of them it's not the most expensive board anyway

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [March 12, 2026, 8:45am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/8 "2026-03-12T08:45:44Z")

</div>

> [@hon38148lk](#):
>
> I've wired up all data pins to A0-A1-A2

Well that sounds wrong to begin with.

Please read the forum guide in the sticky post and follow it. If you don't do that, you prevent us from helping you.

---

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 10:29am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/9 "2026-03-12T10:29:09Z")

</div>

I think i will try to get a ne RTC, the one i use is quite old and i've heard DS3231 is better anyway  
Sorry for the time loss

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 10:35am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/10 "2026-03-12T10:35:51Z")

</div>

> [@hon38148lk](#):
>
> Sorry for the time loss

This is not time loss, but a part of process/work.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [March 12, 2026, 10:36am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/11 "2026-03-12T10:36:09Z")

</div>

> [@GolamMostafa](#):
>
> `lastReadSecond = nowDT.second();`

That's where _lastReadSecond_ gets updated.

It would be more obvious done elsewhere

```arduino
void loop ()
{
  nowDT = rtc.now();
  if (lastReadSecond != nowDT.second())
  {
    lastReadSecond = nowDT.second();
    showTime();
  }
}

```

But @hon38148lk will have the same issues with any I2C RTC if she does not wire it using SDA and SCL… on the UNO those are A4 and A5.

And what is the third data line?

a7

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 10:41am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/12 "2026-03-12T10:41:41Z")

</div>

> [@alto777](#):
>
> It would be more obvious done elsewhere
> 
> ```arduino
> void loop ()
> {
> nowDT = rtc.now();
> if (lastReadSecond != nowDT.second())
> {
> lastReadSecond = nowDT.second();
> showTime();
> }
> }
> 
> ```

Right!

I delete the following line from `showTime()` and edit the original post as per above.

```arduino
lastReadSecond = nowDT.second();

```

---

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 10:59am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/13 "2026-03-12T10:59:46Z")

</div>

In order the pins are DS SCL SDA (VCC GND) But i see my mistake indeed thanks, I'll try this later on since i have to move on for now

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [March 12, 2026, 11:07am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/14 "2026-03-12T11:07:47Z")

</div>

@hon38148lk - until you want to use the temperature sensor that is on the module, just forget about DS.

You only need power, ground and the I2C lines.

If that does not work right away, there's one last subtlety.

We here.

a7

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 11:24am UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/15 "2026-03-12T11:24:10Z")

</div>

> [@hon38148lk](#):
>
> In order the pins are DS SCL SDA (VCC GND) But i see my mistake indeed thanks, I'll try this later on since i have to move on for now

This is the circuit for DS1307 breakout board; where, you can clearly identify the pin signals. DS18B20 is the digital temperature sensor which does not come with the breakout board. There are PCB holes to place and solder the legs of the sensor. There is a non-volatile EEPROM (AT24C32) chip to store the times of the day.

 ![](https://europe1.discourse-cdn.com/arduino/original/4X/c/b/5/cb5a2a010e87d05a7385e59893634e84eac72a49.gif)

---

<div class="post-metadata">

**Author:** ![tigger](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tigger/32/1104210_2.png) [@tigger](https://forum.arduino.cc/u/tigger)\
**Post date:** [March 12, 2026, 12:04pm UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/16 "2026-03-12T12:04:04Z")

</div>

These chips or modules aren't usually a problem.  
Follow the guides and examples.  
Yes, the DS3231 is better than the DS1307.  
DS3231 without fine tuning achieves +/- 1 second a month against MSF60.  
Highly accurate atomic clocks achieve +/- seconds in 40-billion years.  
Staggering.

---

<div class="post-metadata">

**Author:** ![build\_1971](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/build_1971/32/689930_2.png) [@build\_1971](https://forum.arduino.cc/u/build_1971)\
**Post date:** [March 12, 2026, 12:17pm UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/17 "2026-03-12T12:17:05Z")

</div>

> [@tigger](#):
>
> Highly accurate atomic clocks achieve +/- seconds in 40-billion years.

Really handy! You can always be exactly on time...

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [March 12, 2026, 12:54pm UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/18 "2026-03-12T12:54:15Z")

</div>

> [@GolamMostafa](#):
>
> This is the circuit for DS1307 breakout board

That is the circuit for some DS1307 breakout board.

It may be the very one @hon38148lk has in front of her right now, but it doesn't look anything like the several different DS1307 RTC modules I have in my lab.

If the module has the diode/resistor "charging" circuit, one of R5 and D1 should be removed.

See

[https://campercontrol.devcave.uk/step-1-assembling-control-box/modifying-rtc-module/](https://campercontrol.devcave.uk/step-1-assembling-control-box/modifying-rtc-module/)

a7

---

<div class="post-metadata">

**Author:** ![hon38148lk](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hon38148lk/32/1244043_2.png) [@hon38148lk](https://forum.arduino.cc/u/hon38148lk)\
**Post date:** [March 12, 2026, 3:04pm UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/19 "2026-03-12T15:04:37Z")

</div>

Where did you find that one i haven't been able to find it on spreadsheet i went trough

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [March 12, 2026, 3:56pm UTC](https://forum.arduino.cc/t/ds1307-not-working/1434904/20 "2026-03-12T15:56:09Z")

</div>

Hee:

> **[◁ Модуль годин реального часу DS1307 RTC для ARDUINO (123626) купити в Україні...](https://gsm-komplekt.ua/ua/product/48328/?srsltid=AfmBOoqsb5IDE1p8TG9-uLVFQBIP2D55RS9zSOv3paYoMpooC7mLHcgm)**
>
> ☛ ❰❰Модуль годин реального часу DS1307 RTC для ARDUINO (123626)❱❱, ціна: 44 грн. купити в інтернет магазині 【Gsm-Komplekt】. ✅Акції і знижки ✍Відгуки ⭐️Характеристики. ✈ Швидка доставка по всій Україні ☎ (061) 220-12-12

[Next page](https://forum.arduino.cc/t/ds1307-not-working/1434904.md?page=2)
