DS1307 intermittent starting

I have tried a forum search on “RTC is NOT running!” but of course this is in the setup of every sketch that members have posted, so most posts are about other issues.

I have built a safety display that tracks days since last accident, and days to next goal.

It is solar powered , and I have a DS1307 RTC so that I can update the number of days at midnight ( I know it will drift a bit, but as long as its in the middle of the night thats fine )

Should there be no sun for a couple of days and the battery goes flat, I have both target days saved in eeprom as unixdays, so it will automatically update the right number of missed days.

The guy I have built it for is collecting it this morning at 9am, but when I got up at 4am ( as one does on Sundays being self employed ) I saw that the days had not changed at midnight.

I took it all apart again and hooked up to the pc, and got the error message “RTC is NOT running!”

I am using the #include “RTClib.h” library, and tried uploading a couple of simple readtime examples, and each time it said the RTC wasnt running.

The battery is 2.8v still, but it had been powered all night from the battery anyway.

I then tried Nick Gammons 12c scan, and it showed me the address as 0x68.

As there is no address shown in the code, I assume that is in the library, but when I added

#define DS1307_I2C_ADDRESS 0x68 it sprang back into life …

I tried commenting out the line and it worked fine again, as did the simple checktime codes.

I have left the line in there now, and if it wasnt for the fact that the guy has driven 1000 km to Cape Town for the weekend and going home today, I would have bought another chip and crystal on Monday.

Has anyone had a similar experience? and will that extra line be OK?

Code attached

forum.pde (7.97 KB)

I’ve not downloaded your code as I don’t want to mess up what I’m working on at the moment. However, if it’s of any assistance, the message is derived from checking the status of the CH (clock halt) bit in one of the registers.

Bit 7 of Register 0 is the clock halt (CH) bit. When this bit is set to 1, the oscillator 
is disabled. When cleared to 0, the oscillator is enabled. On first application of power 
to the device the time and date registers are typically reset to 01/01/00 01 00:00:00 
(MM/DD/YY DOW HH:MM:SS). The CH bit in the seconds register will be set to a 1. The clock 
can be halted whenever the timekeeping functions are not required, which minimizes 
current (IBATDR).

Thanks dannable, that might be a clue, but as far as I know the power never went down ( though it can ) but the backup battery should have kept it alive ?

Anyway, its on the road now, (oddly enough heading for a wind farm in the Eastern Cape ) so I just hope there are no problems.

I don’t think the 35 amphour main battery will have problems supplying the displays 24/7, even in African winter. My sign draws about an amp in full sunlight ( there is auto dimming for overcast or night conditions, where it will drop to a few hundred milliamps or so )

The solar panel is a 40 watt unit, and charged the battery fully while being in the patio shade the last few days of testing.

see attached pic

Not very ambitious. If they get an accident every 12 days they think they're doing OK? :))