Reading DS1307 RTC after sleeping


i want interrupt sleep, log once per second, timestamp onto , sleep again.
after going sleep mode "lowpower.powerdown" , waking again i2c communication dead.
i tryed few things working nothing helps far, if there no sleepmode @ keeps working.
google give this didnt work me or didnt implement correctly.

how i2c , running again? preferably possible, below 50ms , perfect below 1ms.
for sd-card (spi) had use different library , had no more problems when switching off , on via mosfet once every 10 sec.

this example out of library im using, there no sleep. if make sleep , interrupt via 1hz output of rtc identical situation.
code: [select]
#include <wire.h>
#include <time.h>
#include <timelib.h>
#include <ds1307rtc.h>

void setup() {
  serial.begin(9600);
  while (!serial) ; // wait serial
  delay(200);
  serial.println("ds1307rtc read test");
  serial.println("-------------------");
}

void loop() {
  tmelements_t tm;

  if (rtc.read(tm)) {
    serial.print("ok, time = ");
    print2digits(tm.hour);
    serial.write(':');
    print2digits(tm.minute);
    serial.write(':');
    print2digits(tm.second);
    serial.print(", date (d/m/y) = ");
    serial.print(tm.day);
    serial.write('/');
    serial.print(tm.month);
    serial.write('/');
    serial.print(tmyeartocalendar(tm.year));
    serial.println();
    string datestring = "";                             // make string assembling data log
    datestring = string(tmyeartocalendar(tm.year)) + "." + string(tm.month) + "." + string(tm.day) + " " + string(tm.hour) + ":" + string(tm.minute) + ":" + string(tm.second);
    serial.println(datestring);
  } else {
    if (rtc.chippresent()) {
      serial.println("the ds1307 stopped.  please run settime");
      serial.println("example initialize time , begin running.");
      serial.println();
    } else {
      serial.println("ds1307 read error!  please check circuitry.");
      serial.println();
    }
    delay(9000);
  }
  delay(1000);
}

void print2digits(int number) {
  if (number >= 0 && number < 10) {
    serial.write('0');
  }
  serial.print(number);
}

this not code you're using sleep. post code because error in wakeup code.

also post wiring diagram.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Reading DS1307 RTC after sleeping


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor