Device was disconnected

Hello

Can you please look at my code is there a mistake I find since no error because the Blynk app always indicates “Device was disconnected”

#define BLYNK_PRINT Serial 
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 13

char auth[] = "403bc91d69861eb5c4bcf";
char ssid[] = "v.....";
char pass[] = "098500853402613";

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

int Sensorvalue=0;
int tempout=0;
int sensorPin=A0;
int sensorValuePercent=0;

WidgetLCD lcd(V7);

SimpleTimer timer;

void sendTemps()
 {
sensors.requestTemperatures();
  float tempout = sensors.getTempCByIndex(0);
  Serial.println(tempout);
  Blynk.virtualWrite(V4, tempout);
    int Temperatur = tempout;
   if (Temperatur < 9.99)
{
  Blynk.setProperty(V4, "color", "#2ECCFA");
  Blynk.setProperty(V4, "label", "arsch kalt");
}
else if (Temperatur > 10 && Temperatur < 19.99)
{
  Blynk.setProperty(V4, "color", "#00FF00");
  Blynk.setProperty(V4, "label", "Temperatur normal");
}
else if (Temperatur > 20 && Temperatur < 69.99)
{
 Blynk.setProperty(V4, "color", "#FE2E2E");
  Blynk.setProperty(V4, "label", "schön warm");
}
  }
  
void setup()
{
  Serial.begin(9600);
timer.setInterval(3001, sendTemps1); 
timer.setInterval(3001, sendTemps);
  sensors.begin();
  Blynk.begin(auth, ssid, pass);
}
void sendTemps1()

{
  Sensorvalue = analogRead(A0);
  Sensorvalue = map(Sensorvalue, 0, 1023, 1023, 0);
  sensorValuePercent = (Sensorvalue / 1023) * 100;
  Blynk.virtualWrite(V5, Sensorvalue);
  delay(3001);
  int feucht = Sensorvalue;
   if (feucht < 50.99)
{
 lcd.print(5,1,"trocken  ");
  Blynk.setProperty(V5, "color", "#E10C28");
  Blynk.setProperty(V5, "label", "Blumenerde trocken");
  lcd.print(2, 0,"Feuchtigkeit");
  Blynk.setProperty(V7, "color", "#F957FC");
}
else if (feucht > 51 && feucht < 125.99)
{
 lcd.print(5,1,"feucht  ");
  Blynk.setProperty(V5, "color", "#04B404");
  Blynk.setProperty(V5, "label", "Blumenerde feucht");
  lcd.print(2, 0,"Feuchtigkeit");
  Blynk.setProperty(V7, "color", "#F957FC");
}
else if (feucht > 126 && feucht < 200.99)
{
 lcd.print(5,1," nass  ");
 Blynk.setProperty(V5, "color", "#00CCFF");
  Blynk.setProperty(V5, "label", "Blumenerde nass");
  lcd.print(2, 0,"Feuchtigkeit");
  Blynk.setProperty(V7, "color", "#F957FC");
}
}

void loop()    
{ 
  Blynk.run();
  timer.run();
 }

You need to avoid delays. This is not very effective way to go,

Ah ok delay(3001); get out

Blynk.setProperty(V4, “label”, “arsch kalt”); made me a smile on my face :slight_smile:

I Would prefer such solution:

#define BLYNK_PRINT Serial 
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 13

char auth[] = "403bc91d69861eb5c4bcf";
char ssid[] = "v.....";
char pass[] = "098500853402613";

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

int Sensorvalue=0;
int tempout=0;
int sensorPin=A0;
int sensorValuePercent=0;

WidgetLCD lcd(V7);

SimpleTimer timer;
#define UPDATE_AFTER_SECONDS 4
unsigned long SecTimerValue;
unsigned long UpdateTimer;

void UpdateSectimer() {
	
	
	SecTimer++;
}

void sendTemps()
 {
sensors.requestTemperatures();
  float tempout = sensors.getTempCByIndex(0);
  Serial.println(tempout);
  Blynk.virtualWrite(V4, tempout);
    int Temperatur = tempout;
   if (Temperatur < 9.99)
{
  Blynk.setProperty(V4, "color", "#2ECCFA");
  Blynk.setProperty(V4, "label", "arsch kalt");
}
else if (Temperatur > 10 && Temperatur < 19.99)
{
  Blynk.setProperty(V4, "color", "#00FF00");
  Blynk.setProperty(V4, "label", "Temperatur normal");
}
else if (Temperatur > 20 && Temperatur < 69.99)
{
 Blynk.setProperty(V4, "color", "#FE2E2E");
  Blynk.setProperty(V4, "label", "schön warm");
}
  }
  
void setup()
{
  Serial.begin(9600); 
  timer.setInterval(3001, UpdateSectimer);
  sensors.begin();
  Blynk.begin(auth, ssid, pass);
}
void sendTemps1()

{
  Sensorvalue = analogRead(A0);
  Sensorvalue = map(Sensorvalue, 0, 1023, 1023, 0);
  sensorValuePercent = (Sensorvalue / 1023) * 100;
  Blynk.virtualWrite(V5, Sensorvalue);
  delay(3001);
  int feucht = Sensorvalue;
   if (feucht < 50.99)
{
 lcd.print(5,1,"trocken  ");
  Blynk.setProperty(V5, "color", "#E10C28");
  Blynk.setProperty(V5, "label", "Blumenerde trocken");
  lcd.print(2, 0,"Feuchtigkeit");
  Blynk.setProperty(V7, "color", "#F957FC");
}
else if (feucht > 51 && feucht < 125.99)
{
 lcd.print(5,1,"feucht  ");
  Blynk.setProperty(V5, "color", "#04B404");
  Blynk.setProperty(V5, "label", "Blumenerde feucht");
  lcd.print(2, 0,"Feuchtigkeit");
  Blynk.setProperty(V7, "color", "#F957FC");
}
else if (feucht > 126 && feucht < 200.99)
{
 lcd.print(5,1," nass  ");
 Blynk.setProperty(V5, "color", "#00CCFF");
  Blynk.setProperty(V5, "label", "Blumenerde nass");
  lcd.print(2, 0,"Feuchtigkeit");
  Blynk.setProperty(V7, "color", "#F957FC");
}
}

void loop()    
{ 
  Blynk.run();
  timer.run();
  
  if (UpdateSectimer < SecTimerValue) {
	  if (Blynk.connected()) {
		sendTemps();
		sendTemps1();
	  }
	  UpdateSectimer = SecTimerValue + UPDATE_AFTER_SECONDS;
  }
  
  
 }

af_bln / The code does not work Below is always ‘SecTimer’ was not declared in the scope :confused:

Edit this function:
void UpdateSectimer() {
SecTimerValue++;
}

Hello Arduino Still shows errors at see below something with C ++ error

 if (UpdateSectimer < SecTimerValue) { <<< ISO C++forbidscomparsion between pointer and integer (-fpermissive)
    if (Blynk.connected()) {
    sendTemps();
    sendTemps1();
    }
    UpdateSectimer = SecTimerValue + UPDATE_AFTER_SECONDS;
  }
  
  
 }

UpdateSectimer should be UpdateTimer I think. You are now comparing a void function (UpdateSectimer) with a long type variable.

Ups, yes you are right.