Is there a package or library for controlling the DS3231 on the Raspberry Pi

Ask QuestionAsked todayActive todayViewed 7 times1

I’ve just obtained a DS3231 real time clock (RTC), and added it to my RPi 3b. It seems to work as far as keeping time, but I wanted more.

I’d like to be able to set alarms to trigger the INT/SQW pin on the chip, but I’ve been unable to find any way to do that with the toolset in RPi. I’ve probably overlooked something – how should I go about this?packagesrtctimekeepingshared-librariesds3231ShareEditFollowCloseFlagasked 4 hours agoSeamus12k22 gold badges1515 silver badges3535 bronze badges

  • I played with DS3231 some three years ago. I found the drivers around then had too limited, (and only minimal functions like many other drivers). So I DIYed my own python library. Fast forward 3 years, now I am playing with Pico and plan to port my old package such as MCP23017, ADS1115 etc to Pico. In case you and other newbie readers are interested to know me the hobbyist developer learned how to do the job, I am writing an answer below. Comments and counter suggestions welcome. Cheers. – tlfong01 32 mins ago   
  • I remember 3 years ago the DT3231 libraries then were written in C/C++, me python guy found it hard to append more functions. But if you can now find any python package and wish to add more functions, my little DIY functions and design notes might help you modify any existing python or C/C++ packages. – tlfong01 17 mins ago   Edit   

Add a comment

1 Answer



How to write a Rpi4B/Pico Thonny Python program to talk to the DS3231 RTC (Real Time Clock) to do things such as the following:

  1. Detect interrupts,
  2. Trigger on chip square wave signals.


  1. I have searched my 3 year old posts (over 50) in rpi.org.forum to refresh my memory on how I messed around with DS3231, listening to its interrupts, and program/trigger the on chip 32kHz square signals etc.
  2. My old posts are messily scattered in a couple of forums and intermingled with other I2C devices such as MCP23017 IOX and ADS1115 ADC. Porting to Pico is a good opportunity for me to tidy them up.

/ to continue, …


(1) Search query: DS3231 tlfong01 Record – found 54 matches

(2) Python Program to Ping DS3231 and MCP23017

(3) DS3231 Python Programming Code

(4) DS3231 python Write Register Example

(5) DS3231 Old Posts Reference Links

(6) DS3231 i2cdetect record

(7) DS3231 driver vs dit programming

(8) DS3231 read register functions

(9) DS3231 Set alarm etc

(10) DS3231 python programming design notes

(11) DS3231 python programming design notes

(12) DS3231 python programming design notes

(13) DS3232 Square Wave Setup

/ to continue, …


/ to continue, …

ShareEditDeleteFlagedited 8 secs agoanswered 22 mins agotlfong013,62133 gold badges77 silver badges2222 bronze badgesAdd a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.