Difference between revisions of "Arduino: RTC DS1302"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Onnowpurbo (talk | contribs)  (New page: Sumber: http://domoticx.com/arduino-modules-rtc-tijdklok-ds1302/  ==Download Library==  * http://domoticx.com/arduino-library-ds13xx-en-ds32xx-rtc-module/ * http://domoticx.phoenixinteract...)  | 
				Onnowpurbo (talk | contribs)   | 
				||
| (3 intermediate revisions by the same user not shown) | |||
| Line 9: | Line 9: | ||
* http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS3234%20v1.0.7z  | * http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS3234%20v1.0.7z  | ||
| + | Lakukan  | ||
| + |  cp *7z /usr/share/arduino/libraries/  | ||
| + |  cd /usr/share/arduino/libraries/  | ||
| + |  mkdir DS1302  | ||
| + |  mkdir DS1307  | ||
| + |  mkdir DS3231  | ||
| + |  mkdir DS3234  | ||
| + | |||
| + | |||
| + |  cd ~/Arduino/libraries  | ||
| + |  mkdir DS3102  | ||
| + |  wget http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS1302%20v2.2.7z  | ||
| + |  mv DS1302\ v2.2.7z DS1302/  | ||
| + |  cd DS1302  | ||
| + |  7z x DS1302\ v2.2.7z  | ||
| + | |||
| + | |||
| + |  mv DS1307* DS1307  | ||
| + |  cd DS1307  | ||
| + |  7z x DS1307\ v1.1.7z  | ||
| + |  cd /usr/share/arduino/libraries/  | ||
| + | |||
| + |  cd ~/Arduino/libraries  | ||
| + |  mkdir DS3231  | ||
| + |  wget http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS3231%20v1.01.7z  | ||
| + |  wget http://145.130.102.57/domoticx/arduino/libraries/ds13xx_ds32xx/DS3231%20v1.01.7z  | ||
| + |  mv DS3231* DS3231  | ||
| + |  cd DS3231  | ||
| + |  7z x DS3231\ v1.01.7z   | ||
| + | |||
| + |  mv DS3234* DS3234  | ||
| + |  cd DS3234  | ||
| + |  7z x DS3234\ v1.0.7z  | ||
| + |  cd /usr/share/arduino/libraries/  | ||
==Rangkaian==  | ==Rangkaian==  | ||
| Line 33: | Line 67: | ||
  // DS1302 rtc([CE/RST], [I/O], [CLOCK]);  |   // DS1302 rtc([CE/RST], [I/O], [CLOCK]);  | ||
  DS1302 rtc(8, 7, 6);  |   DS1302 rtc(8, 7, 6);  | ||
| + |  Time waktu;  | ||
  void setup() {  |   void setup() {  | ||
    // Set the clock to run-mode, and disable the write protection  |     // Set the clock to run-mode, and disable the write protection  | ||
    rtc.halt(false);  |     rtc.halt(false);  | ||
| − |     rtc.writeProtect(false);  | + |     // rtc.writeProtect(false);  | 
| + |    rtc.writeProtect(true);  | ||
    // Setup Serial connection  |     // Setup Serial connection  | ||
| Line 43: | Line 79: | ||
    // The following lines can be commented out to use the values already stored in the DS1302  |     // The following lines can be commented out to use the values already stored in the DS1302  | ||
| − |     rtc.setDOW(  | + |     // rtc.setDOW(MONDAY);        // Set Day-of-Week to MONDAY  | 
| − |     rtc.setTime(  | + |     // rtc.setTime(13, 0, 0);     // Set the time to 12:00:00 (24hr format)  | 
| − |     rtc.setDate(  | + |     // rtc.setDate(29, 2, 2016);   // Set the date to Feb 2, 2016  | 
  }  |   }  | ||
  void loop() {  |   void loop() {  | ||
| + |    waktu = rtc.getTime();  | ||
| + |    int dataJam = waktu.hour;       | ||
| + |    int dataMenit = waktu.min;  | ||
| + |    int dataDetik = waktu.sec;  | ||
| + | |||
    // Send Day-of-Week  |     // Send Day-of-Week  | ||
    Serial.print(rtc.getDOWStr());  |     Serial.print(rtc.getDOWStr());  | ||
| Line 59: | Line 100: | ||
    // Send time  |     // Send time  | ||
    Serial.println(rtc.getTimeStr());  |     Serial.println(rtc.getTimeStr());  | ||
| − | + | ||
    // Wait one second before repeating :)  |     // Wait one second before repeating :)  | ||
    delay (1000);  |     delay (1000);  | ||
  }  |   }  | ||
| − | |||
==Referensi==  | ==Referensi==  | ||
* http://domoticx.com/arduino-modules-rtc-tijdklok-ds1302/  | * http://domoticx.com/arduino-modules-rtc-tijdklok-ds1302/  | ||
Latest revision as of 05:57, 7 June 2018
Sumber: http://domoticx.com/arduino-modules-rtc-tijdklok-ds1302/
Download Library
- http://domoticx.com/arduino-library-ds13xx-en-ds32xx-rtc-module/
 - http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS1302%20v2.2.7z
 - http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS1307%20v1.1.7z
 - http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS3231%20v1.01.7z
 - http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS3234%20v1.0.7z
 
Lakukan
cp *7z /usr/share/arduino/libraries/ cd /usr/share/arduino/libraries/ mkdir DS1302 mkdir DS1307 mkdir DS3231 mkdir DS3234
cd ~/Arduino/libraries mkdir DS3102 wget http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS1302%20v2.2.7z mv DS1302\ v2.2.7z DS1302/ cd DS1302 7z x DS1302\ v2.2.7z
  
mv DS1307* DS1307 cd DS1307 7z x DS1307\ v1.1.7z cd /usr/share/arduino/libraries/
cd ~/Arduino/libraries mkdir DS3231 wget http://domoticx.phoenixinteractive.nl/arduino/libraries/ds13xx_ds32xx/DS3231%20v1.01.7z wget http://145.130.102.57/domoticx/arduino/libraries/ds13xx_ds32xx/DS3231%20v1.01.7z mv DS3231* DS3231 cd DS3231 7z x DS3231\ v1.01.7z
mv DS3234* DS3234 cd DS3234 7z x DS3234\ v1.0.7z cd /usr/share/arduino/libraries/
Rangkaian
Pin
Arduino RTC +5v 01 - VCC1 (+5v) GND 02 - GND D6 03 - CLK (serial clock) D7 04 - DAT (data) D8 05 - RST (reset)
Code
#include <DS1302.h>
 
// Init the DS1302
// DS1302 rtc([CE/RST], [I/O], [CLOCK]);
DS1302 rtc(8, 7, 6);
Time waktu;
 
void setup() {
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  // rtc.writeProtect(false);
  rtc.writeProtect(true);
  
  // Setup Serial connection
  Serial.begin(9600);
 
  // The following lines can be commented out to use the values already stored in the DS1302
  // rtc.setDOW(MONDAY);        // Set Day-of-Week to MONDAY
  // rtc.setTime(13, 0, 0);     // Set the time to 12:00:00 (24hr format)
  // rtc.setDate(29, 2, 2016);   // Set the date to Feb 2, 2016
}
 
void loop() {
  waktu = rtc.getTime();
  int dataJam = waktu.hour;     
  int dataMenit = waktu.min;
  int dataDetik = waktu.sec;
  
  // 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);
}