Zhang Yuexin

C# programmer. Know a bit of hardware knowledge. 3D model design novice.

张高兴 - 土味儿编程

高兴不高兴

张高兴的 Windows 10 IoT 开发笔记:RTC 时钟模块 DS3231

本文约 231 字,包含 1 张图片,4 个代码段,阅读时间约 1 分钟
QR Code

在手机上查看此页面


This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.

GitHub:https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/DS3231

Screenshot

Attention

No Alarm! No Alarm! No Alarm! Just read and set time.

Connect

  • SDA - Pin3
  • SCL - Pin5
  • VCC - 5V
  • GND - GND

Reference

https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/DS3231/Reference

What Contains

In DS3231.cs file

/// <summary>
/// Initialize the sensor
/// </summary>
/// <returns></returns>
public async Task InitializeAsync();
/// <summary>
/// Read Time from DS3231
/// </summary>
/// <returns>DS3231 Time</returns>
public DateTime ReadTime();
/// <summary>
/// Set DS3231 Time
/// </summary>
/// <param name="time">Time</param>
public void SetTime(DateTime time);
/// <summary>
/// Read DS3231 Temperature
/// </summary>
/// <returns></returns>
public double ReadTemperature();
/// <summary>
/// Cleanup
/// </summary>
public void Dispose();

How to Use

  • First, you need to create a DS3231 object. After that you should call InitializeAsync() to initialize.
DS3231 sensor = new DS3231();
await sensor.InitializeAsync();
  • Secondly
DateTime time = sensor.ReadTime();
double temp = sensor.ReadTemperature();
  • If you want to close the sensor, call Dispose().
sensor.Dispose();
最后更新时间 : 2017/05/19 21:21 张高兴 阅读(353) 评论(0)
文章标签: C# UWP IoT Raspberry Pi
  发表评论
Click to Refresh