Logger shield flat battery
Moderators: adafruit_support_bill, adafruit

Logger shield flat battery

by Spiney on Wed Oct 10, 2012 11:44 am

I built the Adafruit data logger shield in July this year. It has been connected to an Arduino since with a Dallas DS18B20 and a push button to develop an interrupt program. It has been both connected and un-connected to the computer since. I have just found that the battery is flat. Measuring resistance on the shield battery mount I find infinite resistance in the forward direction and about 2k in reverse. The battery WAS put in the right way up +ve up!
I have used the example program Adafruit provided but I am puzzled that "RTC is not Running"does not show.
I attach the code and would appreciate help on this point.
Since starting to write this I have experimented further and I find that I can cause a dead short across the battery by pressing it down near the edge. I suspect that solder has run under from the 2 side-connections of the holder. Maybe that was the cause though in the normal position there is no short. Has this been reported before?

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;
#define TEMP_PIN  2 //See Note 1, sheepdogguides..ar3ne1tt.htm
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#define PIN 3  // the pin for button
volatile byte burp=0;    // a counter to see how many times the pin has changed

volatile long mon=0;
volatile int dy=0;
volatile int hr=0;
volatile int mn=0;
volatile int sec=0;
volatile int flag=0;
int nflag;
byte cmd=0;     // a place to put our serial data

void OneWireReset(int Pin);//See Note 2
void OneWireOutByte(int Pin, byte d);
byte OneWireInByte(int Pin);

void setup() {
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");}
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
    digitalWrite(TEMP_PIN, LOW);
    pinMode(TEMP_PIN, INPUT);      // sets the digital pin as input (logic 1)
    Serial.begin(9600);
    Wire.begin();
    RTC.begin();
    delay(100);
    Serial.print("temperature measurement:\n");
    Serial.print("PinChangeInt test on pin ");
    Serial.print(PIN);
    Serial.println();
    pinMode(PIN, INPUT);     //set the pin to input
    digitalWrite(PIN, HIGH); //use the internal pullup resistor
    PCintPort::attachInterrupt(PIN, burpcount,FALLING); // attach a PinChange Interrupt to our pin on the rising edge
// (RISING, FALLING and CHANGE all work with this library)
// and execute the function burpcount when that pin changes 
   
}

void loop()
Spiney
 
Posts: 165
Joined: Mon Jul 09, 2012 5:35 am

Re: Logger shield flat battery

by adafruit_support_bill on Thu Oct 11, 2012 5:26 am

I haven't seen a problem like that before. Those batteries typically last several years at least and have a very low self-discharge rate. So your short-circuit theory seems to be the most likely cause.

I have used the example program Adafruit provided but I am puzzled that "RTC is not Running"does not show.

Even after removing all power from the system?
User avatar
adafruit_support_bill
 
Posts: 29715
Joined: Sat Feb 07, 2009 9:11 am

Re: Logger shield flat battery

by Spiney on Thu Oct 11, 2012 4:09 pm

Er? Arduino and shield won't run without power, so I have not disconnected USB.
With the battery removed the message did not show. I see now that even a dead battery should be left in place ; didn't see that before.
I have replaced the battery today and the RTC is printing the correct time in response to my Interrupt program - subject of another post from me.
Spiney
 
Posts: 165
Joined: Mon Jul 09, 2012 5:35 am

Re: Logger shield flat battery

by adafruit_support_bill on Thu Oct 11, 2012 4:19 pm

Arduino and shield won't run without power, so I have not disconnected USB.

What I meant was that you have to completely power down the entire system to stop the clock. When you power it back up, it should report that the clock is not running.
User avatar
adafruit_support_bill
 
Posts: 29715
Joined: Sat Feb 07, 2009 9:11 am

Re: Logger shield flat battery

by Spiney on Sat Oct 13, 2012 3:58 am

Ok I understand now.
So I disconnected the shield/Arduino from the computer, removed the battery and shorted the battery holder connections.
I reconnected the shield/Arduino to the computer after 3 minutes, leaving the battery out. I loaded Adafruits code - 1st section included below. Still did not get the "not running" message.
Did get a monitor print of :-
2012/10/11 12:13:14
Since 1970 = 1349957594s = 15624d
now + 7d + 30 sec: 2012/10/18 12:13:41
Etc Etc.
The date is yesterday's date.
Am I being thick again?

Code: Select all | TOGGLE FULL SIZE
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

void setup () {
    Serial.begin(9600);
    Wire.begin();
    RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }

}
Spiney
 
Posts: 165
Joined: Mon Jul 09, 2012 5:35 am

Re: Logger shield flat battery

by adafruit_support_bill on Sat Oct 13, 2012 7:07 am

Wow! Sounds like you have a zombie RTC. I would have thought that 3 minutes of no power would be enough to stop it. Try removing all sources of power for 10 minutes or more.

Code: Select all | TOGGLE FULL SIZE
I reconnected the shield/Arduino to the computer after 3 minutes, leaving the battery out.

You should always run with a battery in place - even if it is a dead battery. The RTC will behave erratically with no cell in the circuit.
User avatar
adafruit_support_bill
 
Posts: 29715
Joined: Sat Feb 07, 2009 9:11 am

Re: Logger shield flat battery

by Spiney on Sat Oct 13, 2012 11:11 am

The shield/Arduino has been disconnected for 3 hours and the battery was and is left out. When reconnected it shows this morning's time and date, from when I ran the Adafruit program before removing the battery and disconnecting. It is counting up in 3 second intervals. No "not running" message
So something is storing the last date & time?
I have just re-loaded the program and the time is still at the morning's setting. With the battery out, it evidently will not fetch the time from the computer.
This lack of the warning is not of importance for me. I think we can leave this problem as being interesting but inconsequential?
Spiney
 
Posts: 165
Joined: Mon Jul 09, 2012 5:35 am

Re: Logger shield flat battery

by adafruit_support_bill on Sat Oct 13, 2012 12:24 pm

That is odd. Typically after a couple minutes with no power, the RTC will stop and RTC.isrunning() will return false.

You can bypass the RTC.isrunning() test and just call "RTC.adjust(DateTime(__DATE__, __TIME__));" unconditionally. That should set it to the time the sketch was compiled.

You will want to run this modified sketch only once. Otherwise it will keep going back to the compile time every time the board resets.
User avatar
adafruit_support_bill
 
Posts: 29715
Joined: Sat Feb 07, 2009 9:11 am

Re: Logger shield flat battery

by Spiney on Sat Oct 13, 2012 2:15 pm

Thanks. Noted. I shall do that.
Spiney
 
Posts: 165
Joined: Mon Jul 09, 2012 5:35 am