Author Topic: Raspberry Pi with DS1302 RTC not working properly  (Read 7860 times)

0 Members and 1 Guest are viewing this topic.

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Raspberry Pi with DS1302 RTC not working properly
« 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 :)

Some people need a high five in the face... with a chair.
~EC

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Raspberry Pi with DS1302 RTC not working properly
« Reply #1 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.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: Raspberry Pi with DS1302 RTC not working properly
« Reply #2 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.

Some people need a high five in the face... with a chair.
~EC

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Raspberry Pi with DS1302 RTC not working properly
« Reply #3 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?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: Raspberry Pi with DS1302 RTC not working properly
« Reply #4 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.

Some people need a high five in the face... with a chair.
~EC

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: Raspberry Pi with DS1302 RTC not working properly
« Reply #5 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)

Some people need a high five in the face... with a chair.
~EC

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Raspberry Pi with DS1302 RTC not working properly
« Reply #6 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 ;)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!