SPRING SALE up to 20% OFF! (excludes trade customers)  •  FREE Standard Delivery for orders over £35 (ex VAT)
Knowledge Base

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

Knowledge Base

RTC Pi C Library

RTC Pi C Library Installation and Usage

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

YOU WILL NEED THIS BOARD

121 available
Order a RTC Pi Photo of RTC Pi

RTC Pi

Real time clock for the Raspberry Pi and Single-Board Computers

£7.59 ex VAT

View Product

C Library to use with RTC Pi Raspberry Pi development board.

The example C programs can be found in /ABElectronics_C_Libraries/RTCPi/demos

Downloading and Installing the library

To download to your Raspberry Pi type in the terminal:

git clone https://github.com/abelectronicsuk/ABElectronics_C_Libraries.git

Functions

rtc_set_date(struct tm date)

Set the date on the RTC
Parameter: (struct tm) date - struct tm formatted date and time
Returns: null


rtc_read_date()

Read the date from the RTC.
Returns: (struct tm) date as a tm struct


rtc_enable_output()

Enable the squarewave output pin
Returns: null


rtc_disable_output()

Disable the squarewave output pin
Returns: null


rtc_set_frequency(uint8_t frequency)

Set the square wave output frequency
Parameter: (uint8_t) frequency - 1 = 1Hz, 2 = 4.096KHz, 3 = 8.192KHz, 4 = 32.768KHz
Returns: null


rtc_write_memory(uint8_t address, uint8_t valuearray[])

Write to the memory on the ds1307.
The DS1307 contains a 56-byte, battery-backed RAM with unlimited writes.
Parameter: (uint8_t) address - 0x08 to 0x3F
Parameter: (uint8_t[]) valuearray - byte array containing data to be written to memory
Returns: null


rtc_read_memory(uint8_t address, uint8_t length)

Read from the memory on the ds1307
The DS1307 contains a 56-byte, battery-backed RAM with unlimited writes.
Parameter: (uint8_t) address - 0x08 to 0x3F
Parameter: (uint8_t) length - up to 32 bytes. length can not exceed the available address space.
Returns: (uint8_t *) pointer to a byte array where the data will be saved


Also useful for your Raspberry Pi project

Temperature & Sensing

1 Wire Pi Plus

Connect dozens of 1-Wire sensors - temperature, iButtons, EEPROMs - via a single GPIO pin. Stacks directly on the 40-pin header.

£9.59 ex VAT

Analogue I/O

ADC Pi

Read up to 8 analogue inputs - perfect for pairing with your temperature sensors or other analogue-output devices.

£14.39 ex VAT

All-in-one

Expander Pi

Combines ADC, DAC, 32 GPIO ports and a real-time clock on one board. The most versatile board for complex Raspberry Pi projects.

£15.99 ex VAT

Order these Boards

All boards are designed & manufactured in the UK with RoHS-compliant components.

Home

Shop

Learn

Forum

FAQ

Contact