|
Forum Index : Microcontroller and PC projects : saving data to DS3231
| Author | Message | ||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
I am trying to save some data to the DS3231 RTC. The RTC module I am using has an EPROM on board. The code I am using is.. Function SAVETORTC(R$) Local X 'A local X variable, perhaps totally seperate from a global X For X=1 To 3 'Step through the three-byte date data, and save it to the RTC RAM RTC SETREG 50+X, Asc(Mid$(R$,X,1)) Next End Function Function READRTC$() Local X,B, R$ For X=1 To 3 RTC GETREG 50+X,B R$=R$+Chr$(B) Next READRTC$ = R$ End Function Courtesy of TassyJim I think. Then to retrieve to code Saved_Rain$ = READRTC$() Rain_Saved = Val(Saved_Rain$) and to send data to the EPROM x= SAVETORTC(R$) where R$ contains the data to save. The code is not working, has anyone successfully saved to the RTC? "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
It seems the DS3231 does not have SRAM like the DS3232. However my DS3231 module does have on board a AT24C32 EEPROM but I have no idea how to save to it. Maybe easier to get a DS3232 but they are expensive. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
It's all too hard so I have upgraded to an E-64 and will log to the SD card, much easier. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
I saw you have found a solution (the E-64). However, there is already some code for the DS3231: https://www.thebackshed.com/forum/forum_posts.asp?TID=6917&PN=1&TPN=2 The cheap DS1307 has The RTC, however, is not very precise. Regards Michael causality ≠ correlation ≠ coincidence |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
Thanks for that, might save me a lot of work, I haven't moved over to the E-64 yet, I will give it a try and report back. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2006 |
@ twofingers That works great, so easy, thanks very much. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
| Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1646 |
Twofingers, Great bit of code! One of the hidden gems on the TBS. It really ought to be in the Library - things like this are so hard to find later. Would you mind putting it in the Library? or I can do it on your behalf if you like. Bill Keep safe. Live long and prosper. |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
@Paul I am pleased to hear that! @Bill I would appreciate it if you could do it. I am not very familiar with the library. All of my code samples here in TBS are public domain. Best regards Michel causality ≠ correlation ≠ coincidence |
||||
| Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1646 |
Will do Michel, If there is anything else that you would like put in the Library please send me a link to it. Cheers Bill Keep safe. Live long and prosper. |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Thanks Bill! If you want, you can find most of my posts in my profile. I can not decide which posts are worth copying to the library. That's the job of the members here, when they find out that something is useful. Some code samples already exist in the library, others may need to be reworked. Greetings Michael causality ≠ correlation ≠ coincidence |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |