I am working on a complex code that I have stumped myself on.
My program will control a sealed environments temperature and humidity for 4 "phases" lasting a total of 3 months. To start, it would gather a handful of setpoints from the user, including temperature setpoints for each phase, humidity setpoints for each phase and length of time for each of the 4 phases.
I need to be able to control the temperature and humidity as well as keep track of the elapsed time. I have read into the millis function but it resets after 70 something days which will not last long enough.
I would also like to record the variables from the environment and print out some averages for each phase at the end of the program.
I have some old code I started on this project but I am thinking I may have to scrap it as it does not work and is being "timed" using delays which has proved terrible. haha
Thank you in advance for any help as it is all greatly appreciated at this point!!
For that duration, you need an RTC. You will record when an event happens , in unix time format, and use unix time math to determine how long between two events.
Hey @PaulS Thanks for the quick reply. I purchased a RTC anticipating having to do this. When I record or read an event, where would I be writing this information to? External or internal memory? Any suggestions on where to find more information, other than a google search, regarding what your refering to as I am pretty new to arduino and have no idea how to code something like that?
For long term data logging you will absolutely need to write the data to an SD card (or some other medium) - don't rely on the Arduino being powered up for the three months you require. I have a simple YouTube video that describes all this, video #22 have a look, it will get you started.
There's another video #5 all about RTCs but you may have that covered already, I'm just adding it for completeness here.
I also cover temperature logging using multiple DS18B20 sensors (video #28) which you can get in a waterproof version too.
There may be other videos there that would assist you so take a look and consider subscribing too (it enables me to gauge interest in the Channel if nothing else). URL is in the footer of this post.
in a long runtime application like this, you also want to look at saving your operating variables to EEPROM regularly - but don't wear out the EEPROM! Maybe once per hour, or after a significant change in state/values...
This, along with the RTC capability may allow you to recover to the most recent state after a reset or power failure - without starting back at phase 1 again.
It would be a pity to run for three months then lose track of the cycle.
Also it may be prudent to name your SD log files with the date & time, so that any restarts don't write over earlier data logs.
@Ralph_S_Bacon Thank you so much, videos like yours were exactly what I was looking for. Surprised I didn't stumble across them in my youtube-ing already.
lastchancename:
in a long runtime application like this, you also want to look at saving your operating variables to EEPROM regularly - but don't wear out the EEPROM! Maybe once per hour, or after a significant change in state/values...
Is there an advantage to using eeprom over an sd card? Just started learning about EEPROM so its still a pretty wild crazy beast to me haha.
lastchancename:
It would be a pity to run for three months then lose track of the cycle.
Also it may be prudent to name your SD log files with the date & time, so that any restarts don't write over earlier data logs.
Thats a great idea, thank you. Yes running for 3 months and then restarting would be horrendous as this will be creating a food product. I am sure I will be posting coding questions once I get a little further in the code.
ZakAttack92: @Ralph_S_Bacon Thank you so much, videos like yours were exactly what I was looking for. Surprised I didn't stumble across them in my youtube-ing already.
ZakAttack92:
Is there an advantage to using eeprom over an sd card? Just started learning about EEPROM so its still a pretty wild crazy beast to me haha.
Not really, other than the EEPROM is already there, and 2GB is a lot of space to record maybe 200 bytes of operating state! Both have a finite number of write cycles.
Using the EEPROM library will be slightly less code for you to call, as you can save/restore data on a variable-by-variable basis.
ZakAttack92:
Thats a great idea, thank you. Yes running for 3 months and then restarting would be horrendous as this will be creating a food product. I am sure I will be posting coding questions once I get a little further in the code.
ZakAttack92: @Ralph_S_Bacon Thank you so much, videos like yours were exactly what I was looking for. Surprised I didn't stumble across them in my youtube-ing already.
I'm glad you found them useful - keep watching, new videos every week (not necessarily all on Arduino but certainly electronics & gadgets)
Is there an advantage to using eeprom over an sd card? Just started learning about EEPROM so its still a pretty wild crazy beast to me haha.
As @lastchancename has said, not really - except that you can easily go and change an SD card now and again to get the data logged so far (and ensure the environment doesn't render it unreadable in those 3 months). And if you implement that hardware change on the SD card I showed in the video then you can detect whether the SD card is present before you write so you won't lose any data.