Spam for push notification

hey blinkers again… In this code i have add in eventor to send me push notification if the temperature drops to 26C… i have 28c and many times of the day send me warning notification that temperature is 26 while temprature is 28 to 30 all time … also i check to super chart to verify this warning and i see that the temperature was not 26 ever … what do you think is this wrong info? thanks you

#include <DNSServer.h>
#include <WiFiManager.h>
#include <ESP8266WebServer.h>
#include <BlynkSimpleEsp8266.h>
#include <ArduinoJson.h>
const char* host = "www.google.com"; 

/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

//BlynkTimer timer;

float temp_0;
float temp_1;
float temp_2;
float temp_3;

const int relay_1 = 16;
const int relay_2 = 5;
const int relay_3 = 4;
const int relay_4 = 0;
const int relay_5 = 14;
const int relay_6 = 12;
const int relay_7 = 13;
const int relay_8 = 3;


#define SET_PIN 0

char blynk_token[40] = "";
bool shouldSaveConfig = false;

void saveConfigCallback () {
 Serial.println("Should save config");
 shouldSaveConfig = true;
}


BLYNK_CONNECTED()  //sygxronizei to esp otan bgei apo to reuma stis leitoyrgies poy eixe stamatisi
{
Blynk.syncAll();
}


void setup()
{
 //Blynk.config(auth);
// Blynk.begin(auth, ssid, pass);
 DS18B20.begin();
 timer.setInterval(1000L,getSendData);
 timer.setInterval(10000L,WiFiStatus);
 
 Serial.begin(115200);
 Serial.println();
 pinMode(SET_PIN, INPUT_PULLUP);
 delay(3000);

 //read configuration from FS json
 Serial.println("mounting FS...");
 if (SPIFFS.begin()) {
   Serial.println("mounted file system");
   if (SPIFFS.exists("/config.json")) {
     //file exists, reading and loading
     Serial.println("reading config file");
     File configFile = SPIFFS.open("/config.json", "r");
     if (configFile) {
       Serial.println("opened config file");
       DynamicJsonDocument jsonBuffer ( 1024 ) ;
       DeserializationError error = deserializeJson ( jsonBuffer, configFile ) ;
       if ( not error )
         {
           serializeJson(jsonBuffer, Serial);
           strcpy(blynk_token, jsonBuffer["blynk_token"]) ;
           Serial.println("\nparsed json");
           Serial.println( blynk_token );
         }
       else  
         Serial.println("failed to load json config");

       configFile.close();
   }
 } else {
   Serial.println("failed to mount FS");
 }

 WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 32);
 WiFiManager wifiManager;
 wifiManager.setSaveConfigCallback(saveConfigCallback);
 wifiManager.addParameter(&custom_blynk_token);

 if (digitalRead(SET_PIN) == LOW) {
   wifiManager.resetSettings();
 }

 if (!wifiManager.autoConnect("Kitchenroom")) {
   Serial.println("failed to connect and hit timeout");
   delay(3000);
   ESP.reset();
   delay(5000);
 }

 Serial.println("wifi connected");
 strcpy(blynk_token, custom_blynk_token.getValue());

 //save the custom parameters to FS
 if (shouldSaveConfig) {
   Serial.println("saving config");
   DynamicJsonDocument jsonBuffer ( 1024 ) ;
   jsonBuffer["blynk_token"] = blynk_token;

   File configFile = SPIFFS.open("/config.json", "w");
   if (!configFile) {
     Serial.println("failed to open config file for writing");
   }
   else
     serializeJson(jsonBuffer, configFile);
   configFile.close();
 }
 
 Serial.println();
 Serial.print("local ip : ");
 Serial.println(WiFi.localIP());
 Serial.print("Blynk Token : ");
 Serial.println(blynk_token);
 Blynk.config(blynk_token);
 }
}

void loop() {
 Blynk.run();
 timer.run(); // Initiates SimpleTimer
}



/***************************************************
 * Send Sensor data to Blynk
 **************************************************/

void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp_0 = DS18B20.getTempCByIndex(0); // Sensor 1 will capture Temp in Celcius
  temp_1 = DS18B20.getTempCByIndex(1); // Sensor 2 will capture Temp in Celcius
  temp_2 = DS18B20.getTempCByIndex(2); // Sensor 3 will capture Temp in Celcius
  temp_3 = DS18B20.getTempCByIndex(3); // Sensor 4 will capture Temp in Celcius

  Blynk.virtualWrite(1, temp_0); //virtual pin V1
  Blynk.virtualWrite(2, temp_1); //virtual pin V2
  Blynk.virtualWrite(3, temp_2); //virtual pin V3
  Blynk.virtualWrite(4, temp_3); //virtual pin V4
}


void WiFiStatus()
{
 WiFiClient client;
 if (client.connect(host, 80))
 {
       Serial.println("connected");
       client.stop();
    
   }
   else {
    Serial.println("connection failed!"); 
 digitalWrite(relay_1, HIGH); // Και εδω δηλωνεις οτι θα ξεκιναει κλειστο
 digitalWrite(relay_2, HIGH);
 digitalWrite(relay_3, HIGH);
 digitalWrite(relay_4, HIGH); 
 digitalWrite(relay_5, HIGH);
 digitalWrite(relay_6, HIGH);
 digitalWrite(relay_7, HIGH);
 digitalWrite(relay_8, HIGH); 
    client.stop();
   
  }
}

That’s in the Blynk app, not in this code, so whatever logic you’ve used for that is invisible to us.
And, as I’ve said before, mixing code and Eventor is a really bad approach.

The way that Superchart works is that it takes all of the reading for a virtual pin and stores them for one minute. It then averages these readings and writes that result to the database. It is this averaged reading that you see in Superchart.

My guess is that because you don’t have any code to check for invalid sensor readings before sending them to Blynk then it’s these invalid readings that are triggering your notifications.

I’d suggest that you add some serial print sta5tements to your code, and look at the readings that are obtained when your notification is triggered.

Pete.

Sorry Pete, i forgot to report that i use eventor for blynk app not to the code… i will check the serial to see what measure was taken in this time… also what do you think that is not good idea to use eventor for my project… why this to work wrong? Can i do something to improve this problem and finally to i use this feature ? It is necessary for my project :confused: thank you

As far as I’m concerned, Eventor is for people who want to add program logic without coding. As you’re already doing the coding bit, you’ve split your program logic across two different systems, so you don’t have full control in one place.
This also means that you have to attempt to debug two pieces of independent logic, which as you’re discovering is difficult.

Yes…

Pete.

something like this?

 * Send Sensor data to Blynk
 **************************************************/
void getSendData(){
    unsigned long cur_millis = millis();
    if (cur_millis - lst_milis >= 2000)         //if 2 seconds since last mesurement 
        {
        lst_milis = cur_millis;
        DS18B20.requestTemperatures(); 
               
           temp_0 = DS18B20.getTempCByIndex(0); // Sensor 1 will capture Temp in Celcius
           temp_1 = DS18B20.getTempCByIndex(1); // Sensor 2 will capture Temp in Celcius
           temp_2 = DS18B20.getTempCByIndex(2); // Sensor 3 will capture Temp in Celcius     

          if(temp_0 != -127){
            Serial.println(temp_0);
            Blynk.virtualWrite(1 , temp_0);    //virtual pin 1
          }
          else{
            Serial.println("Error: Could not read temperature data for sensor No.0");
          }

          if(temp_1 != -127){
            Serial.println(temp_1);
            Blynk.virtualWrite(2 , temp_1);    //virtual pin 2
          }
          else{
            Serial.println("Error: Could not read temperature data for sensor No.1");
            }

            if(temp_2 != -127){
            Serial.println(temp_2);
            Blynk.virtualWrite(3, temp_2);    //virtual pin 3
          }
          else{
            Serial.println("Error: Could not read temperature data for sensor No.2");
           }
           if(temp_3 != -127){
            Serial.println(temp_3);
            Blynk.virtualWrite(4, temp_3);    //virtual pin 4
          }
          else{
            Serial.println("Error: Could not read temperature data for sensor No.3");
           }
        }
    }

Yes.

Pete.

Thanks you for help, Pete :slight_smile: