Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Reply To: Recording data from pressure sensors on an SD card

Home Forums Mayfly Data Logger Recording data from pressure sensors on an SD card Reply To: Recording data from pressure sensors on an SD card

#2195
Shannon Hicks
Moderator

    The first couple things that stand out are this:

    You don’t have to say “Serial.begin(9600)” more than once in your sketch. Just do it once near the beginning of your setup() function and that’s it.

    You don’t have to set the date and time of the RTC every time you run the sketch. The way it is written in your examples means that the clock gets programmed with that prewritten date/time every time the board boots up, which is definitely not something you ever want to do. If you’re using a Mayfly (or any real-time-clock) module with a battery backup (the little silver watch-battery), then your RTC will remember the correct date and time for many years, so you only need to set that time once using a standalone sketch like the “Adjust” example sketch with the SODAQ_DS3231 library. Once the clock is set, you can remove all of the lines in your logger sketches that were essentially re-setting it each time. So in the above sketch, remove lines 11, 16, and 41.

    I’ll see if I can add the code for SD functionality to the second sketch you posted and attempt to compile it on my computer.