BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Why Can I not provision Esp 32?

HIi
I am using esp 32 and blynk.When I download my code,I cannot using flash button because of provision.Where is my mistake.Can you help me please?

#define BLYNK_TEMPLATE_ID "TMPLebZli4eo"
#define BLYNK_DEVICE_NAME "SmartBox"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
#define USE_WROVER_BOARD
//#define USE_TTGO_T7
#include "BlynkEdgent.h"
BlynkTimer timer1;
BlynkTimer timer;
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 5 //D5 pin of Node MCU 
#define DHTTYPE DHT11
int esikdegeri=1500;
int toggleState_1=0;
int toggleState_2=0;
int toggleState_3=0;
int toggleState_4=0;
//int buzzer=18;
int deger=0;
int gazokuma=36; 
int lcdColumns = 16;
int lcdRows = 2;
int role_1=27;
int role_2=26;
int role_3=25;
int role_4=33;
int buzzer=18;
int ok=32;
//int sayac=0;
int x=0;
int yukari=35; 
int asagi=34;
//Set Degerleri Belirleme 
int ayarsayac=1;  
int gerilimset=500;
int akimset=500;
int gazsensorset=1000;
int sicaklikset=500;
int nemset=500;
bool acildurum=false;
bool anaekran=false; 
bool ayarlar=false;
bool gazsetbelirle=false;
bool ayarsayackontrol=false;
bool gerilimsetbelirle=false;
bool akimsetbelirle=false;
bool sicakliksetbelirle=false;
bool nemsetbelirle=false;
bool gazsetonay=false;
bool akimsetonay=false; 
bool nemsetonay=false;
bool gerilimsetonay=false;
bool sicakliksetonay=true; 
bool ayarmenu=false;
bool ayarsetmenu=false;
int yukarisayac=0;
int asagisayac=0;
unsigned long acilsimdi=0;
unsigned long acilsonra=0;
unsigned long eskizaman=0;
unsigned long simdikizaman;
unsigned long ayarlarsimdi=0;
unsigned long ayarlareski=0;
unsigned long butonsimdi=0;
unsigned long butoneski=0;

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows); 
float h , t;
int sayac=1;
#include <PZEM004Tv30.h>

/* Hardware Serial2 is only available on certain boards.
 * For example the Arduino MEGA 2560
*/
#if defined(ESP32)
PZEM004Tv30 pzem(Serial2,16,17);
#else
PZEM004Tv30 pzem(Serial2);
#endif

void sendSensor()
{
float voltage = pzem.voltage();
float current = pzem.current();
float h = dht.readHumidity();
float t = dht.readTemperature();
deger=analogRead(gazokuma);
Blynk.virtualWrite(V1, h);
Blynk.virtualWrite(V0, t);
Blynk.virtualWrite(V2, voltage);
Blynk.virtualWrite(V3, current);
Blynk.virtualWrite(V4, deger);
Blynk.virtualWrite(V9,sicaklikset);
Blynk.virtualWrite(V10,gazsensorset);
Blynk.virtualWrite(V11,akimset);
Blynk.virtualWrite(V12,gerilimset);
Blynk.virtualWrite(V13,nemset);
}

void anadongu() 
{
if(anaekran==true) 
{
anaekran_menu();
Serial.println("Ana EKRAN Cagırıldı...");
}
//Acil Durumda Cagrılcak Fonksiyon
//if(acilsimdi-acilsonra>100)
//{
//acil_durum();
//acilsimdi=acilsonra;  
//}
if(ayarlar==true)
{
ayarlarmenu(); 
} 
if(ayarsetmenu==true)
{
ayarset();
}
}

BLYNK_WRITE(V5) {
  toggleState_1 = param.asInt();
  if(toggleState_1 == 1){
    digitalWrite(role_1, LOW);
  }
  else { 
    digitalWrite(role_1, HIGH);
  }
}

BLYNK_WRITE(V6) {
  toggleState_2 = param.asInt();
  if(toggleState_2 == 1){
    digitalWrite(role_2, LOW);
  }
  else { 
    digitalWrite(role_2, HIGH);
  }
}
BLYNK_WRITE(V7) {
  toggleState_3 = param.asInt();
  if(toggleState_3 == 1){
    digitalWrite(role_3, LOW);
  }
  else { 
    digitalWrite(role_3, HIGH);
  }
}
BLYNK_WRITE(V8) {
  toggleState_4 = param.asInt();
  if(toggleState_4 == 1){
    digitalWrite(role_4, LOW);
  }
  else { 
    digitalWrite(role_4, HIGH);
  }
}
void setup()
{

Serial.begin(115200);
  // initialize LCD
 lcd.begin();                   
 lcd.backlight();
 pinMode(buzzer,OUTPUT);
 pinMode(role_1,OUTPUT);
 pinMode(role_2,OUTPUT);
 pinMode(role_3,OUTPUT);
 pinMode(role_4,OUTPUT);
 pinMode(buzzer,OUTPUT);
 pinMode(ok,INPUT);
 pinMode(yukari,INPUT); 
 pinMode(asagi,INPUT); 
 Serial.println(F("DHTxx test!"));
 dht.begin();
 pinMode(gazokuma, INPUT);
 lcd.clear(); 
 lcd.setCursor(0,0); 
 lcd.print("Haydar"); 
 lcd.setCursor(0,1); 
 lcd.print("Gungor"); 
 delay(1500);
 lcd.clear(); 
 lcd.setCursor(0,0); 
 lcd.print("Dogus UNI"); 
 lcd.setCursor(0,1); 
 lcd.print("Bitirme Projesi"); 
 delay(1500);
 lcd.clear(); 
 BlynkEdgent.begin();
 timer1.setInterval(2000L,sendSensor);
 timer1.setInterval(1500L,anadongu);
 timer1.setInterval(200L,butonkontrol);
 Serial.begin(115200);
}


void loop() 
{
 BlynkEdgent.run();
 timer1.run();
 //timer.run();
}
void dht11_olcum()
{
 lcd.clear();
  float h = dht.readHumidity();
  float t = dht.readTemperature();
//  float f = dht.readTemperature(true);
//  if (isnan(h) || isnan(t) || isnan(f)) 
//  {
//    Serial.println(F("Failed to read from DHT sensor!"));
//    return;
//  }  
  //lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Sicaklik:"); 
  lcd.setCursor(11,0);
  lcd.print(t); 
  lcd.setCursor(0,1);
  lcd.print("Nem:"); 
  lcd.setCursor(11,1);
  lcd.print(h); 
}
void gaz_olcum()
{
lcd.clear();
deger=analogRead(gazokuma);
//Serial.println("Deger :");
//Serial.println(deger);
lcd.setCursor(0,0);
lcd.print("Gaz  Deger:");
lcd.setCursor(10,1);
lcd.print(deger);
}
void elektrikselolcum()
{
lcd.clear();
float voltage = pzem.voltage();
if(voltage != NAN)
{
Serial.print("Voltage:"); 
Serial.print(voltage); 
Serial.println("V");
}
else 
{
//Serial.println(“Error reading voltage”);
}
float current = pzem.current();
if(current != NAN)
{
Serial.print("Current: ");
Serial.print(current); 
Serial.println("A");
}
else 
{
Serial.println("Error reading current");
}
float power = pzem.power();
if(current != NAN)
{
Serial.print("Power: "); 
Serial.print(power); 
Serial.println("W");
}
else 
{
Serial.println("Error reading power");
}
float energy = pzem.energy();
if(current != NAN)
{
Serial.print("Energy: ");
Serial.print(energy,3); 
Serial.println("kWh");
} 
else 
{
Serial.println("Error reading energy");
}
float frequency = pzem.frequency();
if(current != NAN)
{
Serial.print("Frequency: "); 
Serial.print(frequency, 1); 
Serial.println("Hz");
} else 
{
Serial.println("Error reading frequency");
}
float pf = pzem.pf();
if(current != NAN)
{
Serial.print("PF: "); 
Serial.println(pf);
} else {
Serial.println("Error reading power factor");
}
lcd.setCursor(0,0);
lcd.print("Voltage:");
//Gerilim
lcd.setCursor(11,0);
lcd.print(voltage);
lcd.setCursor(0,1);
lcd.print("Current:");
//Akım
lcd.setCursor(11,1);
lcd.print(current);
//delay(3000);
//lcd.clear();
//lcd.setCursor(0,0);
//lcd.print("Power:");
//Güç
//lcd.setCursor(11,0);
//lcd.print(power);
//lcd.setCursor(0,1);
//lcd.print("Frequency :");
////Frekans
//lcd.setCursor(11,1);
//lcd.print(frequency);
//
//  float v = pzem.voltage();
//  if (v < 0.0) v = 0.0;
//   Serial.println(v);Serial.println("V; ");
//
//  float i = pzem.current();
//   if(i >= 0.0){ Serial.println(i);Serial.println("A; "); }
//
//  float p = pzem.power();
//   if(p >= 0.0){ Serial.println(p);Serial.println("W; "); }
//
//  float e = pzem.energy();
//   if(e >= 0.0){ Serial.println(e);Serial.println("Wh; "); }
}
void acil_durum() 
{
float voltage = pzem.voltage();
float current = pzem.current();
float h = dht.readHumidity();
float t = dht.readTemperature();
deger=analogRead(gazokuma);

if(deger>gazsensorset)
{
Blynk.logEvent("gaz_tehlkes","Gaz Tehlikesi var.");  
lcd.clear();
acildurum=true;
anaekran=false;
ayarlar=false;
lcd.setCursor(0,0); 
lcd.print("Acil Durum!!!");
lcd.setCursor(0,1); 
lcd.print("Gaz Tehlikesi");
digitalWrite(buzzer,HIGH);
digitalWrite(role_1,LOW);
digitalWrite(role_2,LOW);
digitalWrite(role_3,LOW);
digitalWrite(role_4,LOW);  
} 
else if(voltage>gerilimset)
{
Blynk.logEvent("gerilim_tehlikesi","Gerilim Tehlikesi...");  
lcd.clear();
acildurum=true;
anaekran=false;
ayarlar=false;
lcd.setCursor(0,0); 
lcd.print("Acil Durum!!!");
lcd.setCursor(0,1); 
lcd.print("Gerilim Tehlikesi");
digitalWrite(buzzer,HIGH);
digitalWrite(role_1,LOW);
digitalWrite(role_2,LOW);
digitalWrite(role_3,LOW);
digitalWrite(role_4,LOW);   
}
else if(current>akimset) 
{
Blynk.logEvent("yksek_akim_","YÜKSEK AKIM UYARISI");  
lcd.clear();
acildurum=true;
anaekran=false;
ayarlar=false;
lcd.setCursor(0,0); 
lcd.print("Acil Durum!!!");
lcd.setCursor(0,1); 
lcd.print("Akim Tehlikesi");
digitalWrite(buzzer,HIGH);
digitalWrite(role_1,LOW);
digitalWrite(role_2,LOW);
digitalWrite(role_3,LOW);
digitalWrite(role_4,LOW);   
}
else if(t>sicaklikset) 
{
Blynk.logEvent("yksek_scaklk","YÜKSEK SICAKLIK...");  
lcd.clear();
acildurum=true;
anaekran=false;
ayarlar=false;
lcd.setCursor(0,0); 
lcd.print("Acil Durum!!!");
lcd.setCursor(0,1); 
lcd.print("Sicaklik Tehlikesi");
digitalWrite(buzzer,HIGH);
digitalWrite(role_1,LOW);
digitalWrite(role_2,LOW);
digitalWrite(role_3,LOW);
digitalWrite(role_4,LOW);   
}
else if(h>nemset) 
{
Blynk.logEvent("krtk_nem_uyarisi","KRİTİK NEM UYARISI");  
lcd.clear();
acildurum=true;
anaekran=false;
ayarlar=false;
lcd.setCursor(0,0); 
lcd.print("Acil Durum!!!");
lcd.setCursor(0,1); 
lcd.print("Nem Tehlikesi");
digitalWrite(buzzer,HIGH);
digitalWrite(role_1,LOW);
digitalWrite(role_2,LOW);
digitalWrite(role_3,LOW);
digitalWrite(role_4,LOW);   
}
else
{
acildurum=false; 
digitalWrite(buzzer,LOW);
} 
}
void ayarlarmenu() 
{
if(ayarsayac==1)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Gaz Sensor");
lcd.setCursor(0,1); 
lcd.print("Set Belirleme");
} 
if(ayarsayac==2)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Gerilim");
lcd.setCursor(0,1); 
lcd.print("Set Belirleme"); 
}
if(ayarsayac==3)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Akim");
lcd.setCursor(0,1); 
lcd.print("Set Belirleme"); 
}
if(ayarsayac==4)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Sicaklik");
lcd.setCursor(0,1); 
lcd.print("Set Belirleme"); 
}
if(ayarsayac==5)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Nem");
lcd.setCursor(0,1); 
lcd.print("Set Belirleme"); 
}
}
void ayarset()
{
if(gazsetbelirle==true)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Gaz Set");  
lcd.setCursor(0,1);
lcd.print(gazsensorset);

}
if(gerilimsetbelirle==true)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Gerilim Set");
lcd.setCursor(0,1);
lcd.print(gerilimset); 
}
if(akimsetbelirle==true)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Akim Set");
lcd.setCursor(0,1);
lcd.print(akimset);  
}
if(sicakliksetbelirle==true)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Sicaklik Set");  
lcd.setCursor(0,1);
lcd.print(sicaklikset);
}
if(nemsetbelirle==true)
{
lcd.clear();
lcd.setCursor(0,0); 
lcd.print("Nem Set");  
lcd.setCursor(0,1);
lcd.print(nemset);
}
}
  

void anaekran_menu() 
{
if(sayac==1)
{
dht11_olcum();  
//Serial.println("Fonksiyon Çalıştı");
}
if(sayac==2) 
{
gaz_olcum();
}
if(sayac==3) 
{
elektrikselolcum();
}
sayac++;
if(sayac==4)
{
sayac=1;
//lcd.clear();
}  
}




void butonkontrol() 
{
if(digitalRead(ok)==1)
{
x++; 
if(x>4)
{
x=0;  
}  
}
if(x==0)
{
ayarlar=false;
ayarsetmenu=false;
anaekran=true;  
}
if(x==1)
{
anaekran=false;
ayarlar=true;  
ayarsetmenu=false;
}
if(x==2)
{
anaekran=false;
ayarsetmenu=true;
ayarlar=false; 
if(ayarsayac==1)
{
gazsetbelirle=true;
}
if(ayarsayac==2)
{
gerilimsetbelirle=true; 
}
if(ayarsayac==3)
{
akimsetbelirle=true; 
}
if(ayarsayac==4)
{
sicakliksetbelirle=true; 
}
if(ayarsayac==5)
{
nemsetbelirle=true; 
}
}
if(x==3) 
{
//setonay=true;
}
//////////Ayar Kontrol
if(ayarlar==true)
{
if(digitalRead(yukari)==1)
{
digitalWrite(buzzer,HIGH);
ayarsayac++; 
digitalWrite(buzzer,LOW);
}
if(digitalRead(asagi)==1)
{
digitalWrite(buzzer,HIGH);
ayarsayac--; 
digitalWrite(buzzer,LOW);
}
if(ayarsayac>5) 
{
ayarsayac=5;  
}
if(ayarsayac<1) 
{
ayarsayac=1; 
}  
}

if(gazsetbelirle==true)
{
if(digitalRead(yukari)==1) 
{
gazsensorset++;
}
if(digitalRead(asagi)==1) 
{
gazsensorset--;
}
}
//////Gerilim
if(gerilimsetbelirle=true)
{
if(digitalRead(yukari)==1) 
{
gerilimset++;
}
if(digitalRead(asagi)==1) 
{
gerilimset--;
}   
}
//////Akim
if(akimsetbelirle==true)
{
if(digitalRead(yukari)==1) 
{
akimset++;
}
if(digitalRead(asagi)==1) 
{
akimset--;
}
}
//Sicaklik 
if(sicakliksetbelirle==true)
{
if(digitalRead(yukari)==1) 
{
sicaklikset++;
}
if(digitalRead(asagi)==1) 
{
sicaklikset--;
}  
}

/////Nem
if(nemsetbelirle==true)
{
 if(digitalRead(yukari)==1) 
{
nemset++;
}
if(digitalRead(asagi)==1) 
{
nemset--;
}  
}
//////////AyarKontrol bitiş
}


I’m not exactly sure what this means, but you should probably read the “Defining your physical switch and LED” section of this post…

Pete.