arduino real time clock ds3231 with lcd display brands

Recently I"ve been developing a new project that requires a sensor to be checked at a certain time of day. The unit will be battery powered, I didn"t want to be counting time continuously so I opted for a Real Time Clock (RTC) to trigger an interrupt pin at a specific time each day.

As with all Arduino projects there isn"t an automatic user interface and I wanted a way to set the clocks without having to set up a board and plug them into the laptop each time so I thought I"d get an LCD with a keypad and build a simple interface to set the RTCs up.

There was a learning curve:I had to learn about LCDsI had to learn about Keypads going to one analogue pinI discovered an issues with cheaper generic LCD Keypad shieldsI had to learn about manipulating bytes and, as it turned out, initiating them

The DS3231 has the ability to store:dates using two digit years,the current day of the week,time in hours, minutes & secondstime as 24 hour or 12 hour (with am and pm data)an alarm (alarm 1) that can be set from days to seconds and has five different methods of triggeringan alarm (alarm 2) that can be set from days to minutes and has three different methods of triggering

For my application I made a couple of decisions:I"m not bothered about 12 hour clocks so I was going to only use the clock in 24 hour mode.I only read dates in dd/mm/yy format so I wasn"t going to give the user an option to show dates in mm/dd/yy format. If that is your preference then the code is easy to adjust but you would have to pay attention to the sequencing during the date set up routine.

The first decision to be made was the sequencing of options for the user. The LCD has two lines of display so each step had to accommodate that. I didn"t want the LCD to scroll a new line up or down each time so I though it would be better if each screen presented had a theme.

When I first created the project I used the following sequences:Date & TimeAlarm 1Alarm 2Set DateSet TimeSet Alarm 1 On or OffSet Alarm 1 Date and/or timeSet Alarm 1 MethodSet Alarm 2 On or OffSet Alarm 2 Date and/or timeSet Alarm 2 Method

But this method took a lot of steps to get from simply displaying Alarm 1 back to Date & Time and also from displaying Alarm 2 to setting Alarm 2 so I changed the sequence:

I maintained the wiring for the LCD as if it had been plugged into an Arduino UNO so the code for initiating looks like:#include #include #include DS3231 Clock;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);void setup() {// Start the lcd and set the cursorlcd.begin(16,2);lcd.setCursor(0,0);// Start the I2C interfaceWire.begin();}

I used the same variables for each of the buttons pressed. There is a lot of information on the internet about managing button bounce, I controlled it with a 50ms debounce delay. To learn more about debounce try this vide:

I also added a variable to store the last button pressed, this avoids the issue of long button presses. Because the Arduino loop runs very often every time it entered the loop after the debounce delay the code would act as if a new button had been pressed without this code.// check the key press against the previous key press to avoid issues from long key pressesif (oldKey!=lcd_key) {// depending on which button was pushed, we perform an actionswitch (lcd_key){case btnRIGHT:

Below is the initial code for the display sequencing, the first block is taken straight from the datasheet:/ define some values used by the panel and buttonsint lcd_key = 0;int adc_key_in = 0;const int btnRIGHT = 0;const int btnUP =1;const int btnDOWN =2;const int btnLEFT =3;const int btnSELECT =4;const int btnNONE =5;int bounceDelay;int oldKey = 0;/**************************************************************** Functions to read the buttons***************************************************************/// read the buttonsint read_LCD_buttons(){adc_key_in = analogRead(0); // read the value from the sensor// my buttons when read are centered at these valies: 0, 144, 329, 504, 741// we add approx 50 to those values and check to see if we are closeif (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result// For V1.1 us this thresholdif (adc_key_in < 50) return btnRIGHT;if (adc_key_in < 250) return btnUP;if (adc_key_in < 450) return btnDOWN;if (adc_key_in < 650) return btnLEFT;if (adc_key_in < 850) return btnSELECT;return btnNONE; // when all others fail, return this...}void loop() {//Set the menu item or display text for the usersetMenu();// read the buttonslcd_key = read_LCD_buttons();// check the key press against the previous key press to avoid issues from long key pressesif (oldKey!=lcd_key) {// depending on which button was pushed, we perform an actionswitch (lcd_key){case btnRIGHT:{oldKey = btnRIGHT;if (currentMode==modeSHOWDATETIME){currentMode=modeSHOWALARM1;}else if (currentMode==modeSHOWALARM1){currentMode=modeSHOWALARM2;}else if (currentMode==modeSHOWALARM2){currentMode=modeSHOWDATETIME;}delay(50);break;}case btnLEFT:{oldKey = btnLEFT;delay(50);break;}case btnUP:{oldKey = btnUP;delay(50);break;}case btnDOWN:{oldKey = btnDOWN;delay(50);break;}case btnSELECT:{oldKey = btnSELECT;if (currentMode==modeSHOWDATETIME){currentMode=modeSETDATE;}else if (currentMode==modeSHOWALARM1){currentMode=modeSETALARM1ON;}else if (currentMode==modeSHOWALARM2){currentMode=modeSETALARM2ON;}else if (currentMode==modeSETDATE){currentMode=modeSETTIME;}else if (currentMode==modeSETTIME){currentMode=modeSHOWDATETIME;}else if (currentMode==modeSETALARM1ON && Clock.checkAlarmEnabled(1)){currentMode=modeSETALARM1;}else if (currentMode==modeSETALARM1ON && !Clock.checkAlarmEnabled(1)){currentMode=modeSHOWALARM1;}else if (currentMode==modeSETALARM1){currentMode=modeSETALARM1METHOD;}else if (currentMode==modeSETALARM1METHOD){currentMode=modeSHOWALARM1;}else if (currentMode==modeSETALARM2ON && Clock.checkAlarmEnabled(2)){currentMode=modeSETALARM2;}else if (currentMode==modeSETALARM2ON && !Clock.checkAlarmEnabled(2)){currentMode=modeSHOWALARM2;}else if (currentMode==modeSETALARM2){currentMode=modeSETALARM2METHOD;}else if (currentMode==modeSETALARM2METHOD){currentMode=modeSHOWALARM2;};break;}case btnNONE:{oldKey=btnNONE;break;}}}}

When I entered the adjustment modes I need a way to show the user which part of the display they could adjust with the up or down arrows. I resolved this in four parts:an integer that changed as the user selected each different section of the display (with the left or right buttons)an integer to hold the maximum value for the blink integer, so that if the maximum number of blink stages (items on display) couldn"t be exceededa variable to hold the blink status (either true or false)a variable to hold the time in milliseconds since the blink status last changed, once that exceeded a set value the blink status changed from true to false or false to true as required.

Code added to the loop() function:void loop() {//Set the menu item or display text for the usersetMenu();// read the buttonslcd_key = read_LCD_buttons();// check the blink counter isn"t too highif (blinkInt > maxBlinkInt){blinkInt=maxBlinkInt;}// Set the current blink statusif (currentMode>modeSHOWALARM2 && ((millis()-blinkStart)>blinkDelay)){blinkNow=!blinkNow;blinkStart=millis();}else if (currentMode<=modeSHOWALARM2){blinkNow=false;}// check the key press against the previous key press to avoid issues from long key pressesif (oldKey!=lcd_key) {

This gave the following full setup and loop functions :void setup() {// Start the serial portSerial.begin(9600);Serial.println("Starting");// Set the bounce delaybounceDelay=50;// Start the lcd and set the cursorlcd.begin(16,2);lcd.setCursor(0,0);// Start the I2C interfaceWire.begin();}void loop() {//Set the menu item or display text for the usersetMenu();// read the buttonslcd_key = read_LCD_buttons();// check the blink counter isn"t too highif (blinkInt > maxBlinkInt){blinkInt=maxBlinkInt;}// Set the current blink statusif (currentMode>modeSHOWALARM2 && ((millis()-blinkStart)>blinkDelay)){blinkNow=!blinkNow;blinkStart=millis();}else if (currentMode<=modeSHOWALARM2){blinkNow=false;}// check the key press against the previous key press to avoid issues from long key pressesif (oldKey!=lcd_key) {// depending on which button was pushed, we perform an actionswitch (lcd_key){case btnRIGHT:{oldKey = btnRIGHT;if (blinkInt1) {blinkInt-=1;}delay(50);break;}case btnUP:{oldKey = btnUP;if (currentMode==modeSETDATE){if (blinkInt==1){increaseDate();}if (blinkInt==2){increaseMonth();}if (blinkInt==3){increaseYear();}}if (currentMode==modeSETTIME){if (blinkInt==1){increaseHour();}if (blinkInt==2){increaseMinute();}}if (currentMode==modeSETALARM1ON) {if (Clock.checkAlarmEnabled(1)) {AlarmOn(1, false);}}if (currentMode==modeSETALARM1) {if (blinkInt==1){changeAlarmDayOption(1);}if (blinkInt==2){ChangeAlarm(1, 1, 0, 0,0);}if (blinkInt==3){ChangeAlarm(1, 0, 1, 0,0);}if (blinkInt==4){ChangeAlarm(1, 0, 0, 1,0);}if (blinkInt==5){ChangeAlarm(1, 0, 0, 0,1);}}if (currentMode==modeSETALARM1METHOD) {changeAlarmMethod(1, 1);}if (currentMode==modeSETALARM2ON) {if (Clock.checkAlarmEnabled(2)) {AlarmOn(2, false);}}if (currentMode==modeSETALARM2) {if (blinkInt==1){changeAlarmDayOption(2);}if (blinkInt==2){ChangeAlarm(2, 1, 0, 0,0);}if (blinkInt==3){ChangeAlarm(2, 0, 1, 0,0);}if (blinkInt==4){ChangeAlarm(2, 0, 0, 1,0);}if (blinkInt==5){ChangeAlarm(2, 0, 0, 0,1);}}if (currentMode==modeSETALARM2METHOD) {changeAlarmMethod(2, 1);}delay(50);break;}case btnDOWN:{oldKey = btnDOWN;if (currentMode==modeSETDATE){if (blinkInt==1){decreaseDate();}if (blinkInt==2){decreaseMonth();}if (blinkInt==3){decreaseYear();}}if (currentMode==modeSETTIME){if (blinkInt==1){decreaseHour();}if (blinkInt==2){decreaseMinute();}}if (currentMode==modeSETALARM1ON) {if (!Clock.checkAlarmEnabled(1)) {AlarmOn(1, true);}}if (currentMode==modeSETALARM1) {if (blinkInt==1){changeAlarmDayOption(1);}if (blinkInt==2){ChangeAlarm(1, -1, 0, 0,0);}if (blinkInt==3){ChangeAlarm(1, 0, -1, 0,0);}if (blinkInt==4){ChangeAlarm(1, 0, 0, -1,0);}if (blinkInt==5){ChangeAlarm(1, 0, 0, 0,-1);}}if (currentMode==modeSETALARM1METHOD) {changeAlarmMethod(1, 0);}if (currentMode==modeSETALARM2ON) {if (!Clock.checkAlarmEnabled(2)) {AlarmOn(2, true);}}if (currentMode==modeSETALARM2) {if (blinkInt==1){changeAlarmDayOption(2);}if (blinkInt==2){ChangeAlarm(2, -1, 0, 0,0);}if (blinkInt==3){ChangeAlarm(2, 0, -1, 0,0);}if (blinkInt==4){ChangeAlarm(2, 0, 0, -1,0);}if (blinkInt==5){ChangeAlarm(2, 0, 0, 0,-1);}}if (currentMode==modeSETALARM2METHOD) {changeAlarmMethod(2, 0);}delay(50);break;}case btnSELECT:{blinkInt=1;oldKey = btnSELECT;if (currentMode==modeSHOWDATETIME){currentMode=modeSETDATE;}else if (currentMode==modeSHOWALARM1){currentMode=modeSETALARM1ON;}else if (currentMode==modeSHOWALARM2){currentMode=modeSETALARM2ON;}else if (currentMode==modeSETDATE){currentMode=modeSETTIME;}else if (currentMode==modeSETTIME){currentMode=modeSHOWDATETIME;}else if (currentMode==modeSETALARM1ON && Clock.checkAlarmEnabled(1)){currentMode=modeSETALARM1;}else if (currentMode==modeSETALARM1ON && !Clock.checkAlarmEnabled(1)){currentMode=modeSHOWALARM1;}else if (currentMode==modeSETALARM1){currentMode=modeSETALARM1METHOD;}else if (currentMode==modeSETALARM1METHOD){currentMode=modeSHOWALARM1;}else if (currentMode==modeSETALARM2ON && Clock.checkAlarmEnabled(2)){currentMode=modeSETALARM2;}else if (currentMode==modeSETALARM2ON && !Clock.checkAlarmEnabled(2)){currentMode=modeSHOWALARM2;}else if (currentMode==modeSETALARM2){currentMode=modeSETALARM2METHOD;}else if (currentMode==modeSETALARM2METHOD){currentMode=modeSHOWALARM2;};break;}case btnNONE:{oldKey=btnNONE;break;}}}}

Reading the tips and tricks from the BaldEngineer I noticed that it was best to send a full line of text to the LCD to overwrite everything as it can sometimes leave some cells with text. For example, if I sent a line saying 108 and then updated with text saying 22 it would actually say 228 because the LCD wouldn"t overwrite the 8 at cell 3.

The solution is to create a function to write the text to the LCD:void displayText(String line0Text, String line1Text){lcd.setCursor(0,0);sprintf(line0,"%-21s", line0Text.c_str());lcd.print(String(line0));lcd.setCursor(0,1);sprintf(line1,"%-21s", line1Text.c_str());lcd.print(String(line1));}

There was also an issue with sending numbers to the LCD, they would only ever show up as the figure 10. This was resolved with another function that I copied from the internet where it is often cited and resolves the issue:String twoDigitNumber(byte number){char buffer[3];snprintf(buffer,sizeof(buffer), "%02d", number );return String(buffer);}

This is so that the DateText and TimeText can be reused when adjusting the date and time. They read the value of blinkInt and the state of the blinkNow to determine if some of the text should be hidden to give the impression of blinking.String dateText() {String result="Date: ";if (blinkInt!=1 || blinkNow==false){result+=twoDigitNumber(Clock.getDate());}else{result+=" ";}result+="/";if (blinkInt!=2 || blinkNow==false){result+=twoDigitNumber(Clock.getMonth(Century));}else{result+=" ";}result+="/";if (blinkInt!=3 || blinkNow==false){result+=twoDigitNumber(Clock.getYear());}else{result+=" ";}return result;}String timeText() {String result="Time: ";if (blinkInt!=1 || blinkNow==false){result+=twoDigitNumber(Clock.getHour(h12, PM));}else{result+=" ";}result+=":";if (blinkInt!=2 || blinkNow==false){result+=twoDigitNumber(Clock.getMinute());}else{result+=" ";}result+=":";result+=twoDigitNumber(Clock.getSecond());return result;}void showDateTime(){displayText(dateText(), timeText());}

The two separate functions called setDate and setTime simple adjust the display and set the maxBlink variable. For the time I"ve not made an allowance for setting seconds manually, when minutes are changed seconds automatically go to 0. I don"t need a clock to be that accurate, if you do you could easily alter this but you might need to account for lag in processing the command.void setDate(){displayText("Set the date:", dateText());maxBlinkInt=3;}void setTime(){displayText("Set the time:", timeText());maxBlinkInt=2;}

It is the up, down and right buttons that call the necessary functions to change the date and time. The right buttons changes the blinkInt valuecase btnRIGHT:{oldKey = btnRIGHT;if (blinkInt

The up and down buttons adjust the valuescase btnUP:{oldKey = btnUP;if (currentMode==modeSETDATE){if (blinkInt==1){increaseDate();}if (blinkInt==2){increaseMonth();}if (blinkInt==3){increaseYear();}}if (currentMode==modeSETTIME){if (blinkInt==1){increaseHour();}if (blinkInt==2){increaseMinute();}}case btnDOWN:{oldKey = btnDOWN;if (currentMode==modeSETDATE){if (blinkInt==1){decreaseDate();}if (blinkInt==2){decreaseMonth();}if (blinkInt==3){decreaseYear();}}if (currentMode==modeSETTIME){if (blinkInt==1){decreaseHour();}if (blinkInt==2){decreaseMinute();}}

The functions to increase the various date and time parts use the DS3231 library. One of the decisions I made here was to keep scrolling through potential values rather than going to a dead end. For example, for minutes, instead of stopping at 59 and having to go down again to get to 0 I simply allow the sequence to go from 59 to 0. I also factor for the maximum days in a month, not just when setting days but also when setting months or years, just in case the day is set to 31 and the user adjusts to a month that only has 30 days or less. Leap years are adjusted for as well./**************************************************************** Functions to increase and decrease time elements***************************************************************/void increaseYear(){Year=Clock.getYear();if (Year<99){Year = Year + 1;}else{Year = 00;}Clock.setYear(Year);if (Clock.getDate()>monthMaxDays(Clock.getMonth(Century))){Clock.setDate(monthMaxDays(Clock.getMonth(Century)));}}void decreaseYear(){Year=Clock.getYear();if (Year>1){Year = Year - 1;}else{Year = 99;}Clock.setYear(Year);if (Clock.getDate()>monthMaxDays(Clock.getMonth(Century))){Clock.setDate(monthMaxDays(Clock.getMonth(Century)));}}void increaseMonth(){Month=Clock.getMonth(Century);if (Month<12) {Month = Month + 1;}else{Month = 1;}Clock.setMonth(Month);if (Clock.getDate()>monthMaxDays(Clock.getMonth(Century))){Clock.setDate(monthMaxDays(Clock.getMonth(Century)));}}void decreaseMonth(){Month=Clock.getMonth(Century);if (Month>1) {Month = Month - 1;}else{Month = 12;}Clock.setMonth(Month);if (Clock.getDate()>monthMaxDays(Clock.getMonth(Century))){Clock.setDate(monthMaxDays(Clock.getMonth(Century)));}}void increaseDate(){Date=Clock.getDate();if (Date1) {Date = Date- 1;}else {Date = monthMaxDays(Clock.getMonth(Century));}Clock.setDate(Date);}void increaseHour(){Hour=Clock.getHour(h12, PM);if (Hour<24){Hour = Hour + 1;}else{Hour = 1;}Clock.setHour(Hour);}void decreaseHour(){Hour=Clock.getHour(h12, PM);if (Hour>1){Hour = Hour - 1;}else{Hour = 24;}Clock.setHour(Hour);}void increaseMinute(){Minute=Clock.getMinute();if (Minute<60){Minute = Minute + 1;}else{Minute = 1;}Clock.setMinute(Minute);Clock.setSecond(0);}void decreaseMinute(){Minute=Clock.getMinute();if (Minute>0){Minute = Minute - 1;}else{Minute = 60;}Clock.setMinute(Minute);Clock.setSecond(0);}int monthMaxDays(int monthNumber){switch (monthNumber){case 1:case 3:case 5:case 7:case 8:case 10:case 12:return 31;case 4:case 6:case 9:case 11:return 30;case 2:int remainingYears;remainingYears=((Clock.getYear()-2020)%4);if (remainingYears==0){return 29;}else{return 28;}default:return 0;}}

Setting the alarms on or off was fairly simple, there are three functions available in the DS3231 library. These are turnOnAlarm, turnOffAlarm and checkAlarmEnabled. I used the checkAlarmEnabled function to decide if the user needed to see the displays to set the rest of the alarm, if the user had turned the alarm off this all seemed redundant.case btnSELECT:{blinkInt=1;oldKey = btnSELECT;if (currentMode==modeSHOWDATETIME){currentMode=modeSETDATE;}else if (currentMode==modeSHOWALARM1){currentMode=modeSETALARM1ON;}else if (currentMode==modeSHOWALARM2){currentMode=modeSETALARM2ON;}else if (currentMode==modeSETDATE){currentMode=modeSETTIME;}else if (currentMode==modeSETTIME){currentMode=modeSHOWDATETIME;}else if (currentMode==modeSETALARM1ON && Clock.checkAlarmEnabled(1)){currentMode=modeSETALARM1;}else if (currentMode==modeSETALARM1ON && !Clock.checkAlarmEnabled(1)){currentMode=modeSHOWALARM1;}else if (currentMode==modeSETALARM1){currentMode=modeSETALARM1METHOD;}else if (currentMode==modeSETALARM1METHOD){currentMode=modeSHOWALARM1;}else if (currentMode==modeSETALARM2ON && Clock.checkAlarmEnabled(2)){currentMode=modeSETALARM2;}else if (currentMode==modeSETALARM2ON && !Clock.checkAlarmEnabled(2)){currentMode=modeSHOWALARM2;}else if (currentMode==modeSETALARM2){currentMode=modeSETALARM2METHOD;}else if (currentMode==modeSETALARM2METHOD){currentMode=modeSHOWALARM2;};break;}

The blinking was set to match the currently selected on or off option.void setAlarmOnOff(int alarmNum){if (alarmNum>0 && alarmNum<3) {maxBlinkInt=1;if(Clock.checkAlarmEnabled(alarmNum)){blinkInt=2;}else {blinkInt=1;}if (blinkInt==1 && blinkNow==true){displayText("", "Alarm" + String(alarmNum) + ": ON");}else if (blinkInt==2 && blinkNow==true){displayText("Alarm" + String(alarmNum) + ": OFF", "");}else{ displayText("Alarm" + String(alarmNum) + ": OFF", "Alarm" + String(alarmNum) + ": ON");}}}

The alarm is then set:void AlarmOn(int alarmNum, bool setOn){if (alarmNum>0 && alarmNum<3) {if (setOn){Clock.turnOnAlarm(alarmNum);}else {Clock.turnOffAlarm(alarmNum);}}}

There are now only two other options for each alarm that we can use to help with displaying and setting the alarms:getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);setA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);setA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);

I created two separate functions for changing the day/date options and for changing the time for simplicity of reading the code:void changeAlarmDayOption(int alarmNum){byte ADay, AHour, AMinute, ASecond, ABits;bool ADy, A12h, Apm;//Collect the current alarm settingsif (alarmNum==1){Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);}if (alarmNum==2){Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);}ADy=!ADy;if (ADy && ADay>7) {ADay=7;}//Reset the alarm settingsif (alarmNum==1){Clock.setA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);}if (alarmNum==2){Clock.setA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);}}void ChangeAlarm(int alarmNum, int dayAdjust, int hourAdjust, int minAdjust,int secAdjust){byte ADay, AHour, AMinute, ASecond, ABits;bool ADy, A12h, Apm;//Collect the current alarm settingsif (alarmNum==1){Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);}if (alarmNum==2){Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);}//Adjust the dateADay+=dayAdjust;if (ADy){if (ADay<1){ADay=7;}if (ADay>7){ADay=1;}}else {if (ADay<1){ADay=31;}if (ADay>31){ADay=1;}}//Adjust the hourAHour+=hourAdjust;if (AHour<0){AHour=23;}if (AHour>23){AHour=0;}//Adjust the minuteAMinute+=minAdjust;if (AMinute<0){AMinute=59;}if (AMinute>59){AMinute=0;}//Adjust the secondif (alarmNum==1){ASecond+=secAdjust;if (ASecond<0){ASecond=59;}if (ASecond>59){ASecond=0;}}//Reset the alarm settingsif (alarmNum==1){Clock.setA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);}if (alarmNum==2){Clock.setA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);}}

All of the previous steps were fairly painless, a bit of research and applying what I"d learnt. Not so with setting the alarm modes. This was a headache.

The alarm modes are held in memory in various locations and the DS3231 kindly collects this data, stores it in a byte and returns it to the user. In the previous codes this is the ABits variable.

There are a set of masks stated on the data sheet and I copied the constants fromhttps://github.com/mlepard/ArduinoChicken/blob/master/roboCoop/alarmControl.ino// These are the ALARM Bits that can be used// They need to be combined into a single value (see below)// Found here: https://github.com/mlepard/ArduinoChicken/blob/master/roboCoop/alarmControl.ino#define ALRM1_MATCH_EVERY_SEC 0b1111 // once a second#define ALRM1_MATCH_SEC 0b1110 // when seconds match#define ALRM1_MATCH_MIN_SEC 0b1100 // when minutes and seconds match#define ALRM1_MATCH_HR_MIN_SEC 0b1000 // when hours, minutes, and seconds match#define ALRM1_MATCH_DY_HR_MIN_SEC 0b0000 // when hours, minutes, and seconds match#define ALRM2_ONCE_PER_MIN 0b111 // once per minute (00 seconds of every minute)#define ALRM2_MATCH_MIN 0b110 // when minutes match#define ALRM2_MATCH_HR_MIN 0b100 // when hours and minutes match

Some places on-line suggest that you have to create a seven digit byte and set both alarms 1 and 2 at the same time. I discovered this isn"t so from reading the DS3231 library. The alarm 1 reads the first four (from the right hand) digits of a byte sent to it, alarm2 reads digits 5, 6, & 7.

I was still hitting problems though. Sometimes the scrolling of the current status would work, sometimes the status would update, sometimes it wouldn"t.

After posting online in the forum (https://forum.arduino.cc/index.php?topic=719176.0) cattledog highlighted that I could have dirty bytes that could be corrupting what I was sending to the DS3231 library. I explicitly set the bytes, made sure I didn"t recall an old byte variable, and it all worked.void setAlarmMethod(int alarmNum){if (alarmNum>0 && alarmNum<3) {if (alarmNum==1){maxBlinkInt=1;showAlarmMethod(1);}if (alarmNum==2){maxBlinkInt=1;showAlarmMethod(2);}}}void showAlarmMethod(int alarmNum) {String myString1="";String myString2="";byte ADay, AHour, AMinute, ASecond, ABitsOP=0b0;bool ADy, A12h, Apm;if (alarmNum==1){myString1 = "Alarm 1 Method:";Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABitsOP, ADy, A12h, Apm);ABitsOP = ABitsOP & 0b1111;if (ABitsOP==ALRM1_MATCH_EVERY_SEC) {myString2 = "Once per Second";}else if (ABitsOP==ALRM1_MATCH_SEC) {myString2 = "Seconds Match";}else if (ABitsOP==ALRM1_MATCH_MIN_SEC) {myString2 = "Min & Secs Match";}else if (ABitsOP==ALRM1_MATCH_HR_MIN_SEC) {myString2 = "Hr, Min & Sec Match";}else if (ABitsOP==ALRM1_MATCH_DY_HR_MIN_SEC) {myString2 = "Dy, Hr, Mn & Sec";}} else {Clock.getA2Time(ADay, AHour, AMinute, ABitsOP, ADy, A12h, Apm);myString1 = "Alarm 2 Method:";if ((ABitsOP>>4)==ALRM2_ONCE_PER_MIN) {myString2 = "Once per Minute";}else if ((ABitsOP>>4)==ALRM2_MATCH_MIN) {myString2 = "Match Minute";}else {myString2 = "Match Hour & Min";}}displayText(myString1 , myString2);}

In the changeAlarmMethod function to can see that:Abits is explicitly set to zeroFor Alarm1 Abits is then masked to return the first four digits (&0b1111).For Alarm2 Abits is pushed to the right four places to return only digits 5, 6 & 7 (>> 4).For both alarms a new variable is created to hold the new alarm mode to ensure there isn"t any contamination of data from the old variableFor Alarm2 the new variable is pushed to the left four places to correctly set digits 5, 6 & 7 (>> 4).void changeAlarmMethod(int alarmNum, int dir) {byte ADay1, AHour1, AMinute1, ASecond1, ADay2, AHour2, AMinute2, ABits=0b0;bool ADy1, A12h1, Apm1, ADy2, A12h2, Apm2;int AlarmBits;if (alarmNum==1){Clock.getA1Time(ADay1, AHour1, AMinute1, ASecond1, ABits, ADy1, A12h1, Apm1);ABits = ABits & 0b1111;if (dir == 1) {if (ABits==ALRM1_MATCH_EVERY_SEC) {AlarmBits |= ALRM1_MATCH_SEC;}else if (ABits==ALRM1_MATCH_SEC) {AlarmBits |= ALRM1_MATCH_MIN_SEC;}else if (ABits==ALRM1_MATCH_MIN_SEC) {AlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}else if (ABits==ALRM1_MATCH_DY_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_EVERY_SEC;}}else if (dir == 0) {if (ABits==ALRM1_MATCH_EVERY_SEC) {AlarmBits |= ALRM1_MATCH_DY_HR_MIN_SEC;}else if (ABits==ALRM1_MATCH_SEC) {AlarmBits |= ALRM1_MATCH_EVERY_SEC;}else if (ABits==ALRM1_MATCH_MIN_SEC) {AlarmBits |= ALRM1_MATCH_SEC;}else if (ABits==ALRM1_MATCH_HR_MIN_SEC) {AlarmBits |= ALRM1_MATCH_MIN_SEC;}else {AlarmBits |= ALRM1_MATCH_HR_MIN_SEC;}}else {AlarmBits |= ABits;}Clock.setA1Time(ADay1, AHour1, AMinute1, ASecond1, AlarmBits, ADy1, A12h1, Apm1);} else {Clock.getA2Time(ADay2, AHour2, AMinute2, ABits, ADy2, A12h2, Apm2);ABits = ABits >> 4;if (dir == 1) {if (ABits==ALRM2_ONCE_PER_MIN) {AlarmBits = ALRM2_MATCH_MIN;}else if (ABits==ALRM2_MATCH_MIN) {AlarmBits = ALRM2_MATCH_HR_MIN;}else {AlarmBits = ALRM2_ONCE_PER_MIN;}}if (dir == 0) {if (ABits==ALRM2_ONCE_PER_MIN) {AlarmBits = ALRM2_MATCH_HR_MIN;}else if (ABits==ALRM2_MATCH_HR_MIN) {AlarmBits = ALRM2_MATCH_MIN;}else {AlarmBits = ALRM2_ONCE_PER_MIN;}}AlarmBits = AlarmBits << 4;Clock.setA2Time(ADay2, AHour2, AMinute2, AlarmBits, ADy2, A12h2, Apm2);byte newBits;Clock.getA2Time(ADay2, AHour2, AMinute2, newBits, ADy2, A12h2, Apm2);}}

The constants used for the current status are shown below.// define some values used by the menu controllerconst int modeSHOWDATETIME = 0;const int modeSHOWALARM1 = 1;const int modeSHOWALARM2 = 2;const int modeSETDATE = 3;const int modeSETTIME = 4;const int modeSETALARM1ON = 5;const int modeSETALARM1 = 6;const int modeSETALARM1METHOD = 7;const int modeSETALARM2ON = 8;const int modeSETALARM2 = 9;const int modeSETALARM2METHOD = 10;int currentMode = modeSHOWDATETIME;

I"ve created a simple casing/holder for the shield and breadboard. it is 2-piece for two reasons. Firstly, the frame around the LCD would have needed supports and scondly, I"ve found that the positions of the buttons is a bit erratic and so this design allows anyone replicating the design to tweak the LCD panel. The stl files are included.

One of the tings I noticed with this code was the amount of memory it used. I"m not great at understanding how to control memory but I did a couple of things after I wrote the instructions above:I changed all #Define to const as I had read it was better for memory. It had limited effect.I changed all integer flags to bytes to reduce memory usage, this had some effect.I removed global variables where they could be local variables, again this had limited effect.

The next step with memory was to remove references to Serial from the SetUp function. This reduces the memory usage to 50% of storage and global variables occupying 30% of dynamic memory. So there is a lesson to comment out or remove all debugging statements once complete.

When I"ve used the RTC in projects I"ve found two issues:The status register of the DS3231 RTC doesn"t appear to clear correctly, locking the RTC alarm into a low state, this is resolved athttps://electronics.stackexchange.com/questions/445256/ds3231-stops-working-on-vbat

arduino real time clock ds3231 with lcd display brands

This is a part of my own project which i think this small part can be shared as a showcase. anyone who interested to create his/her own clock can consider this.

The use of DS3231 RTC make this project able to count timing even if it"s not power up. Once the date time has set, the RTC module will counting base on the updated time. So the next time you power on the Arduino and LCD module, the date and time are still able to display correctly.

The project just follow standing wiring for both LCD keypad shield and RTC module, however, due to short of VCC pin, I programmed pin 53 as a output pin and provide DC voltage for RTC module.

arduino real time clock ds3231 with lcd display brands

In this Arduino Tutorial we will learn how to use the DS3231 Real Time Clock Module. You can watch the following video or read the written tutorial below.

The first question that comes here is why we actually need a separate RTC for our Arduino Project when the Arduino itself has built-in timekeeper. Well the point is that the RTC module runs on a battery and can keep track of the time even if we reprogram the microcontroller or disconnect the main power.

The DS3231 is a low-cost, highly accurate Real Time Clock which can maintain hours, minutes and seconds, as well as, day, month and year information. Also, it has automatic compensation for leap-years and for months with fewer than 31 days.

Once we connect the module we need to program the Arduino Board to work with the Real Time Clock. However, when it comes to programing a communication between Arduino and an I2C module the code isn’t that small and easy. Luckily, there are already several libraries for the DS3231 RTC which can be found on the internet.

So once we download and install the library we can use its first demo example to initially activate the clock of the RTC module. In the setup section of the demo example code we can notice that there are three line that we need to uncomment in order to initially set the day of the week, the time and the data.

The first line is for setting the day of the week, the second line is for setting the time in hours, minutes and seconds, and the third line is for setting the date in days, months and years.

Now even if we disconnect the Arduino power and then reconnect it and run the Serial Monitor again we can notice that the time keeps going without being reset.

So now we have our Real Time Clock up and running and we can use in any Arduino Project. As a second example I connected an LCD to the Arduino and printed the time and the date on it.

arduino real time clock ds3231 with lcd display brands

In this project, I will discuss about DS3231 RTC Module, important components and features of this module and finally show you how to Interface a DS3231 Real Time Clock (RTC) Module with Arduino.

Real Time Clock or RTC is a timekeeping device in the form of an Integrated Circuit or IC. RTC is an integral component of many time critical applications and devices like Servers, GPS, Data Loggers etc.

With 8051, I have used DS1307 RTC Module in a project called RFID BASED CAR PARKING SYSTEM. Coming to Arduino, I have used the same DS1307 RTC in ARDUINO ALARM CLOCK and ARDUINO REAL TIME CLOCK TUTORIAL USING DS1307. If you want a quick reference, you can go through the provided links.

Also, in the Arduino Real Time Clock Tutorial using DS1307 project, I have talked about the need for an RTC. So, I won’t go into that aspect again. I will directly jump into the IC of interest: the DS3231 RTC IC.

The DS3231 is an RTC IC developed by Maxim Integrated. It is a low cost, extremely accurate RTC IC with communication over I2C Interface. An interesting feature of DS3231 RTC IC is that it has integrated crystal oscillator and temperature sensor and hence you don’t have to connect an external crystal.

Using DS3231 IC as the main component, several manufacturers developed DS3231 RTC Modules with all the necessary components. Almost all the modules available today consists of an additional IC, 24C32N (or something similar). This secondary IC is an EEPROM IC of 32Kb size.

Since RTC is all about maintaining time irrespective of the power supply, you can connect a 3V CR2032 Lithium Battery to the RTC IC to keep the clock ticking. In the DS3231 Module, there is a provision for you to connect a battery using the battery holder provided on the back.

As mentioned earlier, DS3231 IC and 24C32 EEPROM IC are the main components on a typical DS3231 RTC Module board. Apart from that, there are a few other components like Power ON LED, few resistors, capacitors, a battery holder and pins for connecting with microcontroller.

First, let me begin the connections between Arduino and DS3231. Since the interface between them is I2C, identify the I2C Pins on your Arduino Board (if you are using any other board than UNO).

In Arduino UNO, A4 and A5 are SDA and SCL pins. Connect these pins with corresponding SDA and SCL pins of the DS3231 Module. Also, connect the VCC and GND of the RTC Module to +5V and GND of Arduino.

I have used a special library called “RTClib” from Adafruit (which is a forked version of JeeLab’s RTC Library). Download the library from this link and place the extracted folder in the libraries directory of Arduino.

The working of the Arduino DS3231 RTC Module Interface is very easy. Arduino first initializes the RTC Module with its slave address (0x68 for DS3231 IC).

Arduino then updates the internal registers of the RTC IC with the date and time at which the code is compiled and uploaded to Arduino. The uploaded date and time can be viewed on the LCD display.

arduino real time clock ds3231 with lcd display brands

Real time clock module with the DS3231 chip. This module ensures that the Arduino knows the exact time at all times. By connecting the Arduino to the ´qw´ pin, it is possible to generate an interrupt every second with which sensor values or a display can be addressed.

This module uses the DS3231, which is the big brother of DS1307. This chip has an integrated timing crystal and temperature sensor, which provides more stability. With this module you have just that little extra precision and reliability that the predecessor is missing. The chip is fully compatible with the predecessor and therefore requires no modification in the source code.

arduino real time clock ds3231 with lcd display brands

The Arduino is an amazing device. It’s useful for prototyping and can also be used to construct a complete project. It has an analog to digital converters (ADC), digital I/O pins, it handles interrupts and it can communicate via a serial port, SPI, and I2C.

A “real time clock” is essentially a digital clock whose output can be read by a computer or microcontroller.  It has its own oscillator that it uses to count time and it has registers that allow you to set the current time and date.

The device you are using to read this article likely has a real time clock and if you are attached to the Internet you probably are synchronizing this to a network time server (if your device is a phone it may be time synchronized to your telephone companies carrier signal instead).

Unix time is the number of seconds that have elapsed since midnight January 1, 1970 (which was a Thursday if you’re interested).  If you are on Linux (or at the terminal on a Mac, which uses Unix as its underlying operating system) you can type “date +%s” to get the current Unix time.

Unix time is useful when you are writing a program that needs to calculate the time difference between two dates and times, as it involves simple addition and subtraction, without having to worry about days, months and years.

The issue with leap seconds is generally taken care of by synchronizing your real time clock with a local or network time source, which itself will have compensated for leap seconds.

The problem with 2038 is likely to be resolved within the next 19 years, I suspect just shifting to a 64-bit standard would resolve this for several millennia!

One chip is theDS3231, a highly accurate real time clock that uses an I2C interface.  This chip has its own internal crystal oscillator, so no external crystal is required.

Another very popular chip is theDS1307. Like the DS3231 it also communicates using the I2C bus, however, this chip requires an external timing crystal.

As the Tiny RTC uses the I2C bus it is very easy to hook it up to an Arduino.  The I2C bus provides power, clock and data signals, so only four connections are required.

Before you hook up your real time clock module it would be a good idea to install the coin cell battery, if you haven’t already. That way you will ensure that the device will keep time even after you power down the Arduino.

Some Arduino clones also have separateSDAandSCLpins, usually located on the same side as the digital I/O pins above theAREFpin.  You can use these connections instead of the analog pins if you wish, they are actually just duplicates.

There are several libraries available that will work with the Tiny RTC. I’m going to use two libraries that were contributed by Paul Stoffregen, a well-known figure in the Arduino community.

The Arduino Library Manager can be also used to install two updated versions of these libraries, these were updated by Michael Margolis.  You can find them as follows:

Once you have the libraries installed open your Arduino IDE and select theFilemenu item and selectExamples. A sub-menu will appear, scroll down until you get to theExamples from Custom Librariessection.

As you might have guessed from its name theSetTimesketch sets the time on the Tiny RTC module. You’ll need to run this, or something similar, before you can use the clock.

SetTime uses two functions, getTime and getDate, to retrieve the time and date respectively from your computer clock. As most Internet-connected computers synchronize to a network time protocol (NTP) server this will probably be very accurate.

Without using a data structure the time will be reported in Unix time, which I described earlier.  ThetmElements_tdata structure breaks this down into elements like seconds, minutes, hours, days, months and years.

Otherwise, the sketch is fairly straightforward. It gets the current system time from the computer running the IDE and writes it to the DS1307 chip on the Tiny RTC module. It does all of this in the Setup section so there is no code in the loop.

Al that is left is to read those time values and print them to the serial monitor. A function calledprint2digitsis used for the hours, minutes and seconds to format the display nicely, with leading zeros for numbers below 10.

The two sketches we have just looked at illustrate how to set and read the time from the Tiny RTC module, and they accomplish this very well. But the module has an additional function, the ability to output a square wave.

You can use this square wave as a timing source for another circuit. It could be used to drive a stepper motor to create an analog clock. And, as I will show you here, it can be used to generate an interrupt for your Arduino.

To use the square wave output as an interrupt for your Arduino you will need to connect the SQ output on the Tiny RTC module to one of the interrupt pins on the Arduino.

An LED is also connected to the Arduino to indicate when an interrupt is being serviced. This is actually optional as it is connected to pin 13 and the Uno also has a built-in LED connected to that pin. If you wish you can leave it out and just monitor the LED on your Uno board.

I found a great sketch that shows how to use the square wave output, it was originally published by Robert Ulbricht on theArduino Slovakia website. Fortunately, there is an English translation available.

The functionsetSQWis really where the “action” is. This function writes to the control register in the DS1307 and sets the square wave frequency to 1Hz.

ThehandleIntfunction is the interrupt handler. Every time a pulse is received on the D2 pin it will be called.  This is set up in the Setup function using theArduino attachInterrupt function.

The previous sketch illustrated how to use the SQ square wave output from the Tiny RTC module as an interrupt. And while it does a great job of displaying interrupt operation it really doesn’t have many practical uses.

After all, there are many simpler methods of blinking an LED. In fact, if you really wanted to use the Tiny RTC to blink an LED you could just attach it directly to the SQ output, eliminating the Arduino entirely (although you’d need the Arduino to set the SQ output to 1Hz first).

Take another look at theReadTestsketch from the DS1307RTC examples. You’ll notice that it reads the time and then adds two delays that total exactly one second. It then does it all over again.

If you’re just building a clock this will work well, as every second you’ll read the time and it will have advanced one second.  But what if you want to do something else in the Loop after you read and display the time?

If the ”something else” takes less than a second then you’ll be displaying the same time more than once. On a display like an LCD or OLED this is not such a bad thing as you might never notice it, but on the serial monitor it will stand out.

If the “something else” takes more than one second you’ll miss reading the clock and it wil skip one or more seconds. You can alleviate this problem somewhat by simply not displaying seconds but still, your minutes may not change at precisely the right time.

To illustrate how to take advantage of interrupts to solve the timing problem I’m going to build a temperature and humidity meter that can also tell time.  I’m going to stick to the serial monitor for my display, but you could easily modify the code to use an OLED or LCD display.

If you wish you could modify the sketch to use the DHT22 or DHT11, I used the AM2320 because I was already using I2C for the real time clock and because I had one handy!

No matter which sensor you choose for your design you’ll encounter the same dilemma – these temperature and humidity sensors require at least two seconds between readings to stabilize.  And so if you read it in the Loop you’ll get an erratic display.

The latter library is not called directly in the sketch, instead, it is used by the AM2320 Library. Without it installed your sketch will fail to compile.

TheprintCurrentTimefunction prints the time, date, temperature and humidity to the serial monitor. It takes the temperature and humidity as an input and reads the real time clock, it then writes everything to the serial monitor.

By doing this we only read the temperature and humidity sensor every 10 seconds, which gives it plenty of time to stabilize. You can reduce this number if you wish, but don’t go below two seconds.

We then check to see if the tick count is the same as it was before. If it is then we don’t do anything. If it isn’t then it means a second has elapsed, so we callprintCurrentTimeto read the time and write everything to the serial monitor.

Load the sketch and give it a test. Note that since the temperature and humidity are only updated every 10 seconds it won’t immediately respond to a change in these values. In normal situations this shouldn’t really be an issue.

Adding a real time clock to an Arduino makes it possible to build devices that are aware of the current time and date. This can allow you to create fancy timers and delay circuits, or just build a really cool and unique digital clock.

A Real Time Clock can be added to your Arduino project in order to tell the time. Today I will show you how to use the Tiny RTC, a real time clock based upon the popular DS1307 chip.

arduino real time clock ds3231 with lcd display brands

You may return most new, unopened items within 30 days of delivery for a full refund. We"ll also pay the return shipping costs if the return is a result of our error (you received an incorrect or defective item, etc.).

You should expect to receive your refund within four weeks of giving your package to the return shipper, however, in many cases you will receive a refund more quickly. This time period includes the transit time for us to receive your return from the shipper (5 to 10 business days), the time it takes us to process your return once we receive it (3 to 5 business days), and the time it takes your bank to process our refund request (5 to 10 business days).

arduino real time clock ds3231 with lcd display brands

{"id":2520838307898,"title":"Diymore DS3231 AT24C32 IIC Precision Real Time Clock Memory Module for Arduino","handle":"diymore-ds3231-at24c32-iic-precision-real-time-clock-memory-module-for-arduino","description":"\u003cdiv\u003e\u003cspan\u003e\u003cstrong\u003eDescription:\u003c\/strong\u003e\u003c\/span\u003e\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eDS3231 is a low-cost, extremely accurate I2C real-time clock (RTC), with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, disconnect the main power supply and maintains accurate timekeeping. Integrated oscillator improve long-term accuracy of the device and reduces the number of components of the production line. The DS3231 is available in commercial and industrial temperature ranges, using a 16-pin 300mil SO package.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eRTC maintains seconds, minutes, hours, day, date, month, and year information. Less than 31 days of the month, the end date will be automatically adjusted, including corrections for leap year. The clock operates in either the 24 hours or band \/ AM \/ PM indication of the 12-hour format. Provides two configurable alarm clock and a calendar can be set to a square wave output. Address and data are transferred serially through an I2C bidirectional bus.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eA precision temperature-compensated voltage reference and comparator circuit monitors the status of VCC to detect power failures, provide a reset output, and if necessary, automatically switch to the backup power supply. In addition, \/ RST pin is monitored as generating μP reset manually.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eSave time and high precision addition, DS3231 also has some other features that extend the system host of additional features and a range of options.\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eThe device integrates a very precise digital temperature sensor, through the I2C * interface to access it (as the same time).\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eThis temperature sensor accuracy is ± 3 ° C. On-chip power supply control circuit can automatically detect and manage the main and standby power (i.e., low-voltage battery) to switch between the power supply.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eIf the main power failure, the device can continue to provide accurate timing and temperature, performance is not affected.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eWhen the main power re-power or voltage value returns to within the allowable range, the on-chip reset function can be used to restart the system microprocessor.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eModule parameters:\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e1 Size: 38mm (length) * 22mm (W) * 14mm (height)\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e2 Weight: 8g\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e3 Operating voltage :3.3 - 5 .5 V\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e4 clock chip: high-precision clock chip DS3231\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e5 Clock Accuracy :0-40 ℃ range, the accuracy 2ppm, the error was about 1 minute\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e6 calendar alarm clock with two\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e7 programmable square-wave output\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e8 Real time clock generator seconds, minutes, hours, day, date, month and year timing and provide valid until the year 2100 leap year compensation\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e9 chip temperature sensor comes with an accuracy of ± 3 ℃\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e10 memory chips: AT24C32 (storage capacity 32K)\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e11.IIC bus interface, the maximum transmission speed of 400KHz (working voltage of 5V)\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e12 can be cascaded with other IIC device, 24C32 addresses can be shorted A0\/A1\/A2 modify default address is 0x57\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e13 with rechargeable battery LIR2032, to ensure the system after power failure, the clock move any natural normal\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e14 Packing: single anti-static packaging\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eWiring instructions (with Arduino uno r3 for example):\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eSCL → A5\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eSDA → A4\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eVCC → 5V\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eGND → GND\u003cbr\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e\u003cstrong\u003eNote\u003c\/strong\u003e: \u003cstrong\u003edon"t inclue battery,it only need 0.01 dollars,it"s not safty to ship by air mail.hope you can understanding\u003c\/strong\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e\u003cstrong\u003e(2) an electronic file data (including test procedures Arduino, PDF format schematics, data sheet)\u003cbr\u003e\u003c\/strong\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e\u003cstrong\u003ePackage Included:\u003c\/strong\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e1PC*DS3231 module\u003c\/span\u003e\n\u003c\/div\u003e","published_at":"2019-09-24T09:51:32+08:00","created_at":"2019-09-24T09:56:40+08:00","vendor":"diymore","type":"Clock Module","tags":["Arduino","UNO R3"],"price":2699,"price_min":2699,"price_max":2699,"available":true,"price_varies":false,"compare_at_price":null,"compare_at_price_min":0,"compare_at_price_max":0,"compare_at_price_varies":false,"variants":[{"id":23739202338874,"title":"Default Title","option1":"Default Title","option2":null,"option3":null,"sku":"X13720","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Diymore DS3231 AT24C32 IIC Precision Real Time Clock Memory Module for Arduino","public_title":null,"options":["Default Title"],"price":2699,"weight":0,"compare_at_price":null,"inventory_management":null,"barcode":"","requires_selling_plan":false,"selling_plan_allocations":[]}],"images":["\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_8_847.jpg?v=1588664386","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_1_642.jpg?v=1588664386","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_5_714.jpg?v=1588664386","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_10_782.jpg?v=1588664386","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_9_838.jpg?v=1588664386","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_12_381.jpg?v=1588664386"],"featured_image":"\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_8_847.jpg?v=1588664386","options":["Title"],"media":[{"alt":"Diymore Ds3231 At24C32 Iic Precision Real Time Clock Memory Module For Arduino","id":6679434526791,"position":1,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_8_847.jpg?v=1588664386"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_8_847.jpg?v=1588664386","width":1000},{"alt":"Diymore Ds3231 At24C32 Iic Precision Real Time Clock Memory Module For Arduino","id":6679435444295,"position":2,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_1_642.jpg?v=1588664386"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_1_642.jpg?v=1588664386","width":1000},{"alt":"Diymore Ds3231 At24C32 Iic Precision Real Time Clock Memory Module For Arduino","id":6679435903047,"position":3,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_5_714.jpg?v=1588664386"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_5_714.jpg?v=1588664386","width":1000},{"alt":"Diymore Ds3231 At24C32 Iic Precision Real Time Clock Memory Module For Arduino","id":6679436001351,"position":4,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_10_782.jpg?v=1588664386"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_10_782.jpg?v=1588664386","width":1000},{"alt":"Diymore Ds3231 At24C32 Iic Precision Real Time Clock Memory Module For Arduino","id":6679436656711,"position":5,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_9_838.jpg?v=1588664386"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_9_838.jpg?v=1588664386","width":1000},{"alt":"Diymore Ds3231 At24C32 Iic Precision Real Time Clock Memory Module For Arduino","id":6679437180999,"position":6,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_12_381.jpg?v=1588664386"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/X13720_12_381.jpg?v=1588664386","width":1000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":"\u003cdiv\u003e\u003cspan\u003e\u003cstrong\u003eDescription:\u003c\/strong\u003e\u003c\/span\u003e\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eDS3231 is a low-cost, extremely accurate I2C real-time clock (RTC), with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, disconnect the main power supply and maintains accurate timekeeping. Integrated oscillator improve long-term accuracy of the device and reduces the number of components of the production line. The DS3231 is available in commercial and industrial temperature ranges, using a 16-pin 300mil SO package.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eRTC maintains seconds, minutes, hours, day, date, month, and year information. Less than 31 days of the month, the end date will be automatically adjusted, including corrections for leap year. The clock operates in either the 24 hours or band \/ AM \/ PM indication of the 12-hour format. Provides two configurable alarm clock and a calendar can be set to a square wave output. Address and data are transferred serially through an I2C bidirectional bus.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eA precision temperature-compensated voltage reference and comparator circuit monitors the status of VCC to detect power failures, provide a reset output, and if necessary, automatically switch to the backup power supply. In addition, \/ RST pin is monitored as generating μP reset manually.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eSave time and high precision addition, DS3231 also has some other features that extend the system host of additional features and a range of options.\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eThe device integrates a very precise digital temperature sensor, through the I2C * interface to access it (as the same time).\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eThis temperature sensor accuracy is ± 3 ° C. On-chip power supply control circuit can automatically detect and manage the main and standby power (i.e., low-voltage battery) to switch between the power supply.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eIf the main power failure, the device can continue to provide accurate timing and temperature, performance is not affected.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eWhen the main power re-power or voltage value returns to within the allowable range, the on-chip reset function can be used to restart the system microprocessor.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv\u003e\n\u003cbr\u003e\u003cspan\u003eModule parameters:\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e1 Size: 38mm (length) * 22mm (W) * 14mm (height)\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e2 Weight: 8g\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e3 Operating voltage :3.3 - 5 .5 V\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e4 clock chip: high-precision clock chip DS3231\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e5 Clock Accuracy :0-40 ℃ range, the accuracy 2ppm, the error was about 1 minute\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e6 calendar alarm clock with two\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e7 programmable square-wave output\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e8 Real time clock generator seconds, minutes, hours, day, date, month and year timing and provide valid until the year 2100 leap year compensation\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e9 chip temperature sensor comes with an accuracy of ± 3 ℃\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e10 memory chips: AT24C32 (storage capacity 32K)\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e11.IIC bus interface, the maximum transmission speed of 400KHz (working voltage of 5V)\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e12 can be cascaded with other IIC device, 24C32 addresses can be shorted A0\/A1\/A2 modify default address is 0x57\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e13 with rechargeable battery LIR2032, to ensure the system after power failure, the clock move any natural normal\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e14 Packing: single anti-static packaging\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eWiring instructions (with Arduino uno r3 for example):\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eSCL → A5\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eSDA → A4\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eVCC → 5V\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003eGND → GND\u003cbr\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e\u003cstrong\u003eNote\u003c\/strong\u003e: \u003cstrong\u003edon"t inclue battery,it only need 0.01 dollars,it"s not safty to ship by air mail.hope you can understanding\u003c\/strong\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e\u003cstrong\u003e(2) an electronic file data (including test procedures Arduino, PDF format schematics, data sheet)\u003cbr\u003e\u003c\/strong\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e\u003cstrong\u003ePackage Included:\u003c\/strong\u003e\u003c\/span\u003e\u003cbr\u003e\u003cspan\u003e1PC*DS3231 module\u003c\/span\u003e\n\u003c\/div\u003e"}

arduino real time clock ds3231 with lcd display brands

About: Maker 101; Beginner and intermediate level Maker projects! You can find projects such as "How to" and "DIY" on programmable boards such as Arduino, ESP8266, ESP32 and Raspberry Pi on this channel. The projects…

arduino real time clock ds3231 with lcd display brands

A Real Time Clock module gives the ability for an Arduino to keep track of the current time, and be able to track time even when the device loses power. Many libraries for Clock Modules are surprisingly difficult to implement, but the one from Rinky-Dink is very easy.

Make sure to recomment out time setting code, and reupload code once clock has been set. If you do not the Arduino will reset the clock to the time you configured every time it loses power.

arduino real time clock ds3231 with lcd display brands

rtc module clock arduino rtc arduino clock clock real time arduino clock rtc ds1307 arduino clock rtc 3231 clock raspberry rtc ds3231 ds3231 rtc real time clock rtc raspberry nano shield real time clock arduino clock rtc rtc module rtc module rtc module rtc arduino adduino arduous raspberry afruit ino ds3231 raspberry clock arduino time arduino rtc module rtc module ds3231 module ds3231 module ds1307 time arduino rtc ds1307 arduino adafruit arduino i2c arduino real time modul horlog arduino horlog camera ds 3231 rtc modul ds. 3231 arduino arduino real time clock raspberry rtc arduino ds1307 azdelivery rtc clock rtc arduino arduino rtc ds3231 arduino time azdelivery real time clock ds 1307 clock ds3231 i2c clock real time clock module real time raspberry rtc ds 1307 rtc i2c module clock arduino ds1 307 module rtc ds1307 pi rtc rtc 1307 ds3231 at24c32 clock rtc raspberry module time arduino arduino rtc clock ds3231 and battery horlog arduino azdelivery arduino rtc module arduino ds1307 arduino arduino ardui