Remarks

RTC
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Grove.RTCs.RTC

Code Example

RTC rtc;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");

    rtc = new RTC(Device.CreateI2cBus());

    return Task.CompletedTask;
}

public override Task Run()
{
    var running = rtc.IsRunning;

    Console.WriteLine($"{(running ? "is running" : "is not running")}");

    if (!running)
    {
        Console.WriteLine(" Starting RTC...");
        rtc.IsRunning = true;
    }

    var dateTime = rtc.GetTime();
    Console.WriteLine($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}");

    Console.WriteLine($" Setting RTC to : {dateTime:MM/dd/yy HH:mm:ss}");
    dateTime = new DateTime(2030, 2, 15);
    rtc.SetTime(dateTime);

    dateTime = rtc.GetTime();
    Console.WriteLine($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}");

    var rand = new Random();

    var data = new byte[56];

    for (int i = 0; i < 56; i++)
    {
        data[i] = (byte)rand.Next(256);
    }

    Console.WriteLine($" Writing to RTC RAM   : {BitConverter.ToString(data)}");
    rtc.WriteRAM(0, data);
    Console.Write($" Reading from RTC RAM : ");
    data = rtc.ReadRAM(0, 56);
    Console.WriteLine(BitConverter.ToString(data));

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

RTC Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00
Characteristic Locus
Inheritance System.Object Ds1307 > RTC
Inherited Members Ds1307.IsRunning Ds1307.GetTime() Ds1307.SetTime(DateTime) Ds1307.ReadRAM(Int32, Int32) Ds1307.WriteRAM(Int32, Byte[]) Ds1307.SquareWaveOutput(Ds1307.SquareWaveFrequency)
Namespace Meadow.Foundation.Grove.RTCs
Assembly RTC.dll

Syntax

public class RTC : Ds1307

Constructors

RTC(II2cBus)

Creates an RTC driver

Declaration
public RTC(II2cBus bus)

Parameters

Type Name Description
II2cBus bus