ds3231 arduino circuit pinout proteus library

ds3231 arduino circuit pinout proteus library

ds3231 arduino circuit pinout proteus library,ds3231 arduino circuit
[otw_is sidebar=otw-sidebar-1] I will talk about Ds3231 Arduino Circuit  DS3231 RTC device, main components and application of this module and at the end we will show you how to Interface a DS3231 Real Time Clock device with Arduino.

 

Note on Real Time Clock (RTC):

The DS3231 is a Real Time Clock made by Maxim Integrated American Company. It is a low cost, extremely precise RTC with transmission over I2C Interface. An important feature of DS3231 RTC is that it has integrated crystal oscillator and temperature sense ability and you do not have to attach an external crystal.we need to download it first.

It is accessible in SO16 Package. Although it require only 8 pins in the accessible 16 pins to function, the integration of crystal makes the IC large and it is packed as a 16 pin IC rather than 8 pin IC.

ds3231 arduino circuit pinout proteus library,Note on Real Time Clock (RTC),DS3231 Clock Using Arduino

DS3231  Pin Configuration

ds3231 pinout,DS3231  Pin Configuration,DS3231 Circuit Design

 

Pin No Pin Name Description
1 32KHz 32KHz output
2 Vcc DC pin
3 SQW Square wave output
4 RST Low reset
5-12 NC No Connection
13 GND Ground
14 Vbat Power supply from battery
15 SDA Serial input &output
16 SCL Serial Clock Input

 

Interfacing DS3231 RTC with Arduino

 

I have setup an easy data logging application where the data from a sensor is stored in the SD Card in the sort of a text file.

By integrating a DS3231 in this project, you can keep detect the data log with precise time details. So, interfacing DS3231 RTC device with Arduino has a numerous implementation and advantages.

Components Required

DS3231 Circuit Design

Let’s begin the connections between Arduino and DS3231. The junction between them is I2C, point out the I2C Pins on your Arduino Board. In Arduino, A4 and A5 are SDA and SCL pins. Attach these pins with similar SDA and SCL pins of the DS3231 component. Also, join the Vcc and GND of the RTC component to 5v and GND of Arduino.

Connect the push button with Arduino pin 8 and 9.

To see the output, I am using an LCD component. Join the CS with GND and connect Vcc with CS pin.

you can see how to relay interfacing with arduino in proteus.  my last post is  what is relay 


 

 

DS3231 Proteus Library

ds3231 proteus library,Interfacing DS3231 RTC with Arduino

DS3231 Working

The working of the Arduino DS3231 RTC device is very simple. Arduino first stored the RTC component with its peasant address.

Arduino then upload the internal registers of the RTC with the date and time at which the code is assemble and uploaded to Arduino. The updated date and time can be display on the LCD.

If you want the DS3231 device to keep time even after you disjoin power to Arduino, you can also attach a 3v Battery.

DS3231 Application

  • Servers
  • GPS Module
  • Power Meters

So this is it. I hope you consider this guide helpful. Will meets you guys next time with new topic. Till then take care, have fun.

 

Arduino lcd rtc circuit

Arduino lcd rtc circuit

Arduino lcd rtc circuit

 

 

ds3231 programming

int sw1=8;
int sw2=9;
int sw3=10;
int sw4=11;
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
#include <Wire.h>
const int DS1307 = 0x68; // Address of DS1307 see data sheets
const char* days[] =
{“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”};
const char* months[] =
//{“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”,”September”, “October”, “November”, “December”};
{“Jan”, “Feb”, “March”, “April”, “May”, “June”, “July”, “August”,”Septem”, “Octobe”, “Novem”, “Decemb”};
// Initializes all values:
byte second = 0;
byte minute = 0;
byte hour = 0;
byte weekday = 0;
byte monthday = 0;
byte month = 0;
byte year = 0;
void setup() {
  Wire.begin();
   lcd.begin(16, 2);
  pinMode(sw1, INPUT_PULLUP);
  pinMode(sw2, INPUT_PULLUP);
  pinMode(sw3, INPUT_PULLUP);
  pinMode(sw4, INPUT_PULLUP);
if(digitalRead(sw1) == LOW){
 delay(100);
  }
  Serial.begin(9600);
  delay(2000); // This delay allows the MCU to read the current date and time.
  Serial.print(“The current date and time is: “);
  printTime();
  Serial.println(“Please change to newline ending the settings on the lower right of the Serial Monitor”);
  Serial.println(“Would you like to set the date and time now? Y/N”);
 /*
  while (!Serial.available()) delay(10);
  if (Serial.read() == ‘y’ || Serial.read() == ‘Y’)
  // This set of functions allows the user to change the date and time
  {
    Serial.read();
    setTime();
    Serial.print(“The current date and time is now: “);
    printTime();
  }
 */
  Serial.println(“Thank you.”);
}
// Continuous function for converting bytes to decimals and vice versa
void loop() {
    printTime();
 delay(500);
chk();
}
void chk(){
  if(digitalRead(sw1) == LOW){
lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print(“enter year setting”);
 delay(500);
while(digitalRead(sw1) == LOW){delay(500); }
while(digitalRead(sw1) == HIGH){delay(500);
if(digitalRead(sw2) == LOW){
year++;
 lcd.setCursor(10, 1);
 lcd.print(year);
delay(300);
}
if(digitalRead(sw3) == LOW){
year–;lcd.setCursor(10, 1);
 lcd.print(year);delay(300);
}}
lcd.clear(); delay(300);
///*
lcd.clear(); lcd.setCursor(0, 0);
 lcd.print(“enter month”);delay(500);
while(digitalRead(sw1) == LOW){delay(500); }
while(digitalRead(sw1) == HIGH){delay(300);
if(digitalRead(sw2) == LOW){
lcd.setCursor(6, 1);
 lcd.print(”           “);
month++; lcd.setCursor(6, 1);
 lcd.print(months[month-1]);delay(100);
}
if(digitalRead(sw3) == LOW){
month–;
lcd.setCursor(6, 1);  lcd.print(”           “);
lcd.setCursor(6, 1);
 lcd.print(months[month-1]);delay(100);
}}
lcd.clear(); delay(300);
lcd.clear(); lcd.setCursor(0, 0);
 lcd.print(“enter date”);delay(500);
while(digitalRead(sw1) == LOW){delay(500); }
while(digitalRead(sw1) == HIGH){delay(300);
if(digitalRead(sw2) == LOW){
lcd.setCursor(6, 1);
 lcd.print(”           “);
monthday++; lcd.setCursor(6, 1);
 lcd.print(monthday);delay(100);
}
if(digitalRead(sw3) == LOW){
monthday–;
lcd.setCursor(6, 1);  lcd.print(”           “);
lcd.setCursor(6, 1);
 lcd.print(monthday);delay(100);
}}
lcd.clear(); lcd.setCursor(0, 0);
 lcd.print(“enter day”);delay(500);
while(digitalRead(sw1) == LOW){delay(500); }
while(digitalRead(sw1) == HIGH){delay(300);
if(digitalRead(sw2) == LOW){
lcd.setCursor(6, 1);
 lcd.print(”           “);
weekday++; lcd.setCursor(6, 1);
 lcd.print(days[weekday-1]);delay(100);
}
if(digitalRead(sw3) == LOW){
weekday–;
lcd.setCursor(6, 1);  lcd.print(”           “);
lcd.setCursor(6, 1);
 lcd.print(days[weekday-1]);delay(100);
}}
lcd.clear(); lcd.setCursor(0, 0);
 lcd.print(“enter hour”);delay(500);
while(digitalRead(sw1) == LOW){delay(500); }
while(digitalRead(sw1) == HIGH){delay(300);
if(digitalRead(sw2) == LOW){
lcd.setCursor(6, 1);
 lcd.print(”           “);
hour++; lcd.setCursor(6, 1);
 lcd.print(hour);delay(100);
}
if(digitalRead(sw3) == LOW){
hour–;
lcd.setCursor(6, 1);  lcd.print(”           “);
lcd.setCursor(6, 1);
 lcd.print(hour);delay(100);
}}
lcd.clear(); lcd.setCursor(0, 0);
 lcd.print(“enter minute”);delay(500);
while(digitalRead(sw1) == LOW){delay(500); }
while(digitalRead(sw1) == HIGH){delay(300);
if(digitalRead(sw2) == LOW){
lcd.setCursor(6, 1);
 lcd.print(”           “);
minute++; lcd.setCursor(6, 1);
 lcd.print(minute);delay(100);
}
if(digitalRead(sw3) == LOW){
minute–;
lcd.setCursor(6, 1);  lcd.print(”           “);
lcd.setCursor(6, 1);
 lcd.print(minute);delay(100);
}}
second=0;
//*/
  // The following codes transmits the data to the RTC
  Wire.beginTransmission(DS1307);
  Wire.write(byte(0));
  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(weekday));
  Wire.write(decToBcd(monthday));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.write(byte(0));
  Wire.endTransmission();
  // Ends transmission of data
  }
  }
byte decToBcd(byte val) {
  return ((val/10*16) + (val%10));
}
byte bcdToDec(byte val) {
  return ((val/16*10) + (val%16));
}
// This set of codes is allows input of data
void setTime() {
  Serial.print(“Please enter the current year, 00-99. – “);
  year = readByte();
  Serial.println(year);
  Serial.print(“Please enter the current month, 1-12. – “);
  month = readByte();
  Serial.println(months[month-1]);
  Serial.print(“Please enter the current day of the month, 1-31. – “);
  monthday = readByte();
  Serial.println(monthday);
  Serial.println(“Please enter the current day of the week, 1-7.”);
  Serial.print(“1 Sun | 2 Mon | 3 Tues | 4 Weds | 5 Thu | 6 Fri | 7 Sat – “);
  weekday = readByte();
  Serial.println(days[weekday-1]);
  Serial.print(“Please enter the current hour in 24hr format, 0-23. – “);
  hour = readByte();
  Serial.println(hour);
  Serial.print(“Please enter the current minute, 0-59. – “);
  minute = readByte();
  Serial.println(minute);
  second = 0;
  Serial.println(“The data has been entered.”);
  // The following codes transmits the data to the RTC
  Wire.beginTransmission(DS1307);
  Wire.write(byte(0));
  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(weekday));
  Wire.write(decToBcd(monthday));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.write(byte(0));
  Wire.endTransmission();
  // Ends transmission of data
}
byte readByte() {
  while (!Serial.available()) delay(10);
  byte reading = 0;
  byte incomingByte = Serial.read();
  while (incomingByte != ‘\n’) {
    if (incomingByte >= ‘0’ && incomingByte <= ‘9’)
      reading = reading * 10 + (incomingByte – ‘0’);
    else;
    incomingByte = Serial.read();
  }
  Serial.flush();
  return reading;
}
void printTime() {
  char buffer[3];
  const char* AMPM = 0;
  readTime();
  Serial.print(days[weekday-1]);
  Serial.print(” “);
  Serial.print(months[month-1]);
  Serial.print(” “);
  Serial.print(monthday);
  Serial.print(“, 20”);
  Serial.print(year);
  Serial.print(” “);
  if (hour > 12) {
    hour -= 12;
    AMPM = ” PM”;
  }
  else AMPM = ” AM”;
  Serial.print(hour);
  Serial.print(“y:”);
  sprintf(buffer, “%02d”, minute);
  Serial.print(buffer);
  Serial.println(AMPM);
  lcd.setCursor(0, 0);
  lcd.print(hour);
  lcd.print(“:”);
  lcd.print(buffer);
  lcd.print(AMPM);
 lcd.print(” “);
lcd.print(days[weekday-1]);
 lcd.setCursor(0, 1);
  lcd.print(monthday);
 lcd.print(months[month-1]);
 lcd.print(“20”);
  lcd.print(year);
}
void readTime() {
  Wire.beginTransmission(DS1307);
  Wire.write(byte(0));
  Wire.endTransmission();
  Wire.requestFrom(DS1307, 7);
  second = bcdToDec(Wire.read());
  minute = bcdToDec(Wire.read());
  hour = bcdToDec(Wire.read());
  weekday = bcdToDec(Wire.read());
  monthday = bcdToDec(Wire.read());
  month = bcdToDec(Wire.read());
  year = bcdToDec(Wire.read());
}

 

 

 

ds3231 arduino circuit pinout proteus library

CHECK THIS LINK Arduino Simulator 

 


Leave a Reply

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