/*Auswertung Regenmengensensor mit Regenwippe- Counter kann durch reed-Kontakt oder Hallsensor erfolgen- i2c eeprom AT24C256- i2c Adresse EEPROM (default: 0x50)*/#include <Wire.h>//#include <I2C_EEPROM.h>#//include <avr/eeprom.h>/********************************************//* PIN-Section *//* Hier Sensor-Pins definieren *//********************************************///#define RAIN_COUNT_PIN 7#define RAIN_COUNT_PIN 30/********************************************//* Variablen-Section *//********************************************/long lastSecond; // Original - The millis counter to see when a second rolls byunsigned int minutesSinceLastReset; //Used to reset variables after 24 hours. Imp should tell us when it's midnight, this is backup.byte secondsRain; //When it hits 60, increase the current minutebyte minutesRain; //Keeps track of where we are in various arrays of data
volatile float rainHour[60]; //60 floating numbers to keep track of 60 minutes of rainvolatile unsigned long raintime, rainlast, raininterval, rain;volatile unsigned long last_micros1;long debouncing_time1 = 3; // in millis -> eleminiert evtl REED-Kontakt-Prellenboolean RainTimeReset = false;
//struct Configuration//{// float regenTag;// float regenStunde;//}eepconfig EEMEM;
//AT24C256<0x50> eep; // Das EEProm auf der china üblichen RTC3231
/********************************************//* Interrupt-Section *//********************************************/void rainIRQ(unsigned long now){ if((long)(micros() - last_micros1) >= debouncing_time1 * 1000) { rainToday += 0.1618; // Each dump is 0.1618mm of water rainHour[minutesRain] += 0.1618; // Increase this minute's amount of rain last_micros1 = micros(); }}
/********************************************//* Setup-Section *//********************************************/void setupRain(unsigned long now){ Serial.begin(115200); Wire.begin();#ifdef DEBUG_WS Serial.println("rain gauge online!");#endif// if(eep.ready()){// eep.get(eepconfig.regenTag,rainToday);//#ifdef DEBUG_WS// Serial.print("EEPROM rainToday : ");// Serial.println(rainToday);//#endif// }// else// { midnightReset(now); //Reset rain totals secondsRain = 0; lastSecond = now;// } rainLastHour = 0; pinMode(RAIN_COUNT_PIN, INPUT_PULLUP); attachInterrupt(RAIN_COUNT_PIN, rainIRQ, RISING);
reportWeather();}
/********************************************//* Loop-Section *//********************************************/void loopRain(unsigned long now){ //Keep track of which minute it is if(now - lastSecond >= 1000) { lastSecond += 1000;
reportWeather(); //Print the current readings. Takes 172ms.
//If we roll over 60 seconds then update the arrays for rain if(++secondsRain > 59) { secondsRain = 0;
if(++minutesRain > 59) minutesRain = 0; rainHour[minutesRain] = 0; //Zero out this minute's rainfall amount
minutesSinceLastReset++; //It's been another minute since last night's midnight reset } }
if((TimeStunde == 0) && (! RainTimeReset)) { midnightReset(now); //Reset a bunch of variables like rain and daily total rain RainTimeReset = true; } else if((TimeStunde != 0) && (RainTimeReset)) { RainTimeReset = false; }
//If we go for more than 24 hours without a midnight reset then force a reset //24 hours * 60 mins/hr = 1,440 minutes + 10 extra minutes. We hope that Imp is doing it. if(minutesSinceLastReset > (1440 + 10)) { midnightReset(now); //Reset a bunch of variables like rain and daily total rain }}
//When the imp tells us it's midnight, reset the total amount of rain and gustsvoid midnightReset(unsigned long now){ rainToday = 0; //Reset daily amount of rain// if(eep.ready()){// eep.put(eepconfig.regenTag,rainToday);// } minutesRain = 0; //Reset minute tracker secondsRain = 0; lastSecond = now; //Reset variable used to track minutes
minutesSinceLastReset = 0; //Zero out the backup midnight reset variable}
void calcWeather(){ rainLastHour = 0; for(int i = 0 ; i < 60 ; i++) rainLastHour += rainHour[i];}
void reportWeather(){ calcWeather(); //Go calc all the various sensors#ifdef INFO_WS Serial.print("rainLastHour : "); Serial.print(rainLastHour, 2); Serial.print(" , rainToday : "); Serial.println(rainToday, 2);#endif// if(eep.ready()){// eep.put(eepconfig.regenStunde,rainLastHour); //Nicht nutzen// eep.put(eepconfig.regenTag,rainToday);// }}outTemp=43.8outHumidity=74.7pressure=29.896rain=0.00windSpeed=0.8/*Auswertung Regenmengensensor mit Regenwippe- Counter kann durch reed-Kontakt oder Hallsensor erfolgen- i2c eeprom AT24C256- i2c Adresse EEPROM (default: 0x50)*/#include <Wire.h>//#include <I2C_EEPROM.h>#//include <avr/eeprom.h>/********************************************//* PIN-Section *//* Hier Sensor-Pins definieren *//********************************************///#define RAIN_COUNT_PIN 7#define RAIN_COUNT_PIN 30/********************************************//* Variablen-Section *//********************************************/long lastSecond; // Original - The millis counter to see when a second rolls byunsigned int minutesSinceLastReset; //Used to reset variables after 24 hours. Imp should tell us when it's midnight, this is backup.byte secondsRain; //When it hits 60, increase the current minutebyte minutesRain; //Keeps track of where we are in various arrays of data
volatile float rainHour[60]; //60 floating numbers to keep track of 60 minutes of rainvolatile unsigned long raintime, rainlast, raininterval, rain;volatile unsigned long last_micros1;long debouncing_time1 = 3; // in millis -> eleminiert evtl REED-Kontakt-Prellenboolean RainTimeReset = false;
//struct Configuration//{// float regenTag;// float regenStunde;//}eepconfig EEMEM;
//AT24C256<0x50> eep; // Das EEProm auf der china üblichen RTC3231
/********************************************//* Interrupt-Section *//********************************************/void rainIRQ(unsigned long now){ if((long)(micros() - last_micros1) >= debouncing_time1 * 1000) { rainToday += 0.1618; // Each dump is 0.1618mm of water rainHour[minutesRain] += 0.1618; // Increase this minute's amount of rain last_micros1 = micros(); }}
/********************************************//* Setup-Section *//********************************************/void setupRain(unsigned long now){ Serial.begin(115200); Wire.begin();#ifdef DEBUG_WS Serial.println("rain gauge online!");#endif// if(eep.ready()){// eep.get(eepconfig.regenTag,rainToday);//#ifdef DEBUG_WS// Serial.print("EEPROM rainToday : ");// Serial.println(rainToday);//#endif// }// else// { midnightReset(now); //Reset rain totals secondsRain = 0; lastSecond = now;// } rainLastHour = 0; pinMode(RAIN_COUNT_PIN, INPUT_PULLUP); attachInterrupt(RAIN_COUNT_PIN, rainIRQ, RISING);
reportWeather();}
/********************************************//* Loop-Section *//********************************************/void loopRain(unsigned long now){ //Keep track of which minute it is if(now - lastSecond >= 1000) { lastSecond += 1000;
reportWeather(); //Print the current readings. Takes 172ms.
//If we roll over 60 seconds then update the arrays for rain if(++secondsRain > 59) { secondsRain = 0;
if(++minutesRain > 59) minutesRain = 0; rainHour[minutesRain] = 0; //Zero out this minute's rainfall amount
minutesSinceLastReset++; //It's been another minute since last night's midnight reset } }
if((TimeStunde == 0) && (! RainTimeReset)) { midnightReset(now); //Reset a bunch of variables like rain and daily total rain RainTimeReset = true; } else if((TimeStunde != 0) && (RainTimeReset)) { RainTimeReset = false; }
//If we go for more than 24 hours without a midnight reset then force a reset //24 hours * 60 mins/hr = 1,440 minutes + 10 extra minutes. We hope that Imp is doing it. if(minutesSinceLastReset > (1440 + 10)) { midnightReset(now); //Reset a bunch of variables like rain and daily total rain }}
//When the imp tells us it's midnight, reset the total amount of rain and gustsvoid midnightReset(unsigned long now){ rainToday = 0; //Reset daily amount of rain// if(eep.ready()){// eep.put(eepconfig.regenTag,rainToday);// } minutesRain = 0; //Reset minute tracker secondsRain = 0; lastSecond = now; //Reset variable used to track minutes
minutesSinceLastReset = 0; //Zero out the backup midnight reset variable}
void calcWeather(){ rainLastHour = 0; for(int i = 0 ; i < 60 ; i++) rainLastHour += rainHour[i];}
void reportWeather(){ calcWeather(); //Go calc all the various sensors#ifdef INFO_WS Serial.print("rainLastHour : "); Serial.print(rainLastHour, 2); Serial.print(" , rainToday : "); Serial.println(rainToday, 2);#endif// if(eep.ready()){// eep.put(eepconfig.regenStunde,rainLastHour); //Nicht nutzen// eep.put(eepconfig.regenTag,rainToday);// }}Unfortunately, the data is summed up every few minutes and the values no longer fit.
For example, I have 0.15mm of rain in the last hour, then the value after each loop adds up until the hour is over.
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/a9156731-4c86-4498-9546-0481365ff600%40googlegroups.com.
On May 4, 2020, at 3:58 PM, Tom Keffer <tke...@gmail.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEASnBsOhS3pMcsP-h0u1G-T8eo9cTrOrvvE%2BU1Ngq5WCA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/19B03C71-EB79-482D-A190-E31C996753F9%40johnkline.com.
On May 4, 2020, at 6:30 PM, Tom Keffer <tke...@gmail.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEBmDc4swE2pvOTkk7inCso11fUmKGXzWvNZhXLSrU8k9A%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/a9156731-4c86-4498-9546-0481365ff600%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/7cf18d09-e9e0-460f-b2a5-40a45f86c923%40googlegroups.com.
Provided you are running WeeWX v4.2.0 or later you need to make the following changes to the [StdWXCalculate] stanza in weewx.conf:
Gary,I have edited the weewx.conf with proposed configuration. I am still not getting the values correct. I do have: rainDay, rainWeek, rainMonth and rainYear values in the weewx's database.
Maybe I don't understand the logic behind the [[Delta]].I have few questions:1. Does the logging interval matter? I am polling the data every minute and store it to the fileparser's compatible format. However, looking at the log file, I see that the records in the weewx.sdb do not update every minute. There are occasions where a minute is skipped (say 1 time per 10 minutes). I don't know the reason.
2. To avoid midnight time discrepancies, I am using the dateTime value provided by the data source (Ecowitt cloud) and provide the "dateTime=<>" string to the fileparser. Is this valid to do? I have also tried without this. Explanation: when polling for the data few seconds over 00:00, I get data from 23:59. If I let weewx use the actual OS time, the "rainDay" would be wrongly logged to the next day.
Why is using e.g. rainMonth or rainYear better than rainDay?