Problem with DS3232RTC library


hello guys!
i'm trying use ds3232 make external interrupt periodically wake arduino @ power saving mode!
the circuit wired can set , read code below.
so think circuit correctly.
code: [select]
#include "wire.h"
#define ds3231_i2c_address 0x68
// convert normal decimal numbers binary coded decimal
byte dectobcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// convert binary coded decimal normal decimal numbers
byte bcdtodec(byte val)
{
  return( (val/16*10) + (val%16) );
}
void setup()
{
  wire.begin();
  serial.begin(9600);
  // set initial time here:
  // ds3231 seconds, minutes, hours, day, date, month, year
  //setds3231time(30,4,17,1,8,1,17);
}
void setds3231time(byte second, byte minute, byte hour, byte dayofweek, byte
dayofmonth, byte month, byte year)
{
  // sets time , date data ds3231
  wire.begintransmission(ds3231_i2c_address);
  wire.write(0); // set next input start @ seconds register
  wire.write(dectobcd(second)); // set seconds
  wire.write(dectobcd(minute)); // set minutes
  wire.write(dectobcd(hour)); // set hours
  wire.write(dectobcd(dayofweek)); // set day of week (1=sunday, 7=saturday)
  wire.write(dectobcd(dayofmonth)); // set date (1 31)
  wire.write(dectobcd(month)); // set month
  wire.write(dectobcd(year)); // set year (0 99)
  wire.endtransmission();
}
void readds3231time(byte *second,
byte *minute,
byte *hour,
byte *dayofweek,
byte *dayofmonth,
byte *month,
byte *year)
{
  wire.begintransmission(ds3231_i2c_address);
  wire.write(0); // set ds3231 register pointer 00h
  wire.endtransmission();
  wire.requestfrom(ds3231_i2c_address, 7);
  // request 7 bytes of data ds3231 starting register 00h
  *second = bcdtodec(wire.read() & 0x7f);
  *minute = bcdtodec(wire.read());
  *hour = bcdtodec(wire.read() & 0x3f);
  *dayofweek = bcdtodec(wire.read());
  *dayofmonth = bcdtodec(wire.read());
  *month = bcdtodec(wire.read());
  *year = bcdtodec(wire.read());
}
void displaytime()
{
  byte second, minute, hour, dayofweek, dayofmonth, month, year;
  // retrieve data ds3231
  readds3231time(&second, &minute, &hour, &dayofweek, &dayofmonth, &month,
  &year);
  // send serial monitor
  serial.print(hour, dec);
  // convert byte variable decimal number when displayed
  serial.print(":");
  if (minute<10)
  {
    serial.print("0");
  }
  serial.print(minute, dec);
  serial.print(":");
  if (second<10)
  {
    serial.print("0");
  }
  serial.print(second, dec);
  serial.print(" ");
  serial.print(dayofmonth, dec);
  serial.print("/");
  serial.print(month, dec);
  serial.print("/");
  serial.print(year, dec);
  serial.print(" day of week: ");
  switch(dayofweek){
  case 1:
    serial.println("sunday");
    break;
  case 2:
    serial.println("monday");
    break;
  case 3:
    serial.println("tuesday");
    break;
  case 4:
    serial.println("wednesday");
    break;
  case 5:
    serial.println("thursday");
    break;
  case 6:
    serial.println("friday");
    break;
  case 7:
    serial.println("saturday");
    break;
  }
}
void loop()
{
  displaytime(); // display real-time clock data on serial monitor,
  delay(1000); // every second
}


but compile error when trying use ds3232 library , error message said can't find streaming.h.
after import streaming library, error message more , more.
here's error messages :
code: [select]
arduino:1.6.12 (windows 7), 板子:"arduino/genuino uno"

in file included c:\users\user\documents\arduino\libraries\ds3232rtc-master\examples\setserial\setserial.ino:35:0:

c:\users\user\documents\arduino\libraries\ds3232rtc-master/ds3232rtc.h:136:26: error: 'tmelements_t' has not been declared

         static byte read(tmelements_t &tm);

                          ^

c:\users\user\documents\arduino\libraries\ds3232rtc-master/ds3232rtc.h:137:20: error: 'tmelements_t' has not been declared

         byte write(tmelements_t &tm);

                    ^

c:\users\user\documents\arduino\libraries\ds3232rtc-master\examples\setserial\setserial.ino: in function 'void setup()':

setserial:46: error: 'setsyncprovider' not declared in scope

     setsyncprovider(rtc.get);

                            ^

setserial:48: error: 'timestatus' not declared in scope

     if (timestatus() != timeset) serial << f(" fail!");

                    ^

setserial:48: error: 'timeset' not declared in scope

     if (timestatus() != timeset) serial << f(" fail!");

                         ^

c:\users\user\documents\arduino\libraries\ds3232rtc-master\examples\setserial\setserial.ino: in function 'void loop()':

setserial:56: error: 'tmelements_t' not declared in scope

     tmelements_t tm;

     ^

setserial:68: error: expected unqualified-id before '.' token

                 tm.year = calendaryrtotm(y);

                   ^

setserial:70: error: expected unqualified-id before '.' token

                 tm.year = y2kyeartotm(y);

                   ^

setserial:71: error: expected unqualified-id before '.' token

             tm.month = serial.parseint();

               ^

setserial:72: error: expected unqualified-id before '.' token

             tm.day = serial.parseint();

               ^

setserial:73: error: expected unqualified-id before '.' token

             tm.hour = serial.parseint();

               ^

setserial:74: error: expected unqualified-id before '.' token

             tm.minute = serial.parseint();

               ^

setserial:75: error: expected unqualified-id before '.' token

             tm.second = serial.parseint();

               ^

setserial:76: error: expected primary-expression before ')' token

             t = maketime(tm);

                            ^

setserial:76: error: 'maketime' not declared in scope

setserial:78: error: 'settime' not declared in scope

             settime(t);       

                      ^

setserial:87: error: 'now' not declared in scope

     t = now();

             ^

setserial:91: error: 'second' not declared in scope

         if (second(t) == 0) {

                     ^

c:\users\user\documents\arduino\libraries\ds3232rtc-master\examples\setserial\setserial.ino: in function 'void printtime(time_t)':

setserial:111: error: 'hour' not declared in scope

     printi00(hour(t), ':');

                    ^

setserial:112: error: 'minute' not declared in scope

     printi00(minute(t), ':');

                      ^

setserial:113: error: 'second' not declared in scope

     printi00(second(t), ' ');

                      ^

c:\users\user\documents\arduino\libraries\ds3232rtc-master\examples\setserial\setserial.ino: in function 'void printdate(time_t)':

setserial:119: error: 'day' not declared in scope

     printi00(day(t), 0);

                   ^

setserial:120: error: 'month' not declared in scope

     serial << monthshortstr(month(t)) << _dec(year(t));

                                    ^

setserial:120: error: 'monthshortstr' not declared in scope

     serial << monthshortstr(month(t)) << _dec(year(t));

                                     ^

in file included c:\users\user\documents\arduino\libraries\ds3232rtc-master\examples\setserial\setserial.ino:36:0:

setserial:120: error: 'year' not declared in scope

     serial << monthshortstr(month(t)) << _dec(year(t));

                                                     ^

c:\users\user\documents\arduino\libraries\streaming/streaming.h:64:28: note: in definition of macro '_dec'

 #define _dec(a)     _based(a, dec)

                            ^

exit status 1
'setsyncprovider' not declared in scope

this report have more information with
"show verbose output during compilation"
option enabled in file -> preferences.

how can start library?

here's explanation of problem , code changes need make:
https://github.com/jchristensen/ds3232rtc/pull/30
i don't understand why author of library won't merge pull request.


Arduino Forum > Using Arduino > Microcontrollers > Problem with DS3232RTC library


arduino

Comments

Popular posts from this blog

Help needed for choosing soldering station

Error Message when accessing Adobe

Fuelino for Arduino Nano - motorcycle Fuel Injection control and data logger