- 29a Bùi Xuân Phái, P.Tây Thạnh, Quận Tân Phú, TPHCM
- linhkienduchuy2018@gmail.com
- TƯ VẤN, GIẢI ĐÁP, HƯỚNG DẪN, MUA HÀNG (ZALO): 0966515049 - 0942954739
Giao miễn phí chuyển phát nhanh trong nội thành TPHCM đối với đơn hàng trên 1 triệu đồng
Giảm 5k cho đơn hàng trên 300k đồng
Giảm 10k cho đơn hàng trên 500k đồng
Giảm 15k hoặc freeship chuyển phát nhanh cho đơn hàng trên 1tr đồng
Giảm 25.000đ hoặc freeship cho đơn hàng trên 2tr đồng.
Điện áp hoạt động : DC 3.3V đến 5V
Giao diện truyền thông : Kết nối nối tiếp đồng bộ 3 dây (CE/RST, I/O/DAT, SCLK)
Hệ thống chấm công : Có thể cấu hình giữa định dạng 12 giờ (có AM/PM) và 24 giờ.
Bộ dao động xung nhịp chính : Sử dụng tinh thể thạch anh tiêu chuẩn 32,768 kHz.
Mức tiêu thụ điện năng : Cực kỳ thấp, chỉ tiêu thụ dưới 300nA khi hoạt động bằng pin dự phòng.



CODE ARDUINO ĐỌC DỮ LIỆU RTC DS1302:
/*
This code initializes and sets up the RTC DS1302 module and prints the current date and
time on the serial monitor. It also checks if the RTC is running and has a valid date and time.
If not, it sets the RTC to the compile time.
Due to the time required for compilation and upload, there may be a time difference.
Board: Arduino Uno R3 (or R4)
Component: Real Time Clock Module (DS1302)
Library: https://github.com/Makuna/Rtc (Rtc by Makuna)
*/
#include <ThreeWire.h>
#include <RtcDS1302.h>
const int IO = 4; // DAT
const int SCLK = 5; // CLK
const int CE = 2; // RST
ThreeWire myWire(4, 5, 2); // IO, SCLK, CE
RtcDS1302<ThreeWire> Rtc(myWire);
void setup() {
Serial.begin(9600);
Serial.print("compiled: ");
Serial.print(__DATE__);
Serial.println(__TIME__);
Rtc.Begin();
RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
printDateTime(compiled);
Serial.println();
if (!Rtc.IsDateTimeValid()) {
// Common Causes:
// 1) first time you ran and the device wasn't running yet
// 2) the battery on the device is low or even missing
Serial.println("RTC lost confidence in the DateTime!");
Rtc.SetDateTime(compiled);
}
if (Rtc.GetIsWriteProtected()) {
Serial.println("RTC was write protected, enabling writing now");
Rtc.SetIsWriteProtected(false);
}
if (!Rtc.GetIsRunning()) {
Serial.println("RTC was not actively running, starting now");
Rtc.SetIsRunning(true);
}
RtcDateTime now = Rtc.GetDateTime();
if (now < compiled) {
Serial.println("RTC is older than compile time! (Updating DateTime)");
Rtc.SetDateTime(compiled);
} else if (now > compiled) {
Serial.println("RTC is newer than compile time. (this is expected)");
} else if (now == compiled) {
Serial.println("RTC is the same as compile time! (not expected but all is fine)");
}
}
void loop() {
RtcDateTime now = Rtc.GetDateTime();
printDateTime(now);
Serial.println();
if (!now.IsValid()) {
// Common Causes:
// 1) the battery on the device is low or even missing and the power line was disconnected
Serial.println("RTC lost confidence in the DateTime!");
}
delay(5000); // five seconds
}
#define countof(a) (sizeof(a) / sizeof(a[0]))
void printDateTime(const RtcDateTime& dt) {
char datestring[20];
snprintf_P(datestring,
countof(datestring),
PSTR("%02u/%02u/%04u %02u:%02u:%02u"),
dt.Month(),
dt.Day(),
dt.Year(),
dt.Hour(),
dt.Minute(),
dt.Second());
Serial.print(datestring);
}
Bình luận