[chbot] No-code weather-station to web dashboard

Robin Gilks gb7ipd at gmail.com
Thu May 5 13:36:13 BST 2022


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.

int16_t rain_mins[60];
int16_t rain_hours[24];
int16_t rain1h;                 /* rain in last hour */
int16_t rain24h;                /* rain in last day */
int16_t gRain;

// keep a history of raw total rainfall over 1 hour and 1 day
// so that actuals can be calculated when required.
static void
update_rain (void)
{
   RT_t calendartime;

   ReadDateTime (&calendartime);

   rain_mins[calendartime.min] = gRain;
   rain_hours[calendartime.hour] = gRain;
   // allow for wraparound of data from remote
   rain1h = (gRain + 4096 - rain_mins[(calendartime.min + 1) % 60]) % 4096;
   rain24h = (gRain + 4096 - rain_hours[(calendartime.hour + 1) % 24]) %
4096;
}

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

https://github.com/g8ecj/bertos/blob/all/boards/arduino/examples/arduino_WxRx/main.c

-- 
Robin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20220506/84f657a8/attachment-0001.html>


More information about the Chchrobotics mailing list