orangepi 香橙派-实时时钟模块使用DS1307/DS3231/PCF8563

香橙派断电后,不带电池,所以时间也没法保持,需要增加模块进行时间处理

支持三种模块

DS1307/DS3231/PCF8563

在某宝上面可以买到

orangepi 香橙派-实时时钟模块使用DS1307/DS3231/PCF8563_第1张图片

例子

I2cConnectionSettings settings = new I2cConnectionSettings(1, Ds1307.DefaultI2cAddress);
I2cDevice device = I2cDevice.Create(settings);

using (Ds1307 rtc = new Ds1307(device))
{
    // set DS1307 time ,设置时间
    rtc.DateTime = DateTime.Now;

    // loop
    while (true)
    {
        // read time 读取时间
        DateTime dt = rtc.DateTime;

        Console.WriteLine($"Time: {dt.ToString("yyyy/MM/dd HH:mm:ss")}");
        Console.WriteLine();

        // wait for a second
        Thread.Sleep(1000);
    }
}

官方:https://github.com/dotnet/iot/blob/main/src/devices/Rtc/README.md

你可能感兴趣的:(传感器,香橙派,c#,c#,香橙派)