B4R Question help me about zs-042 rtc clock module

Hi all of you.
I have a zs-042 clock module like below.
I could find a library with name ds3231.h and i convert that to xml .
but I can not use that.
please help me with a very simple example.
zs-042 picture and ds3231.xml file attached to this post on below.


Johan Schoeman

Licensed User
You will need to create a wrapper for it - not just the xml. There is a B4R code snippet that you can use to set and read the time from a DS3231 RTC. It uses the wire library. Just search the B4R forum.

Last edited:

Johan Schoeman

Licensed User
Just for interest sake - see if this project will read from your ZS-042 RTC (it does not require any library other than the B4R core library - the control of the SDA and SCL pins are all hard coded in the B4R project and you can therefore use any two digital configured pins as long as what you assign them correctly in the B4R code)

You need to connect the SDA pin of the ZS-042 to pin 10 of your Uno
You need to connect the SCL pin of the ZS-042 to pin 11 of your Uno

Check the code - you can connect it to any 2 digital configured pins for eg:

    Dim pdatNo As Byte = pdat.A4                  'pin A4 on the Nano is the default pin for the I2C data line
    Dim pclkNo As Byte = pclk.A5                  'pin A5 on the Nano is the default pin for the I2C clock line
It should hopefully log something like this in the B4R log:


Note that although the default address is suppose to be 0x68 it is based on a 7 bit address. For a "write to" and a "read from" the DS3231 chip the 8 bit addresses actually become:
0xD0 = write
0XD1 = read

The 0x68 "7 bit" address shifts 1 bit to the left and for a write the LSB becomes 0 (i.e the 8 bit address changes to 0xD0) and for a read the LSB becomes a 1 (i.e the 8 bit address becomes 0xD1).
Last edited: