Okay cool… give me a moment to process it and ill update this post.
You will actually need 12 vpins, 6 for temp and 6 for humidity (i ditched the 24 since its the same as day)
First thing you need to do is create some global floats to store the values to use outside of the scope
Put these with your auth token.
float temp_current, temp_24hr, temp_1w, temp_1m, temp_3m, temp_6m, temp_1y;
float humidty_current, humidty_24hr, humidty_1w, humidty_1m, humidty_3m, humidty_6m, humidty_1y;
Then you need to define the vpins you will be using. Defining will help you change the pins later easily if you need to (trust me its good practice!)
Put these at the top.
#define vPIN_TEMP_24HR V20
#define vPIN_TEMP_1W V21
#define vPIN_TEMP_1M V22
#define vPIN_TEMP_3M V23
#define vPIN_TEMP_6M V24
#define vPIN_TEMP_1Y V25
#define vPIN_HUMIDITY_24HR V26
#define vPIN_HUMIDITY_1W V27
#define vPIN_HUMIDITY_1M V28
#define vPIN_HUMIDITY_3M V29
#define vPIN_HUMIDITY_6M V30
#define vPIN_HUMIDITY_1Y V31
Then you need to create a BLYNK_WRITE for each pin so that you can pull the value from the cloud later.
BLYNK_WRITE(vPIN_TEMP_24HR){
temp_24hr = param.asFloat();
}
BLYNK_WRITE(vPIN_TEMP_1W){
temp_1w = param.asFloat();
}
BLYNK_WRITE(vPIN_TEMP_1M){
temp_1m = param.asFloat();
}
BLYNK_WRITE(vPIN_TEMP_3M){
temp_3m = param.asFloat();
}
BLYNK_WRITE(vPIN_TEMP_6M){
temp_6m = param.asFloat();
}
BLYNK_WRITE(vPIN_TEMP_1Y){
temp_1y = param.asFloat();
}
BLYNK_WRITE(vPIN_HUMIDITY_24HR){
humidty_24hr = param.asFloat();
}
BLYNK_WRITE(vPIN_HUMIDITY_1W){
humidty_1w = param.asFloat();
}
BLYNK_WRITE(vPIN_HUMIDITY_1M){
humidty_1m = param.asFloat();
}
BLYNK_WRITE(vPIN_HUMIDITY_3M){
humidty_2m = param.asFloat();
}
BLYNK_WRITE(vPIN_HUMIDITY_6M){
humidty_6m = param.asFloat();
}
BLYNK_WRITE(vPIN_HUMIDITY_1Y){
humidty_1y = param.asFloat();
}
Then you need to do a virtualSync in setup to call the values from the cloud.
void setup(){
// ...
Blynk.syncVirtual(vPIN_TEMP_24HR, vPIN_TEMP_1W, vPIN_TEMP_1M, vPIN_TEMP_3M, vPIN_TEMP_6M, vPIN_TEMP_1Y);
Blynk.syncVirtual(vPIN_HUMIDITY_24HR, vPIN_HUMIDITY_1W, vPIN_HUMIDITY_1M, vPIN_HUMIDITY_3M, vPIN_HUMIDITY_6M, vPIN_HUMIDITY_1Y);
}
Then, at the time you store the values in to V11 and V12 you need to calcuate the averages then store them.
temp_current = bme.readTemperature();
humidity_current = bme.readHumidity();
Blynk.virtualWrite(V11, temp_current);
Blynk.virtualWrite(V12, humidity_current);
temp_24hr = (temp_24hr + temp_current) / 2;
Blynk.virtualWrite(vPIN_TEMP_24HR,temp_24hr);
temp_1w = (temp_1w + temp_current) / 2;
Blynk.virtualWrite(vPIN_TEMP_1W,temp_1w);
temp_1m = (temp_1m + temp_current) / 2;
Blynk.virtualWrite(vPIN_TEMP_1M,temp_1m);
// repeat the other 9 etc
Thne you need to reset them according to the RTC. So install the RTC library and learn how to use that in a difference project. Then you can use what you learnt to reset all the values to 0 as well as Blynk.virtualWrite() to each pin depending when you need to.
Here is some fake code for you to recreate as an example.
if current_day != new_day
then
temp_24hr = 0 AND virtualWrite(vPIN_TEMP_24HR,0)
humidity_24hr = 0 AND virtualWrite(vPIN_HUMIDITY_24HR,0)
if current_month != new_month
then
temp_1m = 0 AND virtualWrite(vPIN_TEMP_1M,0)
humidity_1M = 0 AND virtualWrite(vPIN_HUMIDITY_1M,0)
// repeat for all
@ilak2k, another huge note is 2second polling is rediculous! Change that to poll for new temp/humidty every 5 or 10minutes. The changes you want to record will only be valid every 5mins at least.