<div dir="ltr"><div dir="ltr">Here is a simple rainfall totalling function that works for me (global vars for clarity!!) - it handles the 12 bit rain data my system produces.<div><br></div><div>int16_t rain_mins[60];<br>int16_t rain_hours[24];<br>int16_t rain1h;                 /* rain in last hour */<br>int16_t rain24h;                /* rain in last day */<br>int16_t gRain;<br></div><div><br></div><div>// keep a history of raw total rainfall over 1 hour and 1 day <br>// so that actuals can be calculated when required.<br>static void<br>update_rain (void)<br>{<br>   RT_t calendartime;<br><br>   ReadDateTime (&calendartime);<br><br>   rain_mins[calendartime.min] = gRain;<br>   rain_hours[calendartime.hour] = gRain;<br>   // allow for wraparound of data from remote<br>   rain1h = (gRain + 4096 - rain_mins[(calendartime.min + 1) % 60]) % 4096;<br>   rain24h = (gRain + 4096 - rain_hours[(calendartime.hour + 1) % 24]) % 4096;<br>}<br></div><div><br></div><div>The rest (of the really old arduino code) can be found on my github page - this is extracted from a later port to stm32F1/F4</div><div> <a href="https://github.com/g8ecj/bertos/blob/all/boards/arduino/examples/arduino_WxRx/main.c">https://github.com/g8ecj/bertos/blob/all/boards/arduino/examples/arduino_WxRx/main.c</a></div><div><br></div><div>-- </div><div>Robin</div><div><br></div></div></div>