Hello everyone, i cant get the notifications on my phone. Everything is working clearly. If loops are okey and serial give me the message for them but i cant get the notifications. Any guess for the problem ?
Thanks for everyhting.
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
char auth[] = "--";
char ssid[] = "--";
char pass[] = "--";
#define DHTPIN 5 // Digital pin 2
#define DHTTYPE DHT11 // DHT 11
#define trig D3
#define echo D4
#define RelayPin1 12 // d6
#define fanPin1 13 // d7
#define RelayPin3 14 // d5
#define VPIN_BUTTON_1 V2
#define VPIN_BUTTON_2 V7
#define VPIN_BUTTON_3 V8
int toggleState_1 = 1;
int fanPinState1 = 1;
int toggleState_3 = 1;
int uyari2 = 0;
int uyari3=0;
int uyari1=0;
int uyari7 = 0;
int sensorpin=A0; // Soil Moisture çıkışı
int sensorvalue=0;
int outputvalue=0;
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
BLYNK_CONNECTED() {
Blynk.syncVirtual(VPIN_BUTTON_1);
Blynk.syncVirtual(VPIN_BUTTON_2);
Blynk.syncVirtual(VPIN_BUTTON_3);
}
BLYNK_WRITE(VPIN_BUTTON_1) {
toggleState_1 = param.asInt();
digitalWrite(RelayPin1, toggleState_1);
}
BLYNK_WRITE(VPIN_BUTTON_2) {
fanPinState1 = param.asInt();
digitalWrite(fanPin1, fanPinState1);
}
BLYNK_WRITE(VPIN_BUTTON_3) {
toggleState_3 = param.asInt();
digitalWrite(RelayPin3, toggleState_3);
}
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, ssid, pass);
Blynk.notify("ROW 1 HUMIDITY LEVEL 80%. VALVE CLOSING");
pinMode(RelayPin1, OUTPUT); //Declare Pin mode
digitalWrite(RelayPin1, toggleState_1);
pinMode(fanPin1, OUTPUT); //Declare Pin mode
digitalWrite(fanPin1, fanPinState1);
pinMode(RelayPin3, OUTPUT); //Declare Pin mode
digitalWrite(RelayPin1, toggleState_3);
dht.begin();
// timer.setInterval(1000L, Wlevel);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
// Setup a function to be called every second
// timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
delay(100);
//timer.run();
//soil için
sensorvalue=analogRead(sensorpin);
outputvalue=map(sensorvalue,620,310,0,100); //100,0 pottupaaru
if(outputvalue > 100)
{
outputvalue=100;
Serial.println("100 %");
}
else if(outputvalue <=0)
{
outputvalue=0;
Serial.println("0 %");
}else if(outputvalue >0 && outputvalue < 100)
{
Serial.print(outputvalue);
Serial.println("%");
}
if(outputvalue >80){
Serial.println("girdi");
digitalWrite(RelayPin1, HIGH);
Blynk.virtualWrite(V2, HIGH);
toggleState_1 = 0;
Serial.println("uyarı");
Blynk.notify("ROW 1 HUMIDITY LEVEL 80%. VALVE CLOSING");
uyari7=1;
}else {
if ( outputvalue <40){
digitalWrite(RelayPin1, LOW);
Blynk.virtualWrite(V2, LOW);
toggleState_1 = 1;
}}
delay(1000);
Blynk.virtualWrite(V4,outputvalue);
//
//
float h = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(h) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, temperature); //V6 is for Temperature
if(temperature >= 25 && uyari2 == 0){
Serial.println("fan için girdi");
digitalWrite(fanPin1, LOW);
Blynk.virtualWrite(V7,255);
fanPinState1 = 0;
Blynk.notify("High Temperature.Fan Startıng");
uyari2=1;
}else {
if ( temperature <25){
uyari2 = 0;
}
}
if (temperature < 25 && uyari1 == 0){
digitalWrite(fanPin1, HIGH);
Blynk.virtualWrite(V7,0);
Blynk.notify("Low Temperature,Fan Stoping ");
uyari1=1;
Serial.println("fan için çıktı");
}else {
if ( temperature > 25 ){
uyari1 = 0;
}
}
//
//
digitalWrite(trig, LOW);
delayMicroseconds(4);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
long t = pulseIn(echo, HIGH);
long cm = t / 29 / 2;
Blynk.virtualWrite(V1, cm);
Serial.println(cm);
if(cm <= 10 && uyari3 == 0){
digitalWrite(RelayPin3, HIGH);
Blynk.virtualWrite(V8,0);
Blynk.notify("Water Tank Level %70.Water Valve Closing.");
uyari3=1;
}else {
if ( cm > 11 ){
uyari3 = 0;
Blynk.virtualWrite(V8,255);
digitalWrite(RelayPin3, LOW);
}}
//
}