Tutorial Arduino

Tutorial Arduino Cara Mengakses RTC DS3231

Tutorial Arduino Cara Mengakses RTC DS3231. Masih dalam tema Tutorial Arduino Bahasa Indonesia, postingan kali ini admin akan membahas mengenai Cara Mengakses RTC DS1307. Apa itu RTC? oke mari kita bahas lebih lengkap.

Pengertian RTC DS3231

RTC DS3231 adalah IC RTC dengan harga yang cukup murah tetapi sangat akurat dan terintegrasi dengan crystal kompensasi suhu(TCXO) dan Crystal. IC RTC DS3231 memiliki input Battery yang berfungsi sebagai backUp catu daya dan mempertahankan ketepatan waktu pada saat supplay catu daya terputus. Komunikasi IC RTC DS3231 adalah menggunakan komunikasi 2 kabel atau lebih familiar dengan sebutan I2C.

Fungsi RTC DS3231

  • Servers
  • Telemetics
  • Data Logger
  • Utility Power Meter
  • GPS Tracking Systems

Fitur-fitur RTC DS3231

Highly Accurate RTC Completely Manages All
Timekeeping Functions
• 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
• Akurasi ±2ppm from 0°C to +40°C
• Akurasi ±3.5ppm from -40°C to +85°C
• Digital Temp Sensor Output: ±3°C Accuracy
• Register for Aging Trim
• RST Output/Pushbutton Reset Debounce Input
• Two Time-of-Day Alarms
• Programmable Square-Wave Output Signal
● Simple Serial Interface Connects to Most
Microcontrollers
• Fast (400kHz) I2C Interface
● Battery-Backup Input for Continuous Timekeeping
• Low Power Operation Extends Battery-Backup
Run Time
• 3.3V Operation
● Operating Temperature Ranges: Commercial
(0°C to +70°C) and Industrial (-40°C to +85°C)
● Underwriters Laboratories® (UL) Recognize

Arsitektur dan Blok Diagram IC RTC DS3231

Arsitektur dan Blok Diagram IC RTC DS3231

Skematik Rangkaian RTC DS3231 Arduino Uno

Berikut ini adalah skematik rangkan dari RTC DS3231 yang terhubung dengan Arduino Uno dan I2C LCD 1602

Tutorial Arduino Cara Mengakses RTC DS3231

 

Source Code Program Arduino Uno RTC DS3231

Source Code Program Arduino Uno untuk mengakses RTC DS3231

// DS3231_Serial_Easy
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A quick demo of how to use my DS3231-library to 
// quickly send time and date information over a serial link
//
// To use the hardware I2C (TWI) interface of the Arduino you must connect
// the pins as follows:
//
// Arduino Uno/2009:
// ----------------------
// DS3231:  SDA pin   -> Arduino Analog 4 or the dedicated SDA pin
//          SCL pin   -> Arduino Analog 5 or the dedicated SCL pin
//
// Arduino Leonardo:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 2 or the dedicated SDA pin
//          SCL pin   -> Arduino Digital 3 or the dedicated SCL pin
//
// Arduino Mega:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 20 (SDA) or the dedicated SDA pin
//          SCL pin   -> Arduino Digital 21 (SCL) or the dedicated SCL pin
//
// Arduino Due:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin
//          SCL pin   -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin
//
// The internal pull-up resistors will be activated when using the 
// hardware I2C interfaces.
//
// You can connect the DS3231 to any available pin but if you use any
// other than what is described above the library will fall back to
// a software-based, TWI-like protocol which will require exclusive access 
// to the pins used, and you will also have to use appropriate, external
// pull-up resistors on the data and clock signals.
//

#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

void setup()
{
  // Setup Serial connection
  Serial.begin(115200);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}
  
  // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time
  //rtc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(1, 1, 2014);   // Set the date to January 1st, 2014
}

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);
}

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button