Library - Virtuabotixrtch Arduino
Serial.print(daysOfWeek[myRTC.dayofweek - 1]); // Convert 1-7 to 0-6 Serial.print(" "); Serial.print(dateString); Serial.print(" "); Serial.println(timeString);
// setDS1302Time(seconds, minutes, hours, dayofweek, dayofmonth, month, year) myRTC.setDS1302Time(00, 30, 14, 2, 26, 5, 2026); Use code with caution. 3. Reading the Time
The library is lightweight, making it ideal for projects utilizing smaller microcontrollers like the ATmega328P (Arduino Uno/Nano) where flash memory and RAM are limited. Hardware Wiring and Connections virtuabotixrtch arduino library
The virtuabotixRTC library is a C++ library designed for Arduino to facilitate communication with DS1302 RTC modules. It abstractly handles the complex data structures, pin assignments, and communication protocols required to read and set the time, date, and day of the week on these modules. Key Features
Alternatively, extract the folder into your Documents/Arduino/libraries folder. Wiring the DS1302 to Your Arduino Serial
uses a 3-wire serial interface (not I2C). A common configuration is: : 5V (or 3.3V depending on the module) GND : GND CLK (SCLK) : Pin 6 DAT (I/O) : Pin 7 RST (CE) : Pin 8 Sample Implementation Code
Serial.println("--------"); delay(1000); Wiring the DS1302 to Your Arduino uses a
// Define the RTC pins const int rtcClockPin = 2; const int rtcDataPin = 3; const int rtcRstPin = 4;
Here is an example of how to use the Virtuabotix RTC Arduino Library to set the current date and time:
delay(1000);
// Set the current date and time (seconds, minutes, hours, day of week, day of month, month, year) myRTC.setDS1302Time( // Update the time variables from the RTC chip myRTC.updateTime(); // Print the time to Serial Monitor Serial.print( "Current Date / Time: " ); Serial.print(myRTC.dayofmonth); Serial.print( ); Serial.print(myRTC.month); Serial.print( ); Serial.print(myRTC.year); Serial.print( ); Serial.print(myRTC.hours); Serial.print( ); Serial.print(myRTC.minutes); Serial.print( ); Serial.println(myRTC.seconds);