zanduino / ds3231m Goto Github PK
View Code? Open in Web Editor NEWAccess the DS3231M I2C Realtime Clock
License: GNU General Public License v3.0
Access the DS3231M I2C Realtime Clock
License: GNU General Public License v3.0
Hi
I got a problem, I can't find how to stop a defined alarm.
i work on a project where i need to set an alarm for a period for example every minutes between 01h00 and 03h00
I set an alarm like this:
DS3231M.setAlarm(everyMinute,DateTime(2023,6,9,01,00,0));
but after i can't stop it it fire every minutes. i tried to stop it with the parameter "alarmState":
DS3231M.setAlarm(everyMinute,DateTime(2023,6,9,01,00,0),false);
but it do nothing the alarm still fire every minutes. I can't find how to clear it (to stop the alarm fire)
the clearAlarm() only clear the fire flag for the next fire.
on the RCTlib from adafruit there is an API wo call disableAlarm() who seem to do the job, but i can't find such api on your library.
i use your library because it seem to be lighter than adafruit one.
regards
In the example of adjust function documentation there is the following line
MCP7940.adjust(DateTime(2017,8,5,18,19,20));; // Set the RTC to "2017-08-05 18:19:20"
Is it really MCP7940 variable that should be used?
Hello, I realize that I have in my possession a DS3231, and it has some features that the DS3231M does not have.
One of them is the ability of the DS3231 to produce a frequency of 1hz, 1khz, 4khz or 8khz. while the DS3231M only produces 1hz.
here is a small explanation, although I am guided by the data sheets.
I am fairly new to github, I "fork" your library and made some add-ons (some lines of code) to support this feature. and it has worked fine on arduino uno, nano and some boards that I assemble as data logger.
since this library appears in arduino ide, I wonder: would it be wise to include these changes and expand the support for DS3231?
Is your feature request related to a problem? Please describe.
Unless I missed it (and I apologise if I did), there is no way to tell whether the clock is set.
Refer page15 of datasheet:
OSF: Oscillator stop flag. A logic 1 in this bit indicates that the oscillator either is stopped or was stopped for
some period and could be used to judge the validity of the timekeeping data. This bit is set to logic 1 any time
that the oscillator stops. This bit remains at logic 1 until written to logic 0. The following are examples of
conditions that can cause the OSF bit to be set:
Describe the solution you'd like
Perhaps add a method to check the OSF flag of the STATUS register.
Suggested code (edit as you see fit).
bool DS3231M_Class::getOSF()
{
if(readByte(DS3231M_STATUS) & (1 << 7)) // check bit 7 of STATUS register.
{
return true ;
} else {
return false ;
}
}
Describe alternatives you've considered
Additional context
Add any other context or screenshots about the feature request here.
void DS3231M_Class::pinAlarm() { writeByte(DS3231M_CONTROL,readByte(DS3231M_CONTROL)&~0x4); // Set bit 3 to on } // of method pinAlarm()
this logical operator (&~) should be an or |
void DS3231M_Class::pinSquareWave() { writeByte(DS3231M_CONTROL,readByte(DS3231M_CONTROL)|0x4); } // of method pinSquareWave()
this logical operator (|) should be an and &~
Hello,
I m not a C guru but it seem that to find a leap year you divide the year by 4. you must also consider dividing by 100 and 400.
There is an explanation here:
https://learn.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year
or here but it mid french mid english
https://fr.wikihow.com/calculer-les-ann%C3%A9es-bissextiles
regard
Detail what the expected program behavior should be, or what is expected to happen.
Detail what actually happens.
Explain what needs to be done in order to reproduce the problem.
dayOfTheWeek() is not in the range { 1 to 7 } as declared.
dayOfTheWeek() is in the range { 0 to 6 }
It will not be a problem if the range is declared as { 0 to 6 } in the Library.
Hi I'm using code from the example adjusting the time:
Serial.print(F("\nStarting Set program\n"));
Serial.print(F("- Compiled with c++ version "));
Serial.print(F(VERSION));
Serial.print(F("\n- On "));
Serial.print(F(DATE));
Serial.print(F(" at "));
Serial.print(F(TIME));
Serial.print(F("\n"));
DS3231M.adjust();
now = DS3231M.now();
Serial.print(F("Time: "));
Serial.print(now.hour());
Serial.print(F(":"));
Serial.print(now.minute());
Serial.print(F(":"));
Serial.println(now.second());
But it does not seem as if it is working, because I get something like:
08:48:48.584 -> - Compiled with c++ version 7.3.0
08:48:48.584 -> - On Mar 18 2021 at 08:47:52
08:48:48.584 -> Time: 1:16:3
The compiled with time is correct, but the actual time is way off. Almost seem random!?
There's some bug when hour count's more than 20.After reading the reference of DS3231M,Knowing that HOUR isn't typical BCD,I suggest do so:
the low-5-bits are just like BCD;
read()&B01000000: 0 is 24h system,1 is12h-sys;
in 24h-sys,B00100000 means 20+,and attention that B00110000 is not allowed;
in 12h-sys,read()&B00100000:0 is AM,1 PM.
for example:
23:B00100011 or B01110001,not B00110011;
13:B00010011 or B01100001;
11:B00010001 or B01010001;
1:B00000001 or B01000001.
On the slow Arduino Uno, the SETDATE function always fails as you've shared the input buffer with the sprintf displaying the date/time. On fast CPU's this might work, but not on an Uno. Have to remember to set the serial terminal to send newlines otherwise input wrapping occurs.
Adding:
char outputBuffer[SPRINTF_BUFFER_SIZE]; // right below the inputBuffer definition
Changing inputBuffer to outputBuffer:
sprintf(outputBuffer,"%04d-%02d-%02d %02d:%02d:%02d", now.year(), // Use sprintf() to pretty print //
now.month(), now.day(), now.hour(), now.minute(), now.second()); // date/time with leading zeros //
Serial.println(outputBuffer);
Fixes the problem. The latest example on the Arduino library has this error.
Otherwise this is a nice library. I'd send a pull request but the changes are soo minimal.
Thanks, Shannon
Standardize the formatting of all source elements to adhere to clang-format rules
Clean up the Directory structure
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.