DS3231 Alarm Event Triggers on RPi

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
iamblackrabbit
 
Posts: 1
Joined: Sun Mar 20, 2022 5:43 pm

DS3231 Alarm Event Triggers on RPi

Post by iamblackrabbit »

Hiya, so I read through the clocks section and only found one post similar to my question so I am going to post this and hope for the best.
I have installed the DS3231 RTC breakout as per the instructions on the Learn section of Adafruit on a Rpi B+. However, after completing the final steps I was left a little bit hanging in that accessing the built-in functions such as the alarm triggers nor reading or controlling the output from the 32k SQW were not covered.
My current needs are a high-accuracy event trigger so I have used some other tutorials to sync my board with the PPS-GPS time and chrony which so far seems to be working:
trigger@gpstrigger:~ $ timedatectl
Local time: Sun 2022-03-20 21:53:18 GMT
Universal time: Sun 2022-03-20 21:53:18 UTC
RTC time: Sun 2022-03-20 21:53:18
Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
NTP service: inactive
RTC in local TZ: no
trigger@gpstrigger:~ $ chronyc tracking
Reference ID : 50505300 (PPS)
Stratum : 1
Ref time (UTC) : Sun Mar 20 21:54:03 2022
System time : 0.000000077 seconds slow of NTP time
Last offset : -0.000000091 seconds
RMS offset : 0.000717191 seconds
Frequency : 4.979 ppm fast
Residual freq : -0.000 ppm
Skew : 0.001 ppm
Root delay : 0.000000001 seconds
Root dispersion : 0.000022166 seconds
Update interval : 16.0 seconds
Leap status : Normal
trigger@gpstrigger:~ $ chronyc sources
210 Number of sources = 11
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#x NMEA 0 4 377 17 +132ms[ +132ms] +/- 68ms
#* PPS 0 4 377 17 -1927ns[-2309ns] +/- 237ns
^- time-a-b.nist.gov 1 7 377 48 +5128us[+5128us] +/- 69ms
^- time-d-b.nist.gov 1 6 377 56 -2830us[-2830us] +/- 66ms
My events need to be triggered off of GPS timing preferably -0ms/+100us and IMHO setting a hardware clock to do the triggering is preferable to having a program looping to compare datetimes. Wouldn't catching a GPIO going high/low since they are already polled about every 5us make more sense?
I have tried to read the memory registers of the chip using smbus but I am currently getting
OSError: [Errno 16] Device or resource busy
which I thought was a bit wierd.

Does anyone have any thoughts on how to communicate with the RTC to make use of the in-built functions such as alarms and the like?
System Information
------------------

Raspberry Pi 3 Model B Plus Rev 1.3
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: DS3231 Alarm Event Triggers on RPi

Post by adafruit_support_mike »

The "Device or resource busy" error usually means you don't have permission to use the connected device. Try running the command with `sudo`, or make sure your user account is part of the 'i2c' group.

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”