![]() ![]() ![]() The other job of this function is to display alarms data (hours, minutes and status) and the temperature value. It also reads the DS3231 control register, status register and temperature registers (2 registers). Void alarms_read_display() : basically this functions reads alarm1 and alarm2 minutes and hours. This function displays the calendar by calling a function named void calendar_display(). Void DS3231_display() : displays time and calendar data, before displaying time and calendar data are converted from BCD format to decimal format. Void DS3231_read() : this function reads time and calendar data from the DS3231 (seconds, minutes, hours, day, date, month and year). Minute = ((minute / 10) << 4) + (minute % 10) // Convert decimal to BCD Minute = (minute > 4) * 10 + (minute & 0x0F) // Convert BCD to decimal The DS3231 works with BCD format only (except the temperature) and to convert the BCD to decimal and vise versa I used the following commands (example for minute variable): The Arduino code below doesn’t use any library for the DS3231.īy reading the datasheet of the DS3231 RTC the code will be more easier! Buttons B3 and B2 adjust alarm1 and alarm2 parameters (hours, minutes and ON/OFF), button B3 selects the parameter and B2 increments the selected parameter.Īlso, there is an LED connected to Arduino pin 12, this LED is used as an alarm indicator (alarm1 or alarm2), so if there is an alarm the DS3231 pulls down the INT pin which interrupts the microcontroller and the microcontroller turns the LED ON, here button B2 turns both the LED and the occurred alarm OFF. ![]() Time and calendar can be adjusted with B1 and B2, button B1 selects time or date parameter (time parameters: hours and minutes calendar parameters: day of the week, date, month and year) and B2 increments the selected parameter. These buttons are used to set time, calendar and alarms. In the circuit there are 3 push buttons: B1, B2 and B3. The DS3231 interrupts the microcontroller when there is an alarm (alarm1 or alarm2). The DS3231 board is supplied with 5V as the 2004 LCD, this 5V comes from the Arduino board, there are 3 data lined connected between this board and the Arduino, SCL line is connected to analog pin 5, SDA is connected to analog pin 4 and INT line is connected to digital pin 2 which is the external interrupt pin of the Arduino. There is also 24C32 EEPROM and some other resistors (not used in this project). Less than 31 days of the month, the end date will be automatically adjusted, including corrections for leap year.In this project I used the DS3231 board, this board basically contains the main chip which is the DS3231, two pull-up resistors (4.7K) of SCL, SDA and INT/SQW lines and coin cell battery holder. RTC maintains seconds, minutes, hours, day, date, month, and year information. Integrated oscillator improve long-term accuracy of the device and reduces the number of components of the production line.ĭS3231 available in commercial and industrial temperature ranges, using a 16-pin 300mil SO package. The device incorporates a battery input, disconnect the main power supply and maintains accurate timekeeping. Low-cost, extremely accurate I2C real-time clock (RTC), with an integrated temperature-compensated crystal oscillator (TCXO) and crystal.
0 Comments
Leave a Reply. |