How to read time from non I2C DS1302 RTC module

Hi.
I want to use time and data from rtc module based on ds1302 chip like in picture below:

RTC-DS1302-MODUL-ZEGAR-CZASU-RZECZYWISTEGO-ARDUINO

I know there is Xod library for rtc module but its for i2c comunication. But module that i have is called 3 wire comunication. It has 5 pins: VCC, GND, CLK, DAT, and RST.

I checked this module using Arduino IDE and use sketch from this link:
https://playground.arduino.cc/Main/DS1302/

It work and show data in serial monitor.

Any idea how to use it with Xod.

Hi, can cesars/ds1302

1 Like

I load your library and try it on two different boards, Nano and Uno, but still cant get any data from RTC module. However it works with sketch from link via Arduino IDE, so the module itself is fine.

I connect everything like in this picture, and go o debug mode:

When left button is pressed and released, to set data and hour, it change its status from false to true,and back to false, just like supposed to. When right button is pressed to read data, it change its status from false to true, but when its released its looks like its freeze all debug mode, and its stay true, even the button is released. Rtc-ds node show “00-00-00”, rtc-wds show “watch”, and rtc-ds show “00:00:00”.

Anyone else have this module, and can check it with Xod?

You could be having conflict with timers used for serial communication for rtc and debug… Just grasping at straws…

1 Like

Yes. Its looks like it’s because debug is on.

So, I finally make my RTC module work in Xod. I get date, weekday and time from it, and display on LCD:

I use tobias/plc library to format data from module. But there is problem with year and weekday. Year, instead “2020” is “55”, and weekday instead “SUN” ( sunday, which is seventh day of week) is “SAT”.

Hi. What I will say now is more a question than an answer. I don’t have a sensor, and I don’t have the ds1302 and tobias / plc libraries, but why can’t I set a date (without a sensor) in some patch, and after every second add one to this patch? The Patch itself will have functions to convert seconds to minutes, minutes to hours, hours to days, etc (ships everywhere, the cesars/ds1302 library works like that).
The question is: Why do i need a sensor, if using programming it is possible to calculate the time anyway? As I understand it, the only thing, that the sensor can do is work without an arduino board connected to the power supply (using battery), right?

1 Like

My guess would be that day of week is using 1 for Monday, but rtc-wds is an nth-input which starts at zero, so you need to add an extra pin in front of Monday.

1 Like

Danya, RTC is used to remember time when Arduino is power cycled and it also keeps more accurate time than counting seconds in software.

1 Like

If rts-wds is like nth-input, then the number 7 will go beyond nth-input, then it will still show Sunday, not Saturday.


So the error is not here. I have a guess that this is due to the year. The day of the week depends on the year.

and as it turned out, the rtc-wds is not a nth-input.


Isn’t Sunday the 1st day of the week rather than Monday?

1 Like

Looks like first day of the week is different around the world. I’m from Poland, and here, in every calendar I’ve seen, Monday is first . But for example in Google Calendar app you can choose which day is first.
Now i have proper weekday on display, but still year is “55” instead “2020”.

Sounds like RTC may need 1965 added to the year. There could be something else wrong that this would only be a kludge to cover up the problem, though… 1965 is an odd year to be the “epoch”…

1 Like

Thanks a lot. This trick work. Now I have correct 2020 year.

Hi, It is one of my first libraries, which I modified later but there were errors.

Eliminate the internal debug, you should be able to simulate now, the error of the year is because I put 2020 and according to the datasheet the year record of the RTC is from 00 to 99.
hence the error and the need to add 1965.

Updated @0.0.7, try …

Ok. Thanks cesars.

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