Short, Easy Dialogues
15 topics: 10 to 77 dialogues per topic, with audio
HOME – www.eslyes.com
Mike michaeleslATgmail.com
February 22, 2018: "500 Short Stories for Beginner-Intermediate," Vols. 1 and 2, for only 99 cents each! Buy both e‐books (1,000 short stories, iPhone and Android) at Amazon (Volume 1) and at Amazon (Volume 2). All 1,000 stories are also right here at eslyes at Link 10.
delay(30000); // Check every 30 seconds
Use VirtuabotixRTC if you already own a DS1302 module and want simplicity. If you are buying a new RTC for a project, buy a DS3231 and use Adafruit RTCLib—it is more accurate and easier to wire (only 2 data pins vs 3). Advanced Tips and Optimization Tip 1: Reduce Delay with Time Change Detection Instead of reading the RTC every 1000ms (which uses updateTime() many times), read changes only when the second changes. virtuabotixrtc.h arduino library
Combine the RTC with a 16x2 I2C LCD for a stand-alone desk clock. delay(30000); // Check every 30 seconds Use VirtuabotixRTC
Instead of hardcoding, you can set the time based on your computer's clock at compilation using __TIME__ and __DATE__ macros, but note this requires parsing strings—a more advanced technique. Practical Projects with VirtuabotixRTC Now that you understand the basics, let's look at three practical applications. Project 1: Time-Stamped Data Logger (with SD Card) This project logs temperature (from a TMP36 sensor) to an SD card alongside the current time. Combine the RTC with a 16x2 I2C LCD
The DS1302 can store time in 12-hour format with AM/PM flags. Use myRTC.hourmode which returns 12-hour value, and myRTC.ampm (1 = PM, 0 = AM). You set the mode during setDS1302Time() . Tip 3: Battery Backup Trick If your DS1302 is running slow, check the voltage on pin 3.3V. Some modules have a diode that drops voltage. Powering the VCC pin with 5V and the backup battery with 3V can cause issues. Ensure the main power matches the chip's spec sheet. Conclusion The virtuabotixrtc.h Arduino library is a reliable, lightweight, and easy-to-use solution for integrating the DS1302 Real-Time Clock into your projects. While it may not be the newest or most feature-rich library available, its simplicity and low resource consumption make it perfect for thousands of existing Arduino sketches.
| DS1302 Module Pin | Connect to Arduino Pin | | :--- | :--- | | | 5V (or 3.3V, but 5V is typical) | | GND | GND | | CLK (Clock) | Digital Pin 4 | | DAT (Data) | Digital Pin 3 | | RST (Reset/Chip Select) | Digital Pin 2 |
#include <virtuabotixRTC.h> // Define your pins: (RST, DAT, CLK) int RTC_RST = 2; int RTC_DAT = 3; int RTC_CLK = 4;