How to Use a Real-Time Clock Module (DS3231)

How to Use a Real-Time Clock Module (DS3231)

This project will show you how to use a real-time clock module (DS3231). We'll display the values on the serial monitor.

  • 161,044 views
  • 58 comments
  • 30 respects

Components and supplies

Apps and online services

About this project

Operation

The Time Clock Module ( or DS3231 ) is a module that measures the time, dependently or independently of his Arduino card through of his cell.

The Arduino card measures the elapsed time since the module was turned on ( in ms ).

The module comes assembled ready-to-use, with battery ( supplied ).

Code

The code has been made by Gilles Thebault : http://gilles.thebault.free.fr/spip.php?article53

Library

The code need the " Wire " Library, which is already in the card. So you don't have to download it.

You will also need the "ds3231" Library : https://github.com/rodan/ds3231.

Connections


Code

DS3231Arduino
This code will displays values on the serial monitor.
#include <Wire.h>
#include <ds3231.h>
 
struct ts t; 
 
void setup() {
  Serial.begin(9600);
  Wire.begin();
  DS3231_init(DS3231_CONTROL_INTCN);
  /*----------------------------------------------------------------------------
  In order to synchronise your clock module, insert timetable values below !
  ----------------------------------------------------------------------------*/
  t.hour=12; 
  t.min=30;
  t.sec=0;
  t.mday=25;
  t.mon=12;
  t.year=2019;
 
  DS3231_set(t); 
}
 
void loop() {
  DS3231_get(&t);
  Serial.print("Date : ");
  Serial.print(t.mday);
  Serial.print("/");
  Serial.print(t.mon);
  Serial.print("/");
  Serial.print(t.year);
  Serial.print("\t Hour : ");
  Serial.print(t.hour);
  Serial.print(":");
  Serial.print(t.min);
  Serial.print(".");
  Serial.println(t.sec);
 
  delay(1000);
}

Comments

Similar projects you might like

Amazing Binary Clock using LED Matrix Module

Project showcase by LAGSILVA

  • 14,584 views
  • 12 comments
  • 67 respects

LCD with DS3231 Real Time Clock Module

Project showcase by Tan See Youu

  • 60,837 views
  • 3 comments
  • 46 respects

7-Segment Clock with Arduino Nano + DS3231 + LDR

Project tutorial by Ingo Lohs

  • 31,187 views
  • 23 comments
  • 42 respects

Digital Calendar Clock

Project tutorial by Akshay Joseph

  • 7,754 views
  • 0 comments
  • 6 respects

Adjusting Dual Clock using DS3231 on 1.8" ST7735 Display

Project showcase by FLORICA Tudor-Nicusor

  • 12,393 views
  • 3 comments
  • 24 respects

Big Real-Time Clock Using Arduino

Project tutorial by Rahul Khanna D

  • 9,810 views
  • 4 comments
  • 22 respects
Add projectSign up / Login