Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

DS3231 RTC

Note: Espruino contains its own RTC, but it requires to solder in a 32kHz watch crystal. It's easy to solder watch crystal onto espruino board but it gets complicated with espruino pico. A good alternative is to buy cheap DS3231 RTC module, moreover it provides battery back-up, calendar functionality and up to 10 times better accuracy.

This document assumes that you are using one of cheap RTC modules for Raspberry PI. (should work as well with other DS3231 modules)

DS3231 RTC module

Espruino DS3231 module
3V3 +
B7 (SDA) D
B6 (SCL) C
Not connected NC

Note: DS3231 module has soldered pull up resistors. However if you get an error: Uncaught InternalError: Timeout on I2C Write BUSY it may be caused by too low pull up value, in this case it's necessary to solder 4.7k-10k resistor onto it.

Note: This module is designed to be compatible with the JS date object

properity value
miliseconds 0-999
seconds 0-59
minutes 0-59
hours 0-23
day of the month (date) 1-31
month 0-11
day of the week 0-6
year eg: 2017


Initialise the module by calling require("DS3231").connect, passing in an I2C interface.

pull a module right off github (not minified):

I2C1.setup({scl: B6,sda: B7});
var rtc = require("").connect(I2C1);

or from local folder

I2C1.setup({scl: B6,sda: B7});
var rtc = require("DS3231").connect(I2C1);

Daylight saving

I belivie daylight saving should not be handled in this module.

Setting Date/Time/Dow

To set the date:

// 1st January 2017

To set the time:

// 22:59

To set day of the week:

// Sunday (or Monday if it's 1st day of the week for you)

Reading Date/Time/Dow

To read Date/Time as a JS date object and print to the console:

var t = rtc.readDateTime();

Reading single properity:

// can be "hours", "minutes", "dow", "date", "month", "year"


Reads from rtc module and prints to the console every second:

I2C1.setup({scl: B6,sda: B7});
var rtc = require("").connect(I2C1);

setInterval(function() {
}, 1000);
You can’t perform that action at this time.