Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

Knowledge Base

RTC Pi .Net Core Library

RTC Pi .Net Core Library code and demos

Created 29/07/2024 | Last Updated: 30/07/2024

.Net Core Library to use with the RTC Pi, RTC Pi Plus and RTC Pi Zero Raspberry Pi development boards.

Downloading and Installing the .Net Core Libraries

Download the zip archive containing the code demos and libaries from GitHub.

RTC Pi Methods

Connect() 

Connect to the I2C device
Parameters: none
Returns: null

IsConnected() 

Check if the device is connected
Parameters: none
Returns: boolean

Dispose() 

Dispose of the active I2C device
Parameters: none
Returns: null

ReadMemory(byte address, byte length)

Read from the memory on the DS1307. Memory range is 0x08 to 0x3F.
Parameters: address - First memory address where the values with be read.
length - Number of bytes to read from memory.
Returns: byte[] - Byte array containing read memory values.

WriteMemory(byte address, byte[] values)

Write to the SRAM memory on the DS1307. Memory range is 0x08 to 0x3F.
Parameters: address - First memory address where the values with be written. values - Byte array containing values to be written to memory. Array length can not exceed the memory space available. Returns: null

RTC Pi Parameters

DateTime Date { get; set; }

Set or get the date and time from the RTC.
Takes a DateTime variable.
Returns: DateTime

byte Frequency { get; set; }

Get or set the frequency of the output pin square wave.
Options are: 1 = 1Hz, 2 = 4.096KHz, 3 = 8.192KHz, 4 = 32.768KHz

bool Output { get; set; }

Enable or disable the square wave output on the SQW pin.
Set output as true or false. Gets output state as true or false.

RTC Pi Usage

To use the RTC Pi library in your code you must first import the library DLL:

using ABElectronicsUK;

Next, you must initialise the rtc class:

ABElectronicsUK.RTCPi rtc = new ABElectronicsUK.RTCPi();

Next, we need to connect to the device and wait for the connection

rtc.Connect();

while (!rtc.IsConnected)
{
}

You can set the date and time from the RTC chip to be the 25th of December 2015 at 6 AM with:

DateTime newdate = new DateTime(2015, 12, 25, 06, 00, 00);
rtc.Date = newdate;

You can read the date and time from the RTC chip with:

DateTime value = rtc.Date;

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout