B4R Code Snippet DS3231 Clock - Another Snippet

rodmcm

Active Member
Licensed User
This is a simple read and write with only 4 subroutines and no library

If of interest the ZS-042 module contains a DS3231 and on board I2C EEprom so you can get time and storage on one unit. See External EEPROM in the questions section for the latter ( though I must admit I haven't tried it on this module)
 

Attachments

Johan Schoeman

Expert
Licensed User
Hello @rodmcm

Nice project and working after a minor mod to the code of your project in post #2. Please just check - you are missing Saturday in your Daylist() array and your sample project sets the date to 31 April 2020 (April has 30 days).

B4X:
Public Daylist() As String = Array As String ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday")
B4X:
setDS3231Time(DS3231_I2Address,43,59,23,2,31,4,20)   'DS3231Address, seconds, minutes, hours, DOW, DOM, month, year
....only 4 subroutines and no library
It uses library rWire....?
 
Last edited:
hi.
I have a zs-042 and i can not understand how to use that.
your source code very good. I test it but this error appeared."Out of bounds error. Array length = 12, Index = 65535"
how to connect my zs-042 to arduino uno ?
 

Attachments

Last edited:

thetahsk

Active Member
Licensed User
Have you checked the I2C Address ,e.g with
 

Johan Schoeman

Expert
Licensed User
Have you checked the I2C Address ,e.g with
From Google it seems to be 0x68 - same as coded in the project in post #1
 

rodmcm

Active Member
Licensed User
Hi
Thanks for pointing out the error in the daylist. I can understand forgetting mondays, but not Saturdays!

As to the possibility of adding in a day that does not exist I am not sure about this
The DS3231 manual says "The date at the end of the month is automatically adjusted for months
with fewer than 31 days, including corrections for leap year
" but does not say whether the DS corrects this for entry. It would appear from your comment that it will accept it.
So possibly the user has to verify the date/day input

When I have a test rig up I will have a play

Libraries used are rWire and rCore
 
Hi
Thanks for pointing out the error in the daylist. I can understand forgetting mondays, but not Saturdays!

As to the possibility of adding in a day that does not exist I am not sure about this
The DS3231 manual says "The date at the end of the month is automatically adjusted for months
with fewer than 31 days, including corrections for leap year
" but does not say whether the DS corrects this for entry. It would appear from your comment that it will accept it.
So possibly the user has to verify the date/day input

When I have a test rig up I will have a play

Libraries used are rWire and rCore
thanks.
finaly last night i can use this module very hardly.
thanks again.
your #8 notes must be use on that.
nobody say that note.
 
Top