Datasheet

CircuitPython
It's easy to use the DS3231 RTC with CircuitPython too! There's a handy Adafruit CircuitPython DS3231 module you
can load on a board and get started setting and reading the time with Python code!
First wire up the DS3231 to your board as shown on the previous Arduino page. The DS3231 uses a simple I2C
connection with:
Vin connected to your board's 3.3V or 5V output.
GND connected to your board's ground.
SCL connected to your board's I2C SCL / clock line.
SDA connected to your board's I2C SDA / data line.
You'll also need to install the Adafruit CircuitPython DS3231 library on your CircuitPython board. Remember this
module is for Adafruit CircuitPython firmware and not MicroPython.org firmware!
First make sure you are running the latest version of Adafruit CircuitPython for your board.
Next you'll need to install the necessary libraries to use the hardware--carefully follow the steps to find and install these
libraries from Adafruit's CircuitPython library bundle. For example the Circuit Playground Express guide has a great
page on how to install the library bundle for both express and non-express boards.
Remember for non-express boards like the Trinket M0, Gemma M0, and Feather/Metro M0 basic you'll need to
manually install the necessary libraries from the bundle:
adafruit_ds3231.mpy
adafruit_bus_device
adafruit_register
Before continuing make sure your board's lib folder or root filesystem has the adafruit_ds3231.mpy,
adafruit_bus_device, and adafruit_register files and folders copied over.
Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.
Then import the necessary board and busio modules to initialize the I2C bus:
Note on some boards like the ESP8266 that don't have a hardware I2C interface you might need to instead import and
use the bitbangio module, like:
Now import the DS3231 module and create an instance of the DS3231 class using the I2C interface created above:
import board
import busio
i2c = busio.I2C(board.SCL, board.SDA)
import board
import bitbangio
i2c = bitbangio.I2C(board.SCL, board.SDA)
© Adafruit Industries https://learn.adafruit.com/adafruit-ds3231-precision-rtc-breakout Page 17 of 22