Posts: 189
Joined: Wed Jan 02, 2013 8:28 am

[RTC] Access to RTC registers?

Tue Aug 14, 2018 9:49 am

Hi to all, I installed DS3231 RTC, enabled kernel modules and so on.
It works.
Taking a look to kernel module with lsmod, I saw it's loaded DS1307 module, where it can manage several RTC chips.
Now I need to access to DS3231 registers to set specific configuration for interrupt and square wave output.
Is there a way to access to RTC registers?
Using C or Python, I need to remove kernel driver before access to RTC, then reload driver.....
Is there different way?

Posts: 1
Joined: Wed Oct 03, 2018 9:36 am

Re: [RTC] Access to RTC registers?

Wed Oct 03, 2018 9:43 am

Good day! I'm also looking for a way to do this. I just installed DS3231 in my RPi 3 and it works but I'd like to generate a 1Hz square wave, and I can't find how to do it. Have you figured it out? Thank you!

Posts: 3431
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: [RTC] Access to RTC registers?

Wed Oct 03, 2018 11:26 am

I did a post on the french side about a python class I made for RTC. Use google translate if you don't speak french. ... 5#p1074313

If you want to access the RTC you need to remove the module

ex: I' using a mcp7940 which is very similar to the ds3231.

sudo rmmod rtc_ds1307 ===> Remove the driver fro the kernel if you want acces to it
python ===> Run My alarm. I think I do have the code to set the square wave in my python class
sudo modprobe rtc_ds1307 ===> Load back the module This has to be check. I'm just setting the alarm to boot and shutdown

It is possible that you need to set the correct address and i2c port after you reload the module.
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device ... rry-pi.pdf

Return to “Interfacing (DSI, CSI, I2C, etc.)”