How To Set Time In Rtc Ds3231 Arduino
(Final Updated On: February 5, 2022)
Description:
Arduino RTC DS3231 Time and Appointment display on a 16×2 LCD- In this tutorial, y'all will learn how to make a real-fourth dimension clock using Arduino, RTC DS3231 module and a 16×2 LCD. This is my showtime tutorial on the RTC DS3231 real-time clock and in this tutorial, I will explain the farthermost nuts.
While in my upcoming tutorial I will use the same DS3231 module in the Battery efficiency monitoring system.
In this project, the battery voltage is stored in the Arduino along with the date and time data. The information which is stored in the Arduino tin can be requested through Bluetooth using the prison cell phone awarding. The data which is received from the Arduino is stored in the database for the mail service-analysis.
In this tutorial, nosotros volition cover.
- RTC DS3231module Pinout
- Consummate circuit diagram explanation
- Programming and finally number
- Testing
Let's get started!!!!
For the Footstep past Footstep Explanation watch Video Tutorial given at the stop of this article.
The components and tools used in this project can be purchased from Amazon, the components Buy links are given below:
12v Adaptor:
Arduino Uno
Arduino Nano
Mega 2560:
RTC DS3231 Real Fourth dimension Clock:
16X2 LCD
Other Tools and Components:
Top Arduino Sensors:
Super Starter kit for Beginners
Digital Oscilloscopes
Variable Supply
Digital Multimeter
Soldering fe kits
PCB small portable drill machines
DISCLAIMER:
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
RTC DS3231 Existent Time Clock:
This is the RTC DS3231 module. The RTC stands for Real-Fourth dimension Clock. You might be thinking why we need the RTC DS3231 module when the Arduino itself has the built-in timekeeper. Arduino is really powerful and nosotros can make a real-time clock, but the problem comes in when the Arduino is turned off, or the power is asunder, the fourth dimension and engagement data is completely lost.
Merely if y'all look at the RTC DS3231 module it has a battery and can go on track of the Time and Date data even if the primary power supply is disconnected or we reprogram the microcontroller.
RTC DS3231 Features:
The RTC DS3231is a depression-price, highly authentic Real Time Clock, which tin maintain hours, minutes, and seconds. This module can also maintain the day, month, and year information. The RTC DS3231 module also has automatic compensation for leap years and for months with fewer than 31 days.
This Module tin can exist powered up using 3.3 volts or 5 volts.
Every bit you can see clearly in the picture above, the DS3231 module has a total of 6 male headers and are conspicuously labeled. Out of these vi Pins, we volition exist using only 4 Pins which are the SCL, SDA, VCC, and GND.
16X2 LCD:
This is the 16×2 LCD, as you lot can see I have already soldered some jumper wires. I accept a very detailed getting started tutorial on the sixteen×2 LCD, which covers the farthermost basics similar for examples, Soldering, interfacing, and bones programming.
Arduino RTC DS3231 Circuit Diagram:
This is the complete circuit diagram explaining how a 16×2 LCD and RTC DS3231 module is connected with the Arduino. This schematic is designed in Cadsoft eagle 9.1.0 version. If y'all want to learn how to brand a schematic and PCB, then watch the following tutorial.
Equally y'all can run into the ground of the Arduino is continued with pin number 1, 5 and pivot number 16 of the LCD…5v from the Arduino is connected with pin number 2 and pin number 15…the center pin of the variable resistor or potentiometer is continued with pin number 3 of the LCD…while the other two pins are continued with the basis and 5v. Pivot's iv to 7 of the Arduino are connected with pins D7 to D4 of the LCD.
Pin number 8 of the Arduino is connected with the Enable pin of the LCD.
Pivot number ix of the Arduino is connected with the Rs pivot of the LCD, while the R/West pin of the LCD is continued with the Ground.
The Vcc pin of the RTC DS3231 module is connected with the iii.3 volts pivot of the Arduino, while the Ground of the DS3231 module is connected with the Arduino's Footing. The SDA and SCL pins of the RTC DS3231 Existent Time Clock module are connected with the Analog pins A4 and A5 of the Arduino. The RTC DS3231 module uses the SPI Protocol.
Interfacing DS3231 and sixteen×ii LCD with Arduino:
RTC DS3231 module and xvi×ii LCD Interfacing with the Arduino is as per the circuit diagram already explained.
Arduino RTC DS3231 Programming:
Before, you starting time the programming, first of all, brand sure that you download all the necessary libraries.
1 two 3 4 5 6 7 8 9 10 xi 12 13 fourteen fifteen 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 fourscore 81 82 83 84 85 86 87 88 | /* * Connections * connect SDA of the RTC with A4 * connect SCL of the RTC with A5 */ #include <LiquidCrystal.h> #include <Wire.h> #include "RTClib.h" RTC_DS3231 rtc ; char daysOfTheWeek [ 7 ] [ iv ] = { "Sun" , "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" } ; int Day ; int Month ; int Year ; int Secs ; int Minutes ; int Hours ; String dofweek ; // mean solar day of week String myDate ; Cord myTime ; // for the 16x2 LCD #ascertain rs 9 #define en 8 #ascertain d4 7 #define d5 six #define d6 5 #define d7 4 // initialize the library with the numbers of the interface pins LiquidCrystal lcd ( rs , en , d4 , d5 , d6 , d7 ) ; void setup ( ) { Serial . begin ( 9600 ) ; lcd . begin ( xvi , two ) ; delay ( 3000 ) ; // wait for panel opening if ( ! rtc . begin ( ) ) { Serial . println ( "Couldn't discover RTC" ) ; while ( 1 ) ; } if ( rtc . lostPower ( ) ) { Serial . println ( "RTC lost power, lets set the time!" ) ; // Comment out below lines once you lot ready the date & time. // Following line sets the RTC to the appointment & time this sketch was compiled rtc . conform ( DateTime ( F ( __DATE__ ) , F ( __TIME__ ) ) ) ; // Following line sets the RTC with an explicit appointment & time // for case to set January 27 2022 at 12:56 you would call: // rtc.adjust(DateTime(2017, i, 27, 12, 56, 0)); } } void loop ( ) { DateTime now = rtc . now ( ) ; lcd . clear ( ) ; Day = now . 24-hour interval ( ) ; Month = now . month ( ) ; Twelvemonth = at present . yr ( ) ; Secs = now . second ( ) ; Hours = now . hour ( ) ; Minutes = at present . minute ( ) ; dofweek = daysOfTheWeek [ now . dayOfTheWeek ( ) ] ; myDate = myDate + dofweek + " " + Mean solar day + "/" + Month + "/" + Year ; myTime = myTime + Hours + ":" + Minutes + ":" + Secs ; // send to serial monitor Series . println ( dofweek ) ; Serial . println ( myDate ) ; Serial . println ( myTime ) ; //Print on lcd lcd . setCursor ( 0 , 0 ) ; lcd . impress ( myDate ) ; lcd . setCursor ( 0 , 1 ) ; lcd . print ( myTime ) ; myDate = "" ; myTime = "" ; delay ( 1000 ) ; } |
Download Wire library: Wire
Download RTClib library:RTClib
For the Program Explanation and practical sit-in watch the following video. Don't forget to Subscribe. Back up my YouTube channel by liking and sharing this video.
Watch Video Tutorial:
Related Article:
16×2 LCD basic examples
How To Set Time In Rtc Ds3231 Arduino,
Source: https://www.electroniclinic.com/arduino-rtc-ds3231-time-and-date-display-on-a-16x2-lcd/
Posted by: mcginnisjoyinewerhat.blogspot.com
0 Response to "How To Set Time In Rtc Ds3231 Arduino"
Post a Comment