Real-time clock DS3231 with TinkerPie
A clock with a coin battery: alarms, timers, data logging.
| Type | Smart sensors (I2C) |
|---|---|
| Connect to | SENSOR port · 0x68 |
| Gives | time and date, kept by its battery |
| Simulator | Yes: a control appears under the simulated board |
How it works
The DS3231 is a real-time clock: it keeps counting seconds, minutes, hours and dates even when the board is off, using a coin cell. Its crystal is temperature-compensated, so it drifts only about a minute a year.
How to wire it
Plug into any SENSOR 1-4 port (SDA, SCL, 3.3 V, GND). Each type has a fixed I2C address, so different types can share the bus.
Code
In blocks: Accessories category in TinkerPie Studio. As code:
// JavaScript
clock.hour()
clock.minute()
clock.set(2026, 10, 13, 9, 30, 0)
// Arduino C++
clock::hour()
clock::minute()
clock::set(2026, 10, 13, 9, 30, 0) Good to know
- Uses I2C (address 0x68) and a CR2032 coin cell.
- Has two alarms and also measures its own temperature.
- Set the time once from the computer, then it keeps it.
Projects with the Real-time clock DS3231
Similar modules
- Light meter BH1750
- Temperature + humidity AHT20
- Temperature + humidity SHT31
- Motion sensor MPU6050
- Colour sensor TCS34725
- IR thermometer MLX90614
- 4-channel ADC ADS1115
- Current + voltage sensor INA219
Questions
Can I try the Real-time clock DS3231 without buying one?
Yes. In TinkerPie Studio the simulator shows a control for it under the board, so you can test your program before you build it.
Why do I need a clock module if the board has Wi-Fi?
Without Wi-Fi the board forgets the time when it restarts. The DS3231 keeps the right time on battery, which is perfect for timers, alarms and data loggers.