Dec 6, 2018 Replies: 8 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 DS3231.zip DS3231.zip 1.7 KB · Views: 970 Click to expand...
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)
R rodmcm Active Member Licensed User Longtime User Dec 8, 2018 #2 Added Unix timestamp GMT Attachments DS3231-Unix.zip DS3231-Unix.zip 2 KB · Views: 930
Johan Schoeman Expert Licensed User Longtime User Jan 12, 2020 #3 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 Click to expand... It uses library rWire....? Last edited: Jan 12, 2020
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 Click to expand... It uses library rWire....?
vali khandangoll Active Member Jan 24, 2020 #4 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 ds3231 error.jpg 477.2 KB · Views: 778 Last edited: Jan 24, 2020
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 ?
thetahsk Active Member Licensed User Longtime User Jan 24, 2020 #5 Have you checked the I2C Address ,e.g with I2C Address Scanner Snippet to scan for I2C (Inter-Integrated Circuit) devices. Helpful to obtain the connected I2C device(s) address. The address range is 0 and 127. Reference. Libraries: rWire, rRandomAccessFile Example output Scanning started... I2C device found at address: 0x76 (118) Scanning completed... www.b4x.com
Have you checked the I2C Address ,e.g with I2C Address Scanner Snippet to scan for I2C (Inter-Integrated Circuit) devices. Helpful to obtain the connected I2C device(s) address. The address range is 0 and 127. Reference. Libraries: rWire, rRandomAccessFile Example output Scanning started... I2C device found at address: 0x76 (118) Scanning completed... www.b4x.com
Johan Schoeman Expert Licensed User Longtime User Jan 24, 2020 #6 SDA on the ZS-042 should go to Uno A4 SCL on the ZS-042 should go to Uno A5
Johan Schoeman Expert Licensed User Longtime User Jan 24, 2020 #7 thetahsk said: Have you checked the I2C Address ,e.g with I2C Address Scanner Snippet to scan for I2C (Inter-Integrated Circuit) devices. Helpful to obtain the connected I2C device(s) address. The address range is 0 and 127. Reference. Libraries: rWire, rRandomAccessFile Example output Scanning started... I2C device found at address: 0x76 (118) Scanning completed... www.b4x.com Click to expand... From Google it seems to be 0x68 - same as coded in the project in post #1
thetahsk said: Have you checked the I2C Address ,e.g with I2C Address Scanner Snippet to scan for I2C (Inter-Integrated Circuit) devices. Helpful to obtain the connected I2C device(s) address. The address range is 0 and 127. Reference. Libraries: rWire, rRandomAccessFile Example output Scanning started... I2C device found at address: 0x76 (118) Scanning completed... www.b4x.com Click to expand... From Google it seems to be 0x68 - same as coded in the project in post #1
R rodmcm Active Member Licensed User Longtime User Jan 25, 2020 #8 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
vali khandangoll Active Member Jan 25, 2020 #9 rodmcm said: 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 Click to expand... 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.
rodmcm said: 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 Click to expand... 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.