I guess it depends on what you’re trying to achieve. As I said before, I want to see rainfall in millimetres over various time periods - the last minute, rolling 60 minutes, rolling 24 Hours etc.
For that reason I use arrays and write the values into the arrays. Take the rolling 60 minute total as an example of how I do this…
I use a variable to store the rolling 60 minute total and a pointer to tell me which array element to write into.
Once I’ve run for 1 hour, all the array element are populated with data and I have a value for the total rainfall in the past 60 minutes. My pointer tells me I’m going to write the next minute’s worth of data into the first array element (position 0). First I read the value that’s stored in that location and deduct it from my 60 minute rolling total. I then add the latest 1 minute value to my rolling total, and write that value into the position that my pointer points to (position 0).
This way, my rolling total always shows me how much rain has fallen in the past 60 minutes. I don’t have to keep resetting the value, it automatically does it for me.
After one hour (when my pointer says it’s at position 59) I write the 60 minute rolling total value into the 24 hour rolling total array.
If I wanted to I could keep cascading his and keep weekly, monthly and annual rolling totals (I don’t by the way).
Your code just keeps counting and it seems that the only way of zeroing the total is to reset the MCU.
Also, you seem to have some part-implemented DHT22 pressure/humidity sensor code kicking around in your sketch. If you plan to run this at the same time then be careful how often you interrogate the DHT22 sensor they don’t like to be read more frequently than every 5 or 10 seconds. If you’re not planning to use this code then you should delete it from your sketch.
At the end of the day it depends on what you’re trying to achieve with your rainfall statistics and you’ve not shared that vision yet.
Pete.