Omnimaga

General Discussion => Technology and Development => Computer Usage and Setup Help => Topic started by: ElementCoder on July 04, 2015, 08:22:18 am

Title: Raspberry Pi with DS1302 RTC not working properly
Post by: ElementCoder on July 04, 2015, 08:22:18 am
Hello guys, it's been some time :) I'm no longer doing much with calculators, but I'm still programming quite a lot. Currently I'm building a telescope with some  class mates and I'm writing the software for its control. We use a Pi B+ to manage everything but since it doesn't have its own clock I figured I'd buy an RTC module. The project is almost due though so getting the Adafruit one for the Pi would have taken too long so I bought one at a local store, a DS1302 (http://www.okaphone.com/artikel.asp?id=472987, sorry for the dutch). It's originally for the Arduino I believe, but I followed this guide to use it with my Pi: http://raspberrypi.stackexchange.com/questions/12310/would-it-be-possible-to-use-the-ds1302-made-for-arduino

It now works in the sense that I can set the time and read from it, but I've encountered a major problem: the clock doesn't seem to "tick" when unplugged from the Pi. It remembers the time it had before disconnecting though, so I don't believe the battery is dead. In the datasheet I found http://datasheets.maximintegrated.com/en/ds/DS1302.pdf I found something about a clock halt flag, but I'm not sure if that's it or how to fix it.

Is anyone familiar with this (type of) clock and could help me fix it? It would greatly ease the user experience :)
Title: Re: Raspberry Pi with DS1302 RTC not working properly
Post by: Sorunome on July 04, 2015, 08:59:09 am
The battery may still be dead if it uses flash to save the time, as that doesn't need a power source.
Title: Re: Raspberry Pi with DS1302 RTC not working properly
Post by: ElementCoder on July 04, 2015, 10:13:14 am
Taking out the battery and reinserting it resets the clock to November 30, 1990 so it most likely does use it to keep its time.
Title: Re: Raspberry Pi with DS1302 RTC not working properly
Post by: Sorunome on July 04, 2015, 10:16:41 am
Maybe you can overgo the isssue by having the pi automatically set the clock as soon as you connect it?
Title: Re: Raspberry Pi with DS1302 RTC not working properly
Post by: ElementCoder on July 04, 2015, 11:00:41 am
Well I the reason I bought this clock is that the Pi will not have internet so it will loose track of the time. We get around it now by manually setting the correct time and then continuing with what needs to be done (still a lot easier than just setting time on the pi imo :P ) so that won't be an option sadly.
Title: Re: Raspberry Pi with DS1302 RTC not working properly
Post by: ElementCoder on July 07, 2015, 12:20:52 pm
Okay it seems to work now. The problem looks like being I "shut down" the pi by just pulling the cord quite a lot. Just using the shutdown command (as I should) makes it work fine.
(sorry for double post)
Title: Re: Raspberry Pi with DS1302 RTC not working properly
Post by: Sorunome on July 08, 2015, 03:26:56 pm
Good you figured it out!
Also, double-posts if the last post is more than a day old or if there was a project update are fine ;)