Module – DS1302 – RTC Tijdklok
Hardware
Een RTC tijdklok met batterij, de klok maakt gebruik van de DS1302 chip.
Informatie (ENG)
- Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year with Leap-Year Compensation Valid Up to 2100
- 31 x 8 Battery-Backed General-Purpose RAM
- Serial I/O for Minimum Pin Count
- 2.0V to 5.5V Full Operation
- Uses Less than 300nA at 2.0V
- Single-Byte or Multiple-Byte (Burst Mode) Data Transfer for Read or Write of Clock or RAM Data
- 8-Pin DIP or Optional 8-Pin SO for Surface Mount
- Simple 3-Wire Interface
- TTL-Compatible (VCC = 5V)
- Optional Industrial Temperature Range: -40°C to +85°C
- DS1202 Compatible
Pinout
Pin (batterij aan de voorkant): | Functie: |
---|---|
01 | VCC1 (batterij opladen) |
02 | VCC2 (+5v) |
03 | GND |
04 | SCLK (serial clock) |
05 | I/O (data) |
06 | RST (reset) |
Pin (batterij aan de voorkant): | Functie: |
---|---|
01 | VCC1 (+5v) |
02 | GND |
03 | CLK (serial clock) |
04 | DAT (data) |
05 | RST (reset) |
IC Pinout:
Arduino
Sluit de Module aan zoals aangegeven op onderstaand schema:
Arduino pin: | Pin (batterij aan de voorkant): |
---|---|
+5v | 01 - VCC1 (+5v) |
GND | 02 - GND |
D6 | 03 - CLK (serial clock) |
D7 | 04 - DAT (data) |
D8 | 05 - RST (reset) |
Onderstaand script maakt gebruik van de “Henning Karlsen” bibliotheek deze stelt de tijd en datum in en leest de gegevens uit via de seriële poort.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#include <DS1302.h> // Init the DS1302 // DS1302 rtc([CE/RST], [I/O], [CLOCK]); DS1302 rtc(8, 7, 6); void setup() { // Set the clock to run-mode, and disable the write protection rtc.halt(false); rtc.writeProtect(false); // Setup Serial connection Serial.begin(9600); // The following lines can be commented out to use the values already stored in the DS1302 rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format) rtc.setDate(6, 8, 2010); // Set the date to August 6th, 2010 } void loop() { // Send Day-of-Week Serial.print(rtc.getDOWStr()); Serial.print(" "); // Send date Serial.print(rtc.getDateStr()); Serial.print(" -- "); // Send time Serial.println(rtc.getTimeStr()); // Wait one second before repeating :) delay (1000); } |
Ps. Vergeet na de upload deze regels niet uit te zetten of weg te halen! en dan het script zonder deze regels opnieuw te uploaden.
1 2 3 |
rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format) rtc.setDate(6, 8, 2010); // Set the date to August 6th, 2010 |
Het resultaat:
Alleen een gedeelte van de tijd, hieronder als voorbeeld de uren:
1 2 3 4 5 |
String uurstr; uurstr = rtc.getTimeStr(); int uur = uurstr.substring(0, 2).toInt(); Serial.println(uur); |
Arduino Library
Installatie van Arduino IDE libraries: Arduino info
Informatie (ENG):
Library: DS1302
The DS1302 trickle-charge timekeeping chip contains a real-time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator (The library only support the 24-hour mode).
Interfacing the DS1302 with a microprocessor is simplified by using synchronous serial communication. Only three wires are required to communicate with the clock/RAM: CE, I/O (data line), and SCLK (serial clock). Data can be transferred to and from the clock/RAM 1 byte at a time or in a burst of up to 31 bytes. The DS1302 is designed to operate on very low power and retain data and clock information on less than 1µW.
The DS1302 is the successor to the DS1202. In addition to the basic timekeeping functions of the DS1202, the DS1302 has the additional features of dual power pins for primary and backup power supplies, programmable trickle charger for VCC1, and seven additional bytes of scratchpad memory.
- DS1302 v2.2.7z 68,11 kb
Afmetingen
GEEN GEGEVENS
Schema
Teardown
GEEN GEGEVENS
Datasheet
Fritzing
- RTC_DS1302_module.fzpz 23,06 kb
Downloads
GEEN GEGEVENS