DS3231 模块

是一个时钟模块,上面包含一个纽扣电池位置,可以在主机断电的情况下还可以继续计算时间,以便以后记录使用。

模块参数:
   1.尺寸:38mm(长)*22mm(宽)*14mm(高)
   2.重量:8g
   3.工作电压:3.3--5.5V
   4.时钟芯片:高精度时钟芯片DS3231
   5.时钟精度:0-40℃范围内,精度2ppm,年误差约1分钟
   6.带2个日历闹钟
   7.可编程方波输出
   8.实时时钟产生秒、分、时、星期、日期、月和年计时,并提供有效期到2100年的闰年补偿
   9.芯片内部自带温度传感器,精度为±3℃
   10.存储芯片:AT24C32(存储容量32K)
   11.IIC总线接口,最高传输速度400KHz(工作电压为5V时)
   12.可级联其它IIC设备,24C32地址可通过短路A0/A1/A2修改,默认地址为0x57
   13.带可充电电池LIR2032,保证系统断电后,时钟任然正常走动

实验效果

通过设定时间的程序后,

我们运行显示时间的程序,就可以看到时钟模块当前的时间了

BOM表

Arduino UNO    *1

DS3231 时钟模块 *1

跳线若干

接线

Arduino   Uno                               DS3231

GND                     <--->                GND

5V                          <--->                VCC

A4(SDA)                          <--->                SDA

A5 (SCL)                         <--->                 SCL

程序

需要下载库

http://www.rinkydinkelectronics.com/library.php?id=74

设置时间的程序

// 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 connectionSerial.begin(115200);// Uncomment the next line if you are using an Arduino Leonardo//while (!Serial) {}// Initialize the rtc objectrtc.begin();// The following lines can be uncommented to set the date and timertc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAYrtc.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-WeekSerial.print(rtc.getDOWStr());Serial.print(" ");// Send dateSerial.print(rtc.getDateStr());Serial.print(" -- ");// Send timeSerial.println(rtc.getTimeStr());// Wait one second before repeating :)delay (1000);
}

显示时间的程序

// 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 connectionSerial.begin(115200);// Uncomment the next line if you are using an Arduino Leonardo//while (!Serial) {}// Initialize the rtc objectrtc.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-WeekSerial.print(rtc.getDOWStr());Serial.print(" ");// Send dateSerial.print(rtc.getDateStr());Serial.print(" -- ");// Send timeSerial.println(rtc.getTimeStr());// Wait one second before repeating :)delay (1000);
}

思路讲解

1,#include <DS3231.h>    //加载DS3231库

2,DS3231  rtc(SDA, SCL);    //设置I2C

3,rtc.begin();   //建立RTC对象

4,

rtc.setDOW(WEDNESDAY);     // 设置星期几,例如 SUNDAY
  rtc.setTime(12, 0, 0);     // 设置时间 12:00:00 (24小时制)
  rtc.setDate(1, 1, 2014);   // 设置日期  1月,1日 ,2014 年

如果在显示程序中,或不需要设置时间的时候,可以在前面加//给注释掉

5,

rtc.getDOWStr()   获取星期几

rtc.getDateStr()    获取日期

rtc.getTimeStr()   获取时间

Arduino UNO DS3231高精度RTC芯片 制作时钟相关推荐

  1. 利用arduino UNO配合Orangepi 4B实现制作机器人

    利用arduino UNO配合Orangepi 4B实现制作机器人 在上一个博客的最后我提到了利用Orangepi 4B制作机器人(传送门) 在这部分需要有更多的准备 知识储备 硬件方面准备 软件方面 ...

  2. 基于Arduino UNO的光驱写字机制作

    功能说明:本写字机的绘图范围是40mm×40mm,可以书写汉字.手写字.图片(BMP格式)等等,可以进行逐行.Z字型走线.逐点.轮廓等四种模式进行绘图. 硬件材料:Arduino Uno(必须是MEG ...

  3. 如何用Arduino UNO和DS18B20防水传感器制作一个温度计

    使用Arduino UNO和DS18B20防水温度传感器自制温度计! 在本篇文章中,我们将使用Arduino UNO开发板和DS18B20温度传感器来制作温度计.当高精度应用需要良好的响应能力时,DS ...

  4. 基于Arduino uno单片机的仿生螃蟹制作

    最近帮朋友制作了一个小项目--仿生螃蟹.该项目具有俩个模式,一个是自动运行模式,一个是遥控模式.经过沟通,发现项目对于遥控的要求不高,于是推荐他们整体使用了红外遥控,毕竟红外遥控成本更低,开发上也比较 ...

  5. Arduino Uno 与 INA219功率监控模块 制作你的功率计

    实验效果 本试验可以检测电池当前输出电压和当前的输出电流 可以应用于电源监控, 可以应用于电源管理,例如充电时电流过高可以加外设备调整电量输出 此模块最大仅检测25V,高于此值极有可能烧鸡 BOM表 ...

  6. Arduino UNO驱动TM1637四位时钟数码管显示时间

    Arduino UNO驱动TM1637四位时钟数码管显示时间 一.TM1637简介 二.引脚定义 三.Arduino UNO与数码管模块接线 四.测试代码 五.实验结果 一.TM1637简介 TM16 ...

  7. 【RT-Thread】高精度RTC rx8900 驱动软件包

    文章目录 1 介绍 1.1 支持功能 1.2 目录结构 1.3 许可证 1.4 依赖 2 实现功能 2.1 rx8900驱动描述 2.2 rx8900读寄存器接口 2.3 rx8900写寄存器接口 2 ...

  8. 从一个空白芯片开始制作arduino uno最小系统板

    摘要:只用一个空白的芯片是无法实现在arduino 编程环境中编程的,芯片需要烧录arduino专用的bootloader才能使用.本文介绍如何从购买一个空白芯片开始,制作arduino uno 的最 ...

  9. STC8H开发(十三): I2C驱动DS3231高精度实时时钟芯片

    目录 STC8H开发(一): 在Keil5中配置和使用FwLib_STC8封装库(图文详解) STC8H开发(二): 在Linux VSCode中配置和使用FwLib_STC8封装库(图文详解) ST ...

最新文章

  1. 共建网络安全堤坝,守住网络安全底线
  2. linux 内核生成
  3. 部署时服务端Excel的COM设置
  4. 使用 okHttp 3.0 版本前后的两点区别.(不要入坑哦)
  5. 嵌入式linux段错误,在嵌入式Linux上使用C Std Lib时出现异常的段错误
  6. 使用Vant完成DatetimePicker 日期的选择器
  7. 计组之指令系统:1、指令系统概述(定义、分类、格式、扩展操作码指令格式)
  8. 如何修复崩溃的WordPress数据库表
  9. http请求消息体和响应消息体
  10. Android Studio实现前后台分离的选课系统
  11. JS实现静默发送邮件功能(选择填报提交后发送、数据查询后发送参考前者)
  12. Kafka权威指南-学习笔记---第一章
  13. python控制苹果手机触摸屏失灵怎么办_iPhone6触屏失灵,用一会就失灵,很恼火?...
  14. The number of method references in a .dex file cannot exceed 64K. Error 解决方案
  15. python没学历可以学习么_python没有学历好就业吗_学历低可以学习python吗
  16. 淘宝API应用开发小试
  17. 自定义注解+切面处理+全局异常处理
  18. 求生之路怎么显示服务器,求生之路2怎么屏蔽rpg服务器 求生之路2屏蔽rpg服务器方法-超能街机...
  19. Vue入门练习:小王记事本
  20. python计算学分绩点_使用Python计算研究生学分绩(绩点)

热门文章

  1. 推荐一款电子表格软件:自带网盘功能,功能全面超越Excel和WPS
  2. 原型模式以及深克隆和浅克隆
  3. 陈志武《金融的逻辑》
  4. 希尔伯特曲线 java_《算法心得:高效算法的奥秘》PDF 下载
  5. UML活动图、状态图
  6. google 使用技巧(转载)
  7. 阿里巴巴2021年双11全球购物狂欢节业绩稳步增长
  8. 领导下发紧急且风险大的任务,如何处理?
  9. 真正喜欢上一个人的感觉,或许从你开始觉得自己配不上她
  10. 与古鲁打交道的礼节和教养(部分摘自图书-程序员修炼之道)