Giter Site home page Giter Site logo

arduino-ds3231's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-ds3231's Issues

Function similar to timeStatus

Hi,

I want to know if there is function in this library to know that time is set or not.

According to datasheet it seems
Status Register (0Fh)Bit 7: Oscillator Stop Flag (OSF).
Indicates if time has been set or not.

Scenario is checking time after power up.

Thanks

no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

#include <Wire.h>
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
void setup() {
Serial.begin(9600);
Wire.begin(4,5);
rtc.begin();
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
Serial.println(rtc.getTimeStr());
Serial.println(" ");
}

void loop() {
String dataString = String(rtc.getDateStr())+" "+String(rtc.getTimeStr())+"\t";
}

This is a piece of my code and the error that I get is the following: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'
Thanks in advance.

Interrupt Alarm Always Fires?

Hi There,

This is a terrific library (thank you!) and yy apologies if this is not in the correct location but I can't for the life of me figure out what my issue is. I'm using your DS3231_intalarm example to detect an alarm is fired. I'm using an ESP8266 since i want to add Wifi to my project once I get this sorted out. My ultimate goal is to put the ESP8266 into light sleep and wake it up from a daily alarm triggered by the DS3231. So far, I've been able to use this library to read the time and set alarms.

Here's my issue: I'm able to set the alarm but it seems to fire every second. I've tried adding a pullup resistor (10k down to 220O) to VCC as I've read elsewhere the output pin of the DS3231 needs to be tied to VCC. However, when I do that, the alarm never fires. I've experimented with different size resistors but the result is either one of these two outcomes: 1) the alarm seems to fire every second or 2) it never fires.

Here is the output to my Monitor when it fires every second:

20-08-2017 23:17:03 - Unknown
20-08-2017 23:17:06 - Unknown
the 20 second alarm just went off!
20-08-2017 23:17:09 - Unknown
the 20 second alarm just went off!
20-08-2017 23:17:12 - Unknown
the 20 second alarm just went off!
20-08-2017 23:17:15 - Unknown
the 20 second alarm just went off!
20-08-2017 23:17:18 - Unknown
the 20 second alarm just went off!

And here is my code:

`#include <Wire.h>
#include <DS3231.h>

DS3231 clock;
RTCDateTime dt;
volatile boolean alarmFlag = false;

void alarmISR()
{
alarmFlag = true;
}

void setup()
{
Serial.begin(115200);

// Initialize DS3231
Serial.println("Initialize DS3231");
clock.begin();
clock.armAlarm1(false);
clock.armAlarm2(false);
clock.clearAlarm1();
clock.clearAlarm2();

//set a 20 second alarm
clock.setAlarm1(0, 0, 0, 20, DS3231_MATCH_S);

// SQW pin on DS3231 to attached to pin 14 on ESP8266.
pinMode(14, INPUT_);
attachInterrupt(14, alarmISR, FALLING);
}

void loop()
{
dt = clock.getDateTime();
Serial.println(clock.dateFormat("d-m-Y H:i:s - l", dt));

if (isAlarm == true) {
Serial.println("the 20 second alarm just went off!");
isAlarm = false;
clock.clearAlarm1();
}
delay(3000);
}
`

Any help or advice would be greatly appreciated!

Day of the Year is incorrect

Hi, I testing your library but Day of the Year is incorrect. I try print this dates with DotY:

2016-01-01, 0
2016-01-31, 30
2016-02-01, 32 (should be 31)
2016-02-27, 58 (57)
2016-02-28, 59 (58)
2016-02-29, 60 (59)
2016-03-01, 59 (60)
2016-03-02, 60 (61)
2016-03-03, 61 (62)

Same will be every leap-year.
Please, can you fix it?

Century bit in hardware is not handled

The DS3231 uses a century bit in bit 7 of the month register(x05).
If this bit is set, as could happen if the clock was set by another library, the bcd2dec() in getDateTime will get the month wrong. example, May which is 05 will be read as 85.
As this lib always assumes years > 2k it never sets the century bit, this is only an issue if the clock chip has been set elsewhere and the century bit was used.

A possible solution is to change getDateTime() to something like the following. (other changes to handle the century bit will also be needed)

RTCDateTime DS3231::getDateTime(void)
{
int values[7];
int century = 0;
int n;

Wire.beginTransmission(DS3231_ADDRESS);
#if ARDUINO >= 100
    Wire.write(DS3231_REG_TIME);
#else
    Wire.send(DS3231_REG_TIME);
#endif
Wire.endTransmission();

Wire.requestFrom(DS3231_ADDRESS, 7);

while(!Wire.available()) {};

for (int i = 6; i >= 0; i--)
{

    #if ARDUINO >= 100
        n = Wire.read();
    #else
        n = Wire.receive();
    #endif

    if (i == 1) {
        values[1] = bcd2dec(n & 0x1F);
        century = (n & 0x80) >> 7;
    } else
        values[i] = bcd2dec(n);            
}

Wire.endTransmission();

if (century == 1) {
    t.year = values[0] + 2000;
} else {
    t.year = values[0] + 1900;
}

t.month = values[1];
t.day = values[2];
t.dayOfWeek = values[3];
t.hour = values[4];
t.minute = values[5];
t.second = values[6];
t.unixtime = unixtime();

return t;

}

Alarm 2 for hour

i'm not able to set alarm 2 for [hour:min]

eg 10(hr).30(min) alarm
alarm is only can set for min

when i'm setting for hour , the is asking date (on which day ) you have to generate

Incorect work whis unixtime

Using TimeLib.h and DS3231.h.
Arduino code:

dt = DS3231clock.getDateTime();
s += "<br>Local Time: " + printDigits(day()) + "-" + printDigits(month()) + "-" + String(year()) + " " + printDigits(hour()) + ":" + printDigits(minute()) + ":" + printDigits(second());
s += "<br>Local Unix Time: " + String(now());
s += "<br>DS3231 Time: " + String(DS3231clock.dateFormat("d-m-Y H:i:s", dt));
s += "<br>DS3231 Unix Time: " + String(DS3231clock.dateFormat("U", dt));

result:
Local Time: 16-06-2016 13:37:53
Local Unix Time: 1466084273
DS3231 Time: 16-06-2016 13:37:53
DS3231 Unix Time: 1465994273

Why the difference in 90000 seconds?
Also, do not put the correct unixtime in setDateTime function

Weird problem when using the library for DS3231 to display time on SSD1306 OLED

I connected both DS3231 and SSD1306 to I2C bus vie A4 andA5 on Arduino nano. I am able to initialize both in the code. I can display stuff on the display and I canread time into e.g. serial monitor.
This library has a cool funcion clock.dateFormat that make formiating time and date really easy.
But here is the problem.

When I try to call this function OLED display does not initialise with the message
SSD1306 allocation failed

There was some issues reported in this forum with clock.dateFormat. There was a fix posted which I applied.
But the issue is still there
Any anyone help?

No need to send Wire.write(DS3231_REG_TIME) after setting a time again.

In the void DS3231::setDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) there are two points where the 0x00 address is being sent - on the beginning of the transmission (which is correct) and at the end of it (which is useless).

Lines 79 - 83 should be removed from DS3231.cpp.

Arduino DUE

Does this library work on Arduino DUE? I decided to use this board for my project but if I enter this board in IDE it will write after verification of the code :
....
exit status 1
'DS3231 clock' redeclared as different kind of symbol

Everything worked normally with the MEGA board.
Is there any repair option?

Arduino crashes if the RTC is not detected / connected.

Hi there, I like this RTC-DS3231 library! But there is a problem if the RTC is not detected / not connected to Arduino making the arduino stops working (doing other tasks).
Would be awesome to have this minor issue fixed !
Thanks!

Alarm 2 settings needs to be corrected, no seconds

This is out of the "alarm" example and will not work, see below for the working example. It took me way too long to figure that one out: There can not be any seconds with Alarm2.

  // Set Alarm - Every full minute.
  // DS3231_EVERY_MINUTE is available only on Alarm2.
  // setAlarm2(Date or Day, Hour, Minute, Second, Mode, Armed = true)
   clock.setAlarm2(0, 0, 0, 0, DS3231_EVERY_MINUTE);
  // Set Alarm - Every full minute.
  // DS3231_EVERY_MINUTE is available only on Alarm2.
  // setAlarm2(Date or Day, Hour, Minute, Mode, Armed = true)
   clock.setAlarm2(0, 0, 0, DS3231_EVERY_MINUTE);

How to get unixtime into a variable ?

I notice that when the time is not set during setup, the time begins at 2000-1-1 0:0:0
Setting the time to the DATE TIME by default would be silly... we expect the super-accurate clock
to tell us the right time on power up...
I notice there is the call
// clock.setDateTime(Unixtime); to set time using Unixtime,
but there appears to be no call for
Unixtime = get_DateTime(dt);
the closest thing is
Serial.println(clock.dateFormat("U", dt));
to print Unixtime
but not to set the value to a variable

Problem with using function setAlarm1

Hi, I´m trying to set an alarm so it is triggered at a specific day of the week e.g. every monday, using function "setAlarm1". However, when I open the serial console, day appears as "unknown".

// Set Alarm - 10h:45m:30s in every Friday (1 - Mon, 7 - Sun)
//setAlarm1(Date or Day, Hour, Minute, Second, Mode, Armed = true)
clock.setAlarm1(7, 15, 40, 15, DS3231_MATCH_DY_H_M_S);

Please tell me how this could be solved.

clock.dateFormat() doesn't output anything in Arduino 1.8.7

After upgrading the Arduino IDE to 1.8.7 I only get blank output from clock.dateFormat(), even in the example sketch. Raw-output is still working (sketch DS3231_simple).

Once downgraded to 1.8.5 it's now working again.

1.8.7 complained about something in DS3231.cpp:
DS3231.cpp:1064:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

Arduino Zero Compatible?

Hi, I have been trying to launch these examples on Arduino Zero and there were errors during the compiling. When I have changed board on e.g. Arduino Uno then there weren't errors.
How to fix it?

setBattery(bool, bool) blocking

Hello,

i want to use a DS3231 module without a battery. I tried to set the module to work without a battery with setBattery(false, false), but it bocks. It blocks with every variant. It doesnt better what i set as the bool values.

Is is a hardware or software issue with this library?

Best regards

setDateTime with epoc unixtime unexpected behavior

First of all I want to congratulate this library really well done, but I found for a small problem that I had to correct to make my sketch work properly.

If you "setDateTime()" with an Epoc Unix Timestamp the time you set in the watch is one hour earlier than I wanted.
I think the problem is due to the fact that 946681200 (master/DS3231.cpp line 90) corresponds to "GMT: Friday, December 31, 1999 11:00 pm PM" and not to the 0 of 1 January.

It would also be interesting to implement the timezone since unix epoc is always UTC.

Thanks, Erik

The Day Suffix function appends "nd" for the 12th day

Not my code, but this code could fix this issue.

char *DS3231::strDaySufix(uint8_t day)
{
switch (day)
{
case 1:
case 21:
case 31:
return "st";
case 2:
case 22:
return "nd";
case 3:
case 23:
return "rd";
default:
return "th";
}
}

Adding time

Hello I have a project in which I need to add 1 year in one if statement then 1 in the month in the next statement and so on. I was wondering how you would accomplish this? I

clock.setDateTime(2014, 4, 13, 19, 21, 00);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.