MisterBotBreak
Published

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.

BeginnerProtip1 hour256,983
How to Use a Real-Time Clock Module (DS3231)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Time clock module ZS-042
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

DS3231

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

Credits

MisterBotBreak

MisterBotBreak

48 projects • 151 followers
I love electronics and cats :D !
Thanks to DougalPlummer.

Comments