Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:53 12 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : saving data to DS3231

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 12:45am 07 Apr 2019
Copy link to clipboard 
Print this post

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: Australia
Posts: 2006
Posted: 05:34am 07 Apr 2019
Copy link to clipboard 
Print this post

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.Edited by palcal 2019-04-08
"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: Australia
Posts: 2006
Posted: 07:07am 07 Apr 2019
Copy link to clipboard 
Print this post

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: Germany
Posts: 1671
Posted: 09:21am 07 Apr 2019
Copy link to clipboard 
Print this post

  palcal said  The code is not working, has anyone successfully saved to the RTC?


  palcal said  However my DS3231 module does have on board a AT24C32 EEPROM but I have no idea how to save to it.


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
  Quote   56-byte, battery-backed, nonvolatile (NV) RAM for data storage
The RTC, however, is not very precise.

Regards Michael
causality ≠ correlation ≠ coincidence
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 08:21pm 07 Apr 2019
Copy link to clipboard 
Print this post

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: Australia
Posts: 2006
Posted: 10:11pm 07 Apr 2019
Copy link to clipboard 
Print this post

@ 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: Australia
Posts: 1646
Posted: 04:32am 08 Apr 2019
Copy link to clipboard 
Print this post

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: Germany
Posts: 1671
Posted: 09:06am 08 Apr 2019
Copy link to clipboard 
Print this post

@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: Australia
Posts: 1646
Posted: 10:03am 08 Apr 2019
Copy link to clipboard 
Print this post

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: Germany
Posts: 1671
Posted: 11:15am 08 Apr 2019
Copy link to clipboard 
Print this post

  Quote  Will do Michel,

Thanks Bill!
  Quote  If there is anything else that you would like put in the Library please send me a link to it.

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
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025