Arduino--DS3231实时时钟模块
(1)简介
DS3231是一种实时的RCT IC芯片,通过IIC接口进行通信,默认IIC通信地址为(0X68,应该是在头文件中有体现,大概看了下也没找见),其内部还集成了晶体振荡器和温度传感器,无需连接外部晶体。
DS3231模块如下图所示,包含RTC芯片和一个32K的EEPROM
自身带有3V CR2032锂电池,掉电时间不变
包括年、月、日、时、分、秒等具体时间信息
(2)连线
主要是IIC接口,本实验室是基于Arduino UNO使用,其他开发板的IIC管脚参考以下链接:
https://blog.csdn.net/u011816009/article/details/106566177
UNO | DS3231 |
---|---|
5V | VCC |
GND | GND |
A4 | SDA |
A5 | SCL |
(3)程序
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 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(FRIDAY); // Set Day-of-Week to SUNDAYrtc.setTime(14, 26, 50); // Set the time to 12:00:00 (24hr format)rtc.setDate(3, 8, 2019); // 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);
}
时钟显示
#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);
}
Arduino--DS3231实时时钟模块相关推荐
- 【Arduino 和 DS3231 实时时钟教程】
[Arduino 和 DS3231 实时时钟教程] 1. 概述 2. 原理分析 3. DS3231 实时时钟 4. 编程 1. 概述 在本Arduino教程中,我们将学习如何使用DS3231实时时钟模 ...
- ESP32连接DS3231实时时钟(RTC)的方法
在本篇文章中,我们将学习如何将RTC实时时钟模块DS3231连接到ESP32开发板和0.96英寸I2C OLED显示屏.我们将使用DS3231实时时钟模块跟踪正确的时间和日期,在OLED显示屏上进行显 ...
- Arduino开发实例-DS3231实时时钟+LCD显示
DS3231实时时钟+LCD显示 1.DS3231介绍 DS3231是低成本.高精度I2C实时时钟(RTC),具有集成的温补晶振(TCXO)和晶体.该器件包含电池输入端,断开主电源时仍可保持精确的计时 ...
- ESP32设备驱动-DS3231实时时钟(RTC)驱动
DS3231实时时钟(RTC)驱动 1.DS3231介绍 DS3231 是一款低成本.极其精确的 I2C 实时时钟 (RTC),具有集成的温度补偿晶体振荡器 (TCXO) 和晶体. 该设备包含电池输入 ...
- linux设置rx8010时间,【经验】实时时钟模块RX8010SJ精度的软件校准方法
RX8010SJ,由于使用简单.标准SOP8封装和高性价比等特点,已经被广泛的应用于各种电子产品的设计中.虽然RX8010SJ内置出厂时经过校准的32.768KHz的晶体单元,能够很大程度上保证了其精 ...
- 树莓派基础实验32:DS1302实时时钟模块实验
一.介绍 现在有很多流行的串行时钟芯片,如DS1302,DS1307,PCF8485等,由于简单的接口,低成本和易用性,他们被广泛应用于电话.传真.便携式仪器等产品领域.在本实验中,我们将使用DS ...
- PCF8563实时时钟模块功能实现
1.概述 PCF8563是为低功耗而优化的CMOS实时时钟/日历.提供了可编程时钟输出.中断输出和低电压检测器.所有地址和数据都是通过两路双向IIC总线串行传输的.最大总线速度为400kbits/s. ...
- 关于实时时钟模块DS1302使用心得
最近在做万年历,用到实时时钟DS1302模块,花了两天时间看资料和写驱动,想记录一下我的学习经过,顺便做一下总结. 首先就是在图书馆查各种资料,于是查到的大多是这些,主要时硬件方面的资料: 其实能查到 ...
- 【Arduino】ESP8266DS1302时钟模块
前言 ESP8266基于Arduino IDE的DS1302时钟模块使用,的过程记录.DS1302时钟模块就不详细介绍了,网上还是有很多资料的,这里只说如何快速上手. 下载文件 代码理解 实际测试 ...
- 【ESP32】17.DS1302实时时钟模块实验(ThreeWire库 / RtcDS1302库)
上一篇: [ESP32]16.RFID门禁系统实验(SPI总线 / MFRC522库) 前言: 先放电路连接图: DS1302 RTC模块,内置Tri流充电器的实时时钟(RTC),或Timekeepi ...
最新文章
- 页面自动获取焦点影响页面切换效果_ReactIndex - 让文件夹index页面变得更有实用性 (替换传统Web服务器index页)...
- 安卓性能调优工具简介(转)
- Python: How to Sort a List
- 【数据结构与算法】计数、基数、桶 O(n) 不基于比较
- 具备什么样的能力,才能在人工智能企业中获得一席之地
- Android开发手记(23) Notification
- python-同步(互斥)锁、递归锁、同步条件(event)
- bzoj4806 炮
- 关于破解百度文库的方法(非常实用)
- lvgl8.2 分析画面刷新
- 伺服驱动器方案,迈信ep100 成熟方案STM32源码
- 大众点评 java_大众点评评分爬取-图文识别ORC
- 推荐好用的临时邮箱工具,解决注册网站收到的垃圾邮件
- 微信无法绑定手机号的解决方案
- 《小岛经济学》八、金本位的破灭、房地产的泡沫
- 私藏多年的vscode插件分享,让你成为一个高效开发的程序员
- 为远程群晖NAS的自定义域名配置SSL证书
- iOS 3级滚动地址
- tomcat服务器一直自动关,项目在tomcat里运行一段时间总是自动崩掉的问题排查与解决...
- Face Attention Network: An Effective Face Detector for the Occluded Faces
热门文章
- KMP算法--字符串模式匹配算法
- 菜鸟学SQL注入 --- 一个简单的教学案例
- android getprop 分辨率,Android getprop 读取的属性哪里来的?
- SpringCloud教程- 服务链路追踪(Spring Cloud Sleuth)(SpringCloud版本Greenwich.SR4)
- Spring容器初始化和bean创建过程
- 设计模式-模板方法(Template Method Patten)
- 查看docker镜像的dockerfile脚本json信息
- hadoop win环境依赖winutils.exe等的gitee下载地址
- linux 生成随机数命令
- k8s插件说明:CoreDNS、Ingress Controller、Federation、Prometheus、ELK