arduino real time clock ds3231 with lcd display pricelist

Time is a critical element of our existence that will never get old, and with technology, we can find better and more intuitive ways to measure it. In one of our past tutorials, we looked at how the DS3231 real time clock module can be used with Arduino to display time on a 16×2 LCD display. Today, we will build an upgrade to that project using an Arduino Due, the DS3231 RTC module and a 3.2″colour TFT display in place of the 16×2 LCD display used in the previous project.

At the heart of today’s project is the DS3231 real time clock module which we will use to obtain the current time, date and temperature of the environment. The DS3231 real time clock module is one of the most popular real-time clock chips among makers and DIY enthusiasts. It is a low-cost, highly accurate, I2Cbased real-time clock (RTC) with a temperature-compensated crystal oscillator (TCXO) and crystal integrated into it.  The module integrates a coin cell battery input which helps it retain date and time even when the main power to the device is interrupted. It maintains seconds, minutes, hours, day, date, month, and year information, automatically adjusting the date for months with fewer than 31 days, including corrections for leap year. It can be set to operate either in the 24-hour or 12-hour format with an active-low AM/PM indicator. It has been used in several projects on this website mostly, due to its accuracy, and its low power requirements which help it keep time accurately, for a longer period of time compared to other real-time clocks (RTC) modules.

Another key part/component that we will use in today’s tutorial is the Arduino Due. One of the important things, when designing electronic systems that have displays is ensuring, that there is no flicker or lag when updating information on the screen and one of the best ways to ensure that, is to use a fast enough micro-controller. Putting this into consideration, for this project, we will use the very fast Arduino Due board. The Arduino Due has one of the fastest CPU in the Arduino family. The Due runs on an 84MHz CPU compared to the 16MHz CPU speed of the Arduino UNO, and as such, it is able to update the screen without any visible flickering.

The most important update to the previous project, however, is the 3.2″color LCD display being used. The display gives us the ability to create a better, bigger and colourful user interface for our clock at a cheap price as it costs about 7$ on banggood.

The goal for this project is to build a real-time clock with a user-friendly interface capable of displaying (without lag or flickering) the current time, date, temperature including the minimum and maximum temperature recorded in a particular environment over time.

The 3.2″ TFT, like most other TFT displays, comes as a shield which can be easily mounted on the Arduino Due. This, however, makes it difficult to access the IOs of the Arduino after the display has been mounted, as it tends to cover the front face of the board. To solve this, so that the DS3231 module can be connected, male headers are used (after bending them as shown in the picture below) to connect the RTC module to the Arduino.

To easily write the code for this project, we will use two libraries: the Bodmer TFT HX8537  library for the TFT display and the Sodaq DS3231 library to easily interface with the DS3231 module. Both libraries can be downloaded via the links attached to their names above. The Bodmer library is a version of the UTFT library specially modified for the Arduino Due as this particular display is incompatible with the UTFT library.

With the libraries installed, relaunch the IDE to begin writing the code. The code for this project is quite simple but bulky, due to the functions used to create the user interface.

Next is the void setup function. We initiate communication with the RTC module and Initialize the display, setting our preferred orientation for the display and print the UI to the display.

With this done, we move to the void loop function. Under this function, we write the code to update all the parameters (after specific intervals) on the display including the min temperature, the max temperature, time and the date.

That’s it for this tutorial guys, there are several useful projects that can be built using this tutorial as a foundation. You could decide to add a buzzer to the project to create an alarm clock or make a to-do list based project, all out of this.

arduino real time clock ds3231 with lcd display pricelist

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 pricelist

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 pricelist

To control the system with the time and date, Real Time Clock (RTC) module (DS3231) is best to use. The time and date can store and it works for a long time as it contains the cell.

In this tutorial, I’m going to show you how to interface the real-time module (DS3231) with Arduino Uno and display real-time & date on the serial monitor. In this work, Arduino code, wiring diagram and component list presents for experimentation.

DS3231 (RTC) is a low-cost, highly accurate Real Time Clock with having built-in temperature sensor. It can maintain hours, minutes and seconds, as well as, day, month and year information. RTC modules use in computers, mobiles, embedded system devices, etc. to provide time and date. RTC module works on the I2C protocol. The module provides details such as second, minute, hour, day of the week, day of the month, month, and year including correction for leap year. It can operate in 12 and 24-hour time formats. It uses in projects like data-logging, time stamping, clocks and alarms.

RTC DS3231 module contains a backup battery which provides supply when the main supply is cut off. DS3231 RTC maintains its clock by counting the cycles of an oscillator, usually an external crystal oscillator circuit, an internal capacitor-based oscillator, or a quartz crystal. DS3231 module needs an Arduino-compatible microcontroller. It works on the I2C communication protocol. The Arduino gets the time & date information and other time-relevant flags from the RTC module by using the I2C protocol,

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:

DS3231 contains 6 pins, which are VCC, GND, SCL, SDA, SQW and 32K. At this time we will use only VCC, GND, SCL and SDA (I2C pins). Every microcontroller has dedicated pins of I2C. For Arduino Uno are A4 (SDA) and A5 (SCL).

Connect your PC to Arduino and open Arduino IDE. For the very first steps, you can refer to Connecting Windows PC with Arduino tutorial. You can get the .ino code and libraries from my download area with the following link:

This is the section before setup which uses for globe variables defining and libraries additions. RTClib.h is the library for real-time clocks. Here we have defined the instance (etc) of the class (RTC_DS3231) and array for the days of the week.

This is the setup section in which Serial.begin(9600) initialise. rtc. begin() use to check whether the DS3231 module attaches or not. when we use the DS3231 for the first time, it doesn’t know the current time and date. So we use this line (rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));) it will automatically get the date and time from your pc or we can manually set it by uncommenting the below line.

In the loop section DateTime now = rtc.now() use get the current date and time from the DS3231 module. now.year() is use for current year, now.month() is use for current month, now.day() is use for current date, daysOfTheWeek[now.dayOfTheWeek() is use for the current day (Monday to Sunday), now.hour() is use for current hour, now.minute() is use for current minutes and now.second() is use for the current seconds.

From your Arduino IDE, compile the code. Upload the code and open the serial monitor, On the serial monitor day and time display. On the serial monitor, time displays based on a two-second delay intentionally so that there should be rest time for the whole system. Otherwise second last line delay (2000) can change to delay(1000) for each second delay. Time, day and date prints on the serial monitor at baud rate 9600.

arduino real time clock ds3231 with lcd display pricelist

Itprecision clock modulelocated onDS3231 RTCIt allows you to take accurate time reading with its integrated. Thanks to this integrated internal oscillator and temperature measurement in this module, it deviates only 1 minute per year. It is possible to correct the date and time with this module, which uses I2C serial protocol. Thanks to the clock battery slot on it, the module can work for a long time even when it is not powered from outside.

arduino real time clock ds3231 with lcd display pricelist

The DS3231 RTC module Precise Real-Time Clock Module is a low-cost, extremely accurate I²C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input and maintains accurate timekeeping when main power to the device is interrupted.

The integration of the crystal resonator enhances the long-term accuracy of the device as well as reduces the piece-part count in a manufacturing line. The ds3231 Arduino is available in commercial and industrial temperature ranges and is offered in a 16-pin, 300-mil SO package.

arduino real time clock ds3231 with lcd display pricelist

In setup function we add a section which checks if display properly initialised. It halts sketch execution if display is not detected.if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64

Then we draw three rectanglers/panels. First in white and since this particular display is dual color one where first 15 lines are yellow it shows in yellow. Then we draw another one in black and then another one in white which will show in blue as that part of the display is blue. (as shown on the photo)display.fillRect(0,0,128,16,SSD1306_WHITE);

We continue with displaying Short name of the month day of the month and a full year in middle panel using DayMonthYear functiondisplay.setCursor(1,18);

In main panel we display hours and minutes using CurrentTime function and then with the smaller font we are also displaying seconds.display.setCursor(3,35);

arduino real time clock ds3231 with lcd display pricelist

The DS3231 High-Precision Real Time Clock Module is a low-cost, extremely accurate I2C real-time clock (RTC). It has an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input and maintains accurate timekeeping when the main power to the device is interrupted. Integrated crystal resonator improves the long-term accuracy of the device and reduces the number of components in the production line.

The RTC maintains seconds, minutes, hours, day, date, month, and year data. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock works in either the 24-hour or 12-hour format with an AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Addresses and data are transferred serially through an I2C bidirectional bus.

arduino real time clock ds3231 with lcd display pricelist

In this tutorial, we will discuss the purpose of getting the current date and time on the Arduino, what is a Real-Time Clock, what is a DS3231 RTC module and we will build a project using a DS3231 RTC module, a 16×2 I2C LCD and an Arduino Uno.

Keeping track of the current date/time for an Arduino has many purposes. One use for it is for recording/log purposes. For example, an Arduino Weather Station needs timestamps in recording weather data. Another example is for an Arduino digital clock or calendar. Arduino-based clocks use the current time as a timer for reminders or to execute a scheduled command via the Arduino’s I/O pins. Depending on the project, having a way to get the current date and time is very useful.

Real-Time Clock (RTC) – A Real-Time Clock, or RTC for short, is an integrated circuit that keeps track of time. It uses a back-up battery to maintain the time in the event that the main power source is removed.

Global Positioning Device (GPS) – A GPS device communicates with satellites to determine its location anywhere in the world. Its GPS data also contains time data.

Time Server– A Time Server is a computer on a network that reads the time from some reference clock and distributes it to the network. The clock source of a time server can be another time server, an atomic clock, or a radio clock.

If you want to learn how to communicate with an internet time server to get the current time and date, please read How to Keep Track of the Date and Time on an Arduino.

The DS3231 RTC module is a real-time clock module using the DS3231 IC. The DS3231 IC is a very affordable and extremely accurate RTC with an I2C interface. It is very accurate because it uses an integrated temperature-compensated crystal oscillator (TCXO) along with a crystal. To keep track of time even if the main power source is removed, the DS3231 has a backup battery mounted at the back of the module. The chip automatically switches between main and backup power sources when necessary.

The RTC keeps track of seconds, minutes, hours, day, date, month, and year data. It also automatically adjusts for months with less than 31 days and also for leap years. The clock can operate in either 24H or 12H (with AM/PM) formats. There are also two programmable time-of-day alarms and also a programmable square-wave output. Communication with the RTC is done through an I2C interface with a fixed default address of 0x68.

Aside from the RTC chip, this particular module also has a 24C32 EEPROM chip. An EEPROM is a kind of data storage device wherein you can read/write data. The 24C32 has 32 bytes of available data storage space. It shares the module’s I2C bus with the DS3231 and has the default address of 0x57. We can change the EEPROM’s default address by bridging the solder pads indicated by A0, A1, and A2 as shown in Figure 2.

SQW – outputs a square-wave signal from the DS3231 chip. The frequency of the square-wave can be changed between 1Hz, 4kHz, 8kHz, or 32kHz programmatically. this pin can also be used programmed as an interrupt output.

After learning about timekeeping and the DS3231 RTC, it is now time to build a project using the DS3231 RTC. For this project, we will make a simple Arduino Calendar Clock using a DS3231 module, a 16×2 I2C LCD, and an Arduino Uno board.

If you want to learn more about the Arduino, check out our Ultimate Guide to the Arduino video course. You’ll learn basic to advanced Arduino programming and circuit building techniques that will prepare you to build any project.

To start our sketch, add the abovementioned libraries to our code by using the keyword #include. We will also initialize two objects lcd() and rtc to be used for communicating with the LCD and DS3231 respectively.

The first function we will code is the function updateRTC(). This function will be responsible for asking the user for the date and time and updating the RTC’s internal clock with the user’s input data. After getting the user input, we can update the RTC’s internal clock by using the function rtc.adjust() from the RTCLib.h library. The rtc.adjust() function receives a parameter with type DataTime which it uses to update the rtc’s internal time and date.

The second custom function we will create is the function updateLCD(). This function will update or refresh the text displayed on the LCD. Inside this function, we will first get the time and date from the RTC. This is done by calling rtc.now() function which is included in the RTCLib.h library.

The function rtc.now() in our code returns a DateTime data type that contains the current date and time of the rtc. We then assign the data to different variables for additional formatting on the LCD. After assigning the variables, we use the functions lcd.setCursor() and lcd.print() from the LiquidCrystal_I2C.hto position the cursor and to display the text respectively on the LCD. The code below shows how these functions come together to get the rtc time, format the text and display it to the LCD.

Inside setup(), we will initialize the serial interface, the lcd and the rtc objects. To initialize the serial with a baud rate of 9600 bps, we will use the code Serial.begin(9600);. For the LCD, we need to initialize the LCD object and switch-on the backlight of the display. This is achieved by the codes lcd.init(); and lcd.backlight();. And finally, we add the code rtc.begin(); to initialize the rtc object.

For the loop() function, we will update the text displayed on the LCD by calling updateLCD();. We will also add the capability to accept user input to update the RTC’s internal clock. If the user sends the char ‘u’ via the serial monitor, it means the user wants to modify the set time and date of the rtc. If this is the case, then we call the function updateRTC(); to handle user input and update the RTC internal clock.

To change the date/time, open your Serial Monitor, and send the letter ‘u’. And then just follow the on-screen prompts to enter the new date and time.

In summary, an RTC module is an easy and inexpensive way to add timekeeping capability to an Arduino based project. This tutorial just showed the basic capability of the DS3231 RTC module. And with more tinkering, you can find lots of uses for this module. Feel free to leave a comment below if you have any questions.

arduino real time clock ds3231 with lcd display pricelist

In today"s world, time is everything, and when it comes to specific electronics, timing is critical; just like us, humans, they also need a way to keep track of time. So how do electronics do it? The answer is DS3231, a Real-Time Clock, often known as an RTC, is a timekeeping device built into an Integrated Circuit, or IC. It is used in many time-critical applications and devices, such as servers, GPS, and data loggers. Let"s see what makes it TICK.

The DS3231 is an I2C real-time clock (RTC) with an inbuilt temperature compensated crystal oscillator (TCXO) and crystal that is both low-cost and exceptionally precise. When the module"s power is interrupted, the device has a battery input and keeps a precise time. The device"s long-term precision is improved by the inclusion of the crystal oscillator. The RTC keeps track of seconds, minutes, hours, days, dates, months, and years. For months with less than 31 days, the date at the end of the month is automatically modified, including leap year corrections. The clock has an AM/PM indication and works in either a 24-hour or 12-hour mode. Two programmable time-of-day alarms are included, as well as a programmable square-wave output. An I2C bidirectional bus is used to transport address and data serially.

The key components of a typical DS3231 RTC Module board are the DS3231 IC and the AT24C32 EEPROM IC to store the time and date data. Other components include a Power ON LED, a few resistors, capacitors, a battery holder, and pins for connecting to the microcontroller.

When the main power to the module is stopped, the DS3231 contains a battery input and maintains accurate time. The built-in power-sense circuit constantly checks the condition of VCC to identify power outages and switches to the backup supply automatically. So, even if the power goes out, your MCU will still be able to maintain track of time. On the DS3231 RTC Module, there is a CR2032 battery holder. A battery holder for a 20mm 3V lithium coin cell is located on the board"s bottom side. Any CR2032 battery will work.

The most significant difference between the DS3231 and the DS1370 is the timekeeping accuracy. For timekeeping, the DS1307 has an external 32kHz crystal oscillator, while the DS3231 has an internal oscillator.

The temperature-compensated crystal oscillator (TCXO) in the DS3231 and DS3234 fits the bill, with precision as good as ±2 ppm in temperatures ranging from 0°C to +40°C.

After making the above connections, you need to connect the Arduino UNO to your PC, open Arduino IDE, and install Arduino DS3231 Time Set Library. Open the Arduino IDE and select Library Manager from the menu bar. Now look for RTCLiband DS3231 and get the most recent version, as shown in the figure below.

You may manually set the time in this line by passing the date-time value to the function in the following order: year, month, date, hour, minute, and second. We"ll set the time of the system in the code below. As a result, we have commented out this line.

We include the below header files to the code, Wire.h to use I2C to communicate with the module, LiquidCrystal.h to show time on the LCD display, RTClib.h to set time to the display and format it.

If in case the RTC loses power and the time in the module goes wrong, the code will automatically set the time in the module and it will take the time from the computer"s clock. So make sure while setting time, the clock on your PC is set at the right time.

arduino real time clock ds3231 with lcd display pricelist

// This will result in the clock being put back 6 seconds at 3:00:01 every morning. Adjust formula accordingly..............THIS DIDNT WORK ......came up with compile error on time.hour

Another approach perhaps try this........RTC.adjust( RTC.now() + 60 ) ;1 minute forward perhaps.....not yet done ...still pissing around with the idea

//rtc.adjust(DateTime(2022, 10, 9, 6, 28, 0));// to set the time manually............ year (Thai plus 543...month....day.....hour(24) ...minute...second)

// ******* NOTE that I had to set year to less 31 as above to give year display of 2565 ....no idea why at this stage....possibly because of " RTC_DS1307 rtc; " ....???????

// ******** SET back to 2022...seems there may be a limit (2100) to the clock and self adjust for leap years may not work properly using extra 543 years.