欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > windows >内容正文

windows

树莓派4b——设置DS3231模块 并从DS3231模块读取系统时间

发布时间:2024/1/1 windows 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 树莓派4b——设置DS3231模块 并从DS3231模块读取系统时间 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

文章目录

    • 1. 驱动下载及安装
    • 2. 设置时间
    • 3. 时间测试
    • 4. 其他功能
    • 参考


  网上有蛮多关于ds3231模块用法的介绍,但是我在树莓派4B上测试的时候,基本上都用不了。折腾了四五个小时,下面分享下自己探索出来的方法。

主要功能:将DS3231设置成为树莓派的系统时钟,树莓派不联网的情况下,可以自动从DS3231获取系统时间。

1. 驱动下载及安装

下载DS3231模块的驱动

git clone https://github.com/Seeed-Studio/pi-hats.git cd pi-hats/CAN-HAT

安装驱动

sudo ./install.sh -u rtc_ds3231

重启电脑

sudo shutdown -h now

2. 设置时间

将时间设置为 2020年 10月1日 20点35分

date 100120352020.00 备注:10120352020

3. 时间测试

date

4. 其他功能

读取硬件时钟并打印结果

sudo hwclock -r

通过硬件时钟设置系统时间

sudo hwclock -s

从当前系统时间设置硬件时钟

sudo hwclock -w

访问帮助以获得更多用途

hwclock --help

参考

  • https://www.seeedstudio.com/blog/2020/07/07/raspberry-pi-rtc-tutorial-using-ds1307-and-ds3231-rtcs-with-raspberry-pi-m/

  • https://shumeipai.nxez.com/2019/05/08/raspberry-pi-configuration-of-ds3231-clock-module-i2c-interface.html

总结

以上是生活随笔为你收集整理的树莓派4b——设置DS3231模块 并从DS3231模块读取系统时间的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。