BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk synchronisiert nicht alle virtuellen pins

Hallo
ich habe in meinem projekt fast 50 virtuelle pins belegt und synchronisiere sie alle mit blynk.connected().

leider werden aber nicht alle werte aktualisiert wie sie in der app sind.
alles auf einem nodemcu.

z.B.V37 timerCair

danke im voraus

//DHT11 And NodeMCU With Blynk
//My GitHub https://github.com/manoranjan2050
//My Hackster.io https://www.hackster.io/Manoranjan2050
//This Video Link https://youtu.be/0dbws1i2GoE

#define BLYNK_PRINT Serial
 

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
 
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "*********************";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Matze K";
char pass[] = "***********************";
 
#define DHTPIN 0          // D3
#define HEATPIN 13        //D7
#define FANPIN 15         //D1
#define PUMPPIN 4
#define MOISTUREPIN A0

#define BLYNK_GREEN     "#23C48E"
#define BLYNK_BLUE      "#04C0F8"
#define BLYNK_YELLOW    "#ED9D00"
#define BLYNK_RED       "#D3435C"
#define BLYNK_DARK_BLUE "#5F7CD8"  


// Data wire is plugged into port D6 on the Arduino
#define ONE_WIRE_BUS 12

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device address
DeviceAddress insideThermometer;

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301
 
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
WidgetRTC rtc;
 
float TEMPH_day=0;
float TEMPH_day_s=0;
float TEMPH_day_g=0;
float TEMPH_day_b=0;
float TEMPL_day=0;
float TEMPL_day_s=0;
float TEMPL_day_g=0;
float TEMPL_day_b=0;
float TEMPH_night=0;
float TEMPH_night_s=0;
float TEMPH_night_g=0;
float TEMPH_night_b=0;
float TEMPL_night=0;
float TEMPL_night_s=0;
float TEMPL_night_g=0;
float TEMPL_night_b=0;
float HUML=0;
float HUML_s=0;
float HUML_g=0;
float HUML_b=0;
float HUMH=0;
float HUMH_s=0;
float HUMH_g=0;
float HUMH_b=0;
float helligkeit=0;
int day_begin=0;
int day_begin_s=0;
int day_begin_g=0;
int day_begin_b=0;
int day_end=0;
int day_end_s=0;
int day_end_g=0;
int day_end_b=0;
float sensor_alarm=0;
float h=0;
float t_Box=0;
float t_Tube=0;
int actual_day=0;
int day_count=0;
int erase_day_count=0;
int seed_state=0;
int grow_state=0;
int bloom_state=0;
float timerCbox =1;
float timerCair;
float timerCalarm=1;
float timerTube=1;
float timerBox=1;
unsigned long timerCmoisture=0;
unsigned long seconds=0;
int moisture=0;
int moistureL=0;
int moistureH=0;
int wateringtime=0;
unsigned long starttime=0;
int multiplierH=0;

void setup()
{
  pinMode(HEATPIN, OUTPUT);
  pinMode(FANPIN, OUTPUT);
  pinMode(PUMPPIN, OUTPUT);
  digitalWrite(D2, HIGH);
  // Debug console
  Serial.begin(9600);
  
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  //Blynk.syncAll();
  Serial.println("Initialisiere Sensoren....");
  dht.begin();
  sensors.begin();
  sensors.getDeviceCount();
  rtc.begin();

  
  // Setup a function to be called every * second
  timer.setInterval(1000L, sendBoxSensor);
  timerBox = timer.setInterval(2000L, readBoxSensor);
  timerTube = timer.setInterval(4000L, readTubeSensor);
  timerCbox = timer.setInterval(2000L, ctrlBox);
  timerCair;
  timer.setInterval(10000L, clockDisplay);
  timerCalarm = timer.setInterval(5000L, ctrlAlarm);
  timer.setInterval(2500L, ctrlTimes);
  timer.setInterval(2000L, erase_DayCount);
  timerCmoisture=timer.setInterval(60000L, ctrlMoisture);
}

BLYNK_CONNECTED()
{
  // Sync pins with a little delay
  int syncPins[] = { V1, V2, V3, V4, V5, V6, V7, V8 ,V9 ,V10 ,V11 ,V12 ,V13 ,V14, V15, V16, V17 ,V18 ,V19, V20 ,V21, V22 ,V23 ,V24 ,V25 ,V26 ,V27 ,V28 ,V29 ,V30 ,V31 ,V32 ,V33 ,V34 ,V35 ,V36 , V37 ,V38 ,V39 ,V40 ,V41 ,V42 ,V43 ,V44 ,V45 ,V46 ,V47 ,V48 ,V49 ,V50};
  
  for(int i=0;i<sizeof(syncPins)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins[i]));
    Blynk.syncVirtual(syncPins[i]);
    delay(500);
  }
}


/*
BLYNK_CONNECTED() {
  Blynk.syncAll();
}*/

BLYNK_WRITE(V47){   // add a numeric input on V36 range 0 to 30 (seconds)
  int multiplierH_input = param.asFloat();
  multiplierH = multiplierH_input;
  Serial.println(String("Multiplikator Heizung eingestellt auf : ")+(multiplierH)+(String(" %")));
  
  }  //<--- MISSING EARLIER

BLYNK_WRITE(V45){   // add a numeric input on V36 range 0 to 30 (seconds)
  float minutes_input = param.asFloat();
  float minutes = minutes_input;
  Serial.println(String("Interval Bodenfeuchte messen eingestellt auf: ")+(minutes)+(String(" Minuten")));
  timer.deleteTimer(timerCmoisture);
  seconds = minutes * 60;
  Serial.println(String("Millis = ")+(seconds));
  timerCmoisture = timer.setInterval(seconds * 1000L, ctrlMoisture);
  Serial.println(timerCmoisture);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V40){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Boxsensor lesen eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerBox);
  timerBox = timer.setInterval(seconds * 1000L, readBoxSensor);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V39){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Zuluftsensor lesen eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerTube);
  timerTube = timer.setInterval(seconds * 1000L, readTubeSensor);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V38){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Alarm auslösen eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerCalarm);
  timerCalarm = timer.setInterval(seconds * 1000L, ctrlAlarm);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V37){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Zulufttemperatur regeln eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerCair);
  timerCair = timer.setInterval(seconds * 1000L, ctrlAir);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V36){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Luftfeuchtigkeit regeln eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerCbox);
  timerCbox = timer.setInterval(seconds * 1000L, ctrlBox);
  
}  //<--- MISSING EARLIER



// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 2
BLYNK_WRITE(V2)
{
  float inputTEMPL_day_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_day_s=inputTEMPL_day_s;
  Serial.print("Minimale Tagestemperatur Samen eingestellt auf : ");
  Serial.println(TEMPL_day_s);
}

BLYNK_WRITE(V19)
{
  float inputTEMPL_day_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_day_g=inputTEMPL_day_g;
  Serial.print("Minimale Tagestemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPL_day_g);
}

BLYNK_WRITE(V28)
{
  float inputTEMPL_day_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_day_b=inputTEMPL_day_b;
  Serial.print("Minimale Tagestemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPL_day_b);
}

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 2
BLYNK_WRITE(V3)
{
  float inputTEMPH_day_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_day_s=inputTEMPH_day_s;
  Serial.print("Maximale Tagestemperatur Samen eingestellt auf : ");
  Serial.println(TEMPH_day_s);
}

BLYNK_WRITE(V20)
{
  float inputTEMPH_day_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_day_g=inputTEMPH_day_g;
  Serial.print("Maximale Tagestemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPH_day_g);
}

BLYNK_WRITE(V29)
{
  float inputTEMPH_day_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_day_b=inputTEMPH_day_b;
  Serial.print("Maximale Tagestemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPH_day_b);
}

BLYNK_WRITE(V11)
{
  float inputTEMPH_night_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_night_s=inputTEMPH_night_s;
  Serial.print("Maximale Nachttemperatur Samen eingestellt auf : ");
  Serial.println(TEMPH_night_s);
}

BLYNK_WRITE(V22)
{
  float inputTEMPH_night_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_night_g=inputTEMPH_night_g;
  Serial.print("Maximale Nachttemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPH_night_g);
}

BLYNK_WRITE(V31)
{
  float inputTEMPH_night_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_night_b=inputTEMPH_night_b;
  Serial.print("Maximale Nachttemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPH_night_b);
}

BLYNK_WRITE(V12)
{
  float inputTEMPL_night_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_night_s=inputTEMPL_night_s;
  Serial.print("Minimale Nachttemperatur Samen eingestellt auf : ");
  Serial.println(TEMPL_night_s);
}

BLYNK_WRITE(V23)
{
  float inputTEMPL_night_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_night_g=inputTEMPL_night_g;
  Serial.print("Minimale Nachttemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPL_night_g);
}

BLYNK_WRITE(V30)
{
  float inputTEMPL_night_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_night_b=inputTEMPL_night_b;
  Serial.print("Minimale Nachttemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPL_night_b);
}

BLYNK_WRITE(V4)
{
  float inputHUML_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUML_s=inputHUML_s;
  Serial.print("Minimale Luftfeuchtigkeit Samen eingestellt auf : ");
  Serial.println(HUML_s);
  }  

BLYNK_WRITE(V24)
{
  float inputHUML_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUML_g=inputHUML_g;
  Serial.print("Minimale Luftfeuchtigkeit Wachstum eingestellt auf : ");
  Serial.println(HUML_g);
  }  

BLYNK_WRITE(V32)
{
  float inputHUML_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUML_b=inputHUML_b;
  Serial.print("Minimale Luftfeuchtigkeit Blüte eingestellt auf : ");
  Serial.println(HUML_b);
  }    

BLYNK_WRITE(V7)
{
  float inputHUMH_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUMH_s=inputHUMH_s;
  Serial.print("Maximale Luftfeuchtigkeit Samen eingestellt auf : ");
  Serial.println(HUMH_s);
  }  

BLYNK_WRITE(V25)
{
  float inputHUMH_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUMH_g=inputHUMH_g;
  Serial.print("Maximale Luftfeuchtigkeit Wachstum eingestellt auf : ");
  Serial.println(HUMH_g);
  }   

BLYNK_WRITE(V33)
{
  float inputHUMH_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUMH_b=inputHUMH_b;
  Serial.print("Maximale Luftfeuchtigkeit Blüte eingestellt auf : ");
  Serial.println(HUMH_b);
  }     

BLYNK_WRITE(V13)
{
  float inputday_begin_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_begin_s=inputday_begin_s;
  Serial.print("Startzeit Tag Samen eingestellt auf : ");
  Serial.println(day_begin);
  }  

BLYNK_WRITE(V26)
{
  float inputday_begin_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_begin_g=inputday_begin_g;
  Serial.print("Startzeit Tag Wachstum eingestellt auf : ");
  Serial.println(day_begin_g);
  }    

BLYNK_WRITE(V34)
{
  float inputday_begin_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_begin_b=inputday_begin_b;
  Serial.print("Startzeit Tag Blüte eingestellt auf : ");
  Serial.println(day_begin_b);
  }    
  

BLYNK_WRITE(V14)
{
  float inputday_end_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_end_s=inputday_end_s;
  Serial.print("Endzeit Tag Samen eingestellt auf : ");
  Serial.println(day_end_s);
  }    

BLYNK_WRITE(V27)
{
  float inputday_end_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_end_g=inputday_end_g;
  Serial.print("Endzeit Tag Wachstum eingestellt auf : ");
  Serial.println(day_end_g);
  }      

BLYNK_WRITE(V35)
{
  float inputday_end_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_end_b=inputday_end_b;
  Serial.print("Endzeit Tag Blüte eingestellt auf : ");
  Serial.println(day_end_b);
  }      
  

BLYNK_WRITE(V15)
{
  float inputsensor_alarm = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  sensor_alarm=inputsensor_alarm;
  Serial.print("Alarm Schwellenwert : ");
  Serial.print(sensor_alarm);
  Serial.println(" °C");
  }

BLYNK_WRITE(V42)
{
  float inputmoistureL = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  moistureL=inputmoistureL;
  Serial.print("Minimale Bodenfeuchte eingestellt auf : ");
  Serial.print(moistureL);
  Serial.println(" %");
  }    

BLYNK_WRITE(V43)
{
  float inputmoistureH = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  moistureH=inputmoistureH;
  Serial.print("Maximale Bodenfeuchte eingestellt auf : ");
  Serial.print(moistureH);
  Serial.println(" %");
  }

BLYNK_WRITE(V44)
{
  float inputwateringtime = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  wateringtime=inputwateringtime;
  Serial.print("Pumpenlaufzeit eingestellt auf : ");
  Serial.print(wateringtime);
  Serial.println(" Sekunden");
  }      

BLYNK_WRITE(V17)
{
  int input_erase = param.asInt(); // assigning incoming value from pin V1 to a variable
  erase_day_count = input_erase;
  Serial.println(String("lösche Tageszähler!!Tageszähler :")+(erase_day_count));

  // process received value
}




BLYNK_WRITE(V21)
{
  switch (param.asInt())
  {
    case 1: // Item 1
      Serial.println("Samenstadium aktiviert!!");
      TEMPL_day=TEMPL_day_s;
      TEMPH_day=TEMPH_day_s;
      TEMPH_night=TEMPH_night_s;
      TEMPL_night=TEMPL_night_s;
      day_begin=day_begin_s;
      day_end=day_end_s;
      HUML=HUML_s;
      HUMH=HUMH_s;
      Serial.println(HUML);
      break;
    case 2: // Item 2
      Serial.println("Wachstumsstadium aktiviert!!");
      TEMPL_day=TEMPL_day_g;
      TEMPH_day=TEMPH_day_g;
      TEMPH_night=TEMPH_night_g;
      TEMPL_night=TEMPL_night_g;
      day_begin=day_begin_g;
      day_end=day_end_g;
      HUML=HUML_g;
      HUMH=HUMH_g;
      Serial.print(TEMPH_night_g, TEMPL_night_g);
      break;
    case 3: // Item 3
      Serial.println("Blütestadium aktiviert!!");
      TEMPL_day=TEMPL_day_b;
      TEMPH_day=TEMPH_day_b;
      TEMPH_night=TEMPH_night_b;
      TEMPL_night=TEMPL_night_b;
      day_begin=day_begin_b;
      day_end=day_end_b;
      HUML=HUML_b;
      HUMH=HUMH_b;
      break;
    default:
      Serial.println("Unknown item selected");
  }
}


void readTubeSensor()
{
 if (!sensors.getAddress(insideThermometer, 0)) 
    {
      Serial.println("Unable to find address for Device 0");
      Blynk.notify("Fehler beim lesen des Zuluftsensors!!");
      return;
     }
  sensors.requestTemperatures(); // Send the command to get temperatures
  sensors.setResolution(insideThermometer, 12);
  float inputt_Tube = sensors.getTempCByIndex(0);
  t_Tube = inputt_Tube;  
}

void readBoxSensor()
{
  
  float inputh = dht.readHumidity();
  h = inputh;
  float inputt_Box = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  t_Box = inputt_Box;
  //Serial.println(t_Tube);
  if (isnan(h) || isnan(t_Box)) 
  {
    Serial.println("Failed to read from DHT sensor!");
    Blynk.notify("Fehler beim lesen des Boxsensors!!");
    return;
  }
}

void ctrlMoisture()
{
  int inputmoisture = analogRead(MOISTUREPIN);
  moisture = map(inputmoisture , 857, 438, 0, 100);
  // print out the value you read:
  Serial.println(String("Bodenfeuchte beträgt : ")+(moisture)+(String(" %")));
  if (moisture <= moistureL)
   {
    Serial.println("Boden zu trocken");
    Blynk.setProperty(V41, "color", "BLYNK_RED");
    analogWrite(PUMPPIN, 0);
    Blynk.virtualWrite(V46, 255);
    starttime = millis();
    //delay(3000);
    //digitalWrite(D2, HIGH);
    Serial.println(starttime);
   }
  else if (moisture >= moistureH)
   {
    Blynk.setProperty(V41, "color", "BLYNK_BLUE");
   }
  else
  {
   Blynk.setProperty(V41, "color", "BLYNK_GREEN");  
  }
}


  
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendBoxSensor()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  //Serial.println(t_Box);
  //Serial.println(t_Tube);
  Blynk.virtualWrite(V5, t_Box);
  Blynk.virtualWrite(V6, h);
  Blynk.virtualWrite(V8, t_Tube);
  Blynk.virtualWrite(V41, moisture);
}

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "." + month() + "." + year();
  Serial.print("Zeit: ");
  Serial.print(currentTime);
  Serial.print(" Datum: ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V9, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V10, currentDate);
}

void ctrlTimes()
{
  int input_actual_day = int(day());
  //Serial.println(input_actual_day);
    if (input_actual_day != actual_day)
      {
        day_count = day_count+1;
        actual_day = input_actual_day;
        Serial.println(String("Tageszaehler: ")+(day_count));
        Blynk.virtualWrite(V16, day_count);
      }
     
     
}

void erase_DayCount()
  {if (erase_day_count > 0)
    {
      day_count=0;
    }
  }

void ctrlAlarm()
{  
  //sensors.requestTemperatures(); // Send the command to get temperatures
  //float t_Tube=sensors.getTempCByIndex(0);
  //float t = dht.readTemperature();
  int currentHour = int(hour());// + ":" + minute() + ":" + second();  
  if(currentHour >= day_begin and currentHour <= day_end)  
    {if (t_Tube <= TEMPL_day-sensor_alarm) 
      {
       //Serial.print("kritischer Sensorwert box --> zu tief")+(TEMPL_day-sensor_alarm);
       Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu tief!!");
      }
    else if (t_Tube >= TEMPH_day+sensor_alarm)
      {
        //Serial.print("kritischer Sensorwert --> zu hoch")+(TEMPH_day+sensor_alarm);
        Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu hoch!!");
      }
    }
  else
    {if (t_Tube <= (TEMPL_night-sensor_alarm))
      {
        Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu tief!!");
      }
     else if (t_Tube >= (TEMPH_night+sensor_alarm))
     {
        Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu hoch!!");
     }
    
    }
   //float t = dht.readTemperature(); 
   if(currentHour >= day_begin and currentHour <= day_end)  
    {if (t_Box <= (TEMPL_day-sensor_alarm)) 
      {
       //Serial.print("kritischer Sensorwert --> zu tief")+(TEMPL_day-sensor_alarm);
       Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu tief!!");
      }
    else if (t_Box >= TEMPH_day+sensor_alarm)
      {
        //Serial.print("kritischer Sensorwert --> zu hoch")+(TEMPH_day+sensor_alarm);
        Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu hoch!!");
      }
    }
  else
    {if (t_Box <= (TEMPL_night-sensor_alarm))
      {
        Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu tief!!");
      }
     else if (t_Box >= (TEMPH_night+sensor_alarm))
     {
        Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu hoch!!");
     }
    
  } 
}    

void ctrlAir()
{
  int currentHour = int(hour());// + ":" + minute() + ":" + second();
  Blynk.syncVirtual(V21);
  Serial.print("Temperatur Ansaugkanal : ");
  Serial.print(t_Tube);  
  Serial.println(" °C");
  //float t_Tube=sensors.getTempCByIndex(0);
if(currentHour >= day_begin and currentHour <= day_end)
  { Serial.println("It's Daytime");                                 
      if(t_Tube <= TEMPL_day)
      {if (helligkeit >= 1023)
        {helligkeit=1023;}
        if (helligkeit < 1023)
          {
            helligkeit=helligkeit+(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String(" % erhöhen!!")));
            //delay(2000);
          }
        }
  
  
      else if(t_Tube >= TEMPH_day)
        {if (helligkeit <= 1)
          {helligkeit=0;}
        if (helligkeit >= 1)
          {
            helligkeit=helligkeit-(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String("% verringern!!")));
            //delay(2000);
            }    
        }
        else
          {
            Serial.println("Heizung kalibriert!!");
          }
   }
else   
  {Serial.println("It's nighttime!!");
      if(t_Tube <= TEMPL_night)
      {if (helligkeit >= 1023)
        {helligkeit=1023;}
        if (helligkeit < 1023)
          {
            helligkeit=helligkeit+(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String("% erhöhen!!")));
            //delay(2000);
          }
        }
  
  
      else if(t_Tube >= TEMPH_night)
        {if (helligkeit <= 1)
          {helligkeit=0;}
        if (helligkeit >= 1)
          {
            helligkeit=helligkeit-(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String("% verringern!!")));
            //delay(2000);
            }    
        }
        else
          {
            Serial.println("Heizung kalibriert!!");
          }
   }
}

void ctrlBox()
{
  //float h = dht.readHumidity();
  //float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  //Serial.print("Temperatur Box : ");
  //Serial.print(t);
  //Serial.println(" °C      ");
  Serial.print("Luftfeuchtigkeit: ");
  Serial.print(h);
  Serial.println(" %");
  
  
  if (h >= HUMH)
  {
    digitalWrite(FANPIN, HIGH);
    Serial.println("Luefter auf Stufe 2!");
    Blynk.virtualWrite(V1, 255);
  }
  else if (h <= HUML)
  {
    digitalWrite(FANPIN, LOW);
    Serial.println("Luefter auf Stufe 1!");
    Blynk.virtualWrite(V1, 0);
  }
  else
  {
    Serial.println("Luftfeuchtigkeit wird abgesenkt!!");
  }
}  

void loop()
{
  Blynk.run();
  timer.run();
   int pinstate = digitalRead(PUMPPIN);
   if (pinstate == 0)
      {
        unsigned long currentMillis = millis();
        Serial.println("zähle Millis!!");
        Serial.println(currentMillis);
        Serial.println(starttime);
        
       
      if (currentMillis <= (wateringtime*1000+starttime)) 
        {
          Serial.println("in Schleife");
          
        }
      
      else
        {
          
          analogWrite(PUMPPIN , 1023);
          Blynk.virtualWrite(V46, 0);
          Serial.println("Pumpe aus!!");
          
         }
      }

}


To avoid this issue, I sync virtual pins in the setup , before the timers declaration.

Ja das hatte ich vorher auch mit Blynk.syncall()
Aber das funktionierte auch nicht

Blynk.syncall() is not good over 20 vpins.
Use your array and loop with delay .
It’s the best solution, but before the timers declaration.

void setup()
{
  pinMode(HEATPIN, OUTPUT);
  pinMode(FANPIN, OUTPUT);
  pinMode(PUMPPIN, OUTPUT);
  digitalWrite(D2, HIGH);
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  update();
  

  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  //Blynk.syncAll();
  Serial.println("Initialisiere Sensoren....");
  dht.begin();
  sensors.begin();
  sensors.getDeviceCount();
  rtc.begin();

  
  // Setup a function to be called every * second
  timer.setInterval(1000L, sendBoxSensor);
  timerBox = timer.setInterval(2000L, readBoxSensor);
  timerTube = timer.setInterval(4000L, readTubeSensor);
  timerCbox = timer.setInterval(2000L, ctrlBox);
  timerCair;
  timer.setInterval(10000L, clockDisplay);
  timerCalarm = timer.setInterval(5000L, ctrlAlarm);
  timer.setInterval(2500L, ctrlTimes);
  timer.setInterval(2000L, erase_DayCount);
  timerCmoisture=timer.setInterval(60000L, ctrlMoisture);
}

void update()
{
if (Blynk.connected())
{
Serial.println("Verbindung zu Blynk hergestellt!!");
// Sync pins with a little delay
  int syncPins[] = { V1, V2, V3, V4, V5, V6, V7, V8 ,V9 ,V10 ,V11 ,V12 ,V13 ,V14, V15, V16, V17 ,V18 ,V19, V20 ,V21, V22 ,V23 ,V24 ,V25 ,V26 ,V27 ,V28 ,V29 ,V30 ,V31 ,V32 ,V33 ,V34 ,V35 ,V36 , V37 ,V38 ,V39 ,V40 ,V41 ,V42 ,V43 ,V44 ,V45 ,V46 ,V47 ,V48 ,V49 ,V50};
  
  for(int i=0;i<sizeof(syncPins)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins[i]));
    Blynk.syncVirtual(syncPins[i]);
    delay(500);
  }
}
}
´´´
hab es jetzt so gemacht aber es funktioniert trotzdem nicht

noch eine Idee zufällig?

hab es jetzt so gemacht aber es funktioniert trotzdem nicht

noch eine Idee zufällig?

Syncing 50 pins will take 25 seconds, which will cause a Blynk disconnection.
Blynk can tolerate up to around 10 sync/writes per second without problems, so I’d reduce the delay to 100ms and split the loop into two sections, with a Blynk.run() after you’ve done the first section.

Pete.

void update()
{
if (Blynk.connected())
{
Serial.println("Verbindung zu Blynk hergestellt!!");
// Sync pins with a little delay
  int syncPins[] = { V1, V2, V3, V4, V5, V6, V7, V8 ,V9 ,V10 ,V11 ,V12 ,V13 ,V14, V15, V16, V17 ,V18 ,V19, V20 ,V21, V22 ,V23 ,V24 ,V25};
  
  for(int i=0;i<sizeof(syncPins)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins[i]));
    Blynk.syncVirtual(syncPins[i]);
    delay(100);
  }
Blynk.run();
// Sync pins with a little delay
  int syncPins2[] = {V26 ,V27 ,V28 ,V29 ,V30 ,V31 ,V32 ,V33 ,V34 ,V35 ,V36 , V37 ,V38 ,V39 ,V40 ,V41 ,V42 ,V43 ,V44 ,V45 ,V46 ,V47 ,V48 ,V49 ,V50};
  
  for(int i=0;i<sizeof(syncPins2)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins2[i]));
    Blynk.syncVirtual(syncPins2[i]);
    delay(100);
  }

}
}
´´´

funktioniert immer noch nicht oder bin ich zu blöd?

What exactly happens when you run this code?

Pete.

er synchrisiert alles pins und regelt die feuchtigkeit alle 2,5 sekunden obwohl in der app 9,8 sekunden eingestellt sind

I don’t see a 9800ms timer in your code.

However, your void loop does break all the Blynk rules.

Pete.

1 Like

Der Timer Cair bekommt seinen Wert aus der App über einen numeric input… Löscht den bestehenden timer und ersetzt diesen

Warum verstößt mein Loop gegen alle blynk Regeln?

If it’s the V45 callback where you are deleting the timer then I’m not sure you’re referencing the timer correctly. I thought you had to do that using the timer ID.

Have you read the document I linked to?

Pete.

//DHT11 And NodeMCU With Blynk
//My GitHub https://github.com/manoranjan2050
//My Hackster.io https://www.hackster.io/Manoranjan2050
//This Video Link https://youtu.be/0dbws1i2GoE

#define BLYNK_PRINT Serial
 

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
 
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "pCg3S9ckgvum5MpDak-urNkMfmMt_iQS";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Matze K";
char pass[] = "77724029983590303232";
 
#define DHTPIN 0          // D3
#define HEATPIN 13        //D7
#define FANPIN 15         //D1
#define PUMPPIN 4
#define MOISTUREPIN A0

#define BLYNK_GREEN     "#23C48E"
#define BLYNK_BLUE      "#04C0F8"
#define BLYNK_YELLOW    "#ED9D00"
#define BLYNK_RED       "#D3435C"
#define BLYNK_DARK_BLUE "#5F7CD8"  


// Data wire is plugged into port D6 on the Arduino
#define ONE_WIRE_BUS 12

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device address
DeviceAddress insideThermometer;

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301
 
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
WidgetRTC rtc;
 
float TEMPH_day=0;
float TEMPH_day_s=0;
float TEMPH_day_g=0;
float TEMPH_day_b=0;
float TEMPL_day=0;
float TEMPL_day_s=0;
float TEMPL_day_g=0;
float TEMPL_day_b=0;
float TEMPH_night=0;
float TEMPH_night_s=0;
float TEMPH_night_g=0;
float TEMPH_night_b=0;
float TEMPL_night=0;
float TEMPL_night_s=0;
float TEMPL_night_g=0;
float TEMPL_night_b=0;
float HUML=0;
float HUML_s=0;
float HUML_g=0;
float HUML_b=0;
float HUMH=0;
float HUMH_s=0;
float HUMH_g=0;
float HUMH_b=0;
float helligkeit=0;
int day_begin=0;
int day_begin_s=0;
int day_begin_g=0;
int day_begin_b=0;
int day_end=0;
int day_end_s=0;
int day_end_g=0;
int day_end_b=0;
float sensor_alarm=0;
float h=0;
float t_Box=0;
float t_Tube=0;
int actual_day=0;
int day_count=0;
int erase_day_count=0;
int seed_state=0;
int grow_state=0;
int bloom_state=0;
float timerCbox =1;
float timerCair;
float timerCalarm=1;
float timerTube=1;
float timerBox=1;
unsigned long timerCmoisture=0;
unsigned long seconds=0;
int moisture=0;
int moistureL=0;
int moistureH=0;
int wateringtime=0;
unsigned long starttime=0;
int multiplierH=0;

void setup()
{
  pinMode(HEATPIN, OUTPUT);
  pinMode(FANPIN, OUTPUT);
  pinMode(PUMPPIN, OUTPUT);
  digitalWrite(D2, HIGH);
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  update();
  

  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  //Blynk.syncAll();
  Serial.println("Initialisiere Sensoren....");
  dht.begin();
  sensors.begin();
  sensors.getDeviceCount();
  rtc.begin();

  
  // Setup a function to be called every * second
  timer.setInterval(1000L, sendBoxSensor);
  timerBox = timer.setInterval(2000L, readBoxSensor);
  timerTube = timer.setInterval(4000L, readTubeSensor);
  timerCbox = timer.setInterval(2000L, ctrlBox);
  timerCair;
  timer.setInterval(10000L, clockDisplay);
  timerCalarm = timer.setInterval(5000L, ctrlAlarm);
  timer.setInterval(2500L, ctrlTimes);
  timer.setInterval(2000L, erase_DayCount);
  timerCmoisture=timer.setInterval(60000L, ctrlMoisture);
  timer.setInterval(1000L, ctrlPtime);
}

void update()
{
if (Blynk.connected())
{
Serial.println("Verbindung zu Blynk hergestellt!!");
// Sync pins with a little delay
  int syncPins[] = { V1, V2, V3, V4, V5, V6, V7, V8 ,V9 ,V10 ,V11 ,V12 ,V13 ,V14, V15, V16,V18 ,V19, V20 ,V21, V22 ,V23 ,V24 ,V25};
  
  for(int i=0;i<sizeof(syncPins)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins[i]));
    Blynk.syncVirtual(syncPins[i]);
    delay(100);
  }
Blynk.run();delay(2000);
// Sync pins with a little delay
  int syncPins2[] = {V26 ,V27 ,V28 ,V29 ,V30 ,V31 ,V32 ,V33 ,V34 ,V35 ,V36 , V37 ,V38 ,V39 ,V40 ,V41 ,V42 ,V43 ,V44 ,V45 ,V46 ,V47 ,V48 ,V49 ,V50};
  
  for(int i=0;i<sizeof(syncPins2)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins2[i]));
    Blynk.syncVirtual(syncPins2[i]);
    delay(100);
  }

}
}
/*
BLYNK_CONNECTED()
{
  // Sync pins with a little delay
  int syncPins[] = { V1, V2, V3, V4, V5, V6, V7, V8 ,V9 ,V10 ,V11 ,V12 ,V13 ,V14, V15, V16, V17 ,V18 ,V19, V20 ,V21, V22 ,V23 ,V24 ,V25 ,V26 ,V27 ,V28 ,V29 ,V30 ,V31 ,V32 ,V33 ,V34 ,V35 ,V36 , V37 ,V38 ,V39 ,V40 ,V41 ,V42 ,V43 ,V44 ,V45 ,V46 ,V47 ,V48 ,V49 ,V50};
  
  for(int i=0;i<sizeof(syncPins)/sizeof(int);i++)
  {
    Serial.println(String("Syncing: ") + (syncPins[i]));
    Blynk.syncVirtual(syncPins[i]);
    delay(500);
  }
};

/*
BLYNK_CONNECTED() {
  Blynk.syncAll();
}*/

BLYNK_WRITE(V47){   // add a numeric input on V36 range 0 to 30 (seconds)
  int multiplierH_input = param.asFloat();
  multiplierH = multiplierH_input;
  Serial.println(String("Multiplikator Heizung eingestellt auf : ")+(multiplierH)+(String(" %")));
  
  }  //<--- MISSING EARLIER

BLYNK_WRITE(V45){   // add a numeric input on V36 range 0 to 30 (seconds)
  float minutes_input = param.asFloat();
  float minutes = minutes_input;
  Serial.println(String("Interval Bodenfeuchte messen eingestellt auf: ")+(minutes)+(String(" Minuten")));
  timer.deleteTimer(timerCmoisture);
  seconds = minutes * 60;
  Serial.println(String("Millis = ")+(seconds));
  timerCmoisture = timer.setInterval(seconds * 1000L, ctrlMoisture);
  Serial.println(timerCmoisture);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V40){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Boxsensor lesen eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerBox);
  timerBox = timer.setInterval(seconds * 1000L, readBoxSensor);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V39){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Zuluftsensor lesen eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerTube);
  timerTube = timer.setInterval(seconds * 1000L, readTubeSensor);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V38){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Alarm auslösen eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerCalarm);
  timerCalarm = timer.setInterval(seconds * 1000L, ctrlAlarm);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V37){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Zulufttemperatur regeln eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerCair);
  timerCair = timer.setInterval(seconds * 1000L, ctrlAir);
  
}  //<--- MISSING EARLIER

BLYNK_WRITE(V36){   // add a numeric input on V36 range 0 to 30 (seconds)
  float seconds_input = param.asFloat();
  float seconds = seconds_input;
  Serial.println(String("Interval Luftfeuchtigkeit regeln eingestellt auf: ")+(seconds)+(String(" Sekunden")));
  timer.deleteTimer(timerCbox);
  timerCbox = timer.setInterval(seconds * 1000L, ctrlBox);
  
}  //<--- MISSING EARLIER



// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 2
BLYNK_WRITE(V2)
{
  float inputTEMPL_day_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_day_s=inputTEMPL_day_s;
  Serial.print("Minimale Tagestemperatur Samen eingestellt auf : ");
  Serial.println(TEMPL_day_s);
}

BLYNK_WRITE(V19)
{
  float inputTEMPL_day_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_day_g=inputTEMPL_day_g;
  Serial.print("Minimale Tagestemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPL_day_g);
}

BLYNK_WRITE(V28)
{
  float inputTEMPL_day_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_day_b=inputTEMPL_day_b;
  Serial.print("Minimale Tagestemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPL_day_b);
}

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 2
BLYNK_WRITE(V3)
{
  float inputTEMPH_day_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_day_s=inputTEMPH_day_s;
  Serial.print("Maximale Tagestemperatur Samen eingestellt auf : ");
  Serial.println(TEMPH_day_s);
}

BLYNK_WRITE(V20)
{
  float inputTEMPH_day_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_day_g=inputTEMPH_day_g;
  Serial.print("Maximale Tagestemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPH_day_g);
}

BLYNK_WRITE(V29)
{
  float inputTEMPH_day_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_day_b=inputTEMPH_day_b;
  Serial.print("Maximale Tagestemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPH_day_b);
}

BLYNK_WRITE(V11)
{
  float inputTEMPH_night_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_night_s=inputTEMPH_night_s;
  Serial.print("Maximale Nachttemperatur Samen eingestellt auf : ");
  Serial.println(TEMPH_night_s);
}

BLYNK_WRITE(V22)
{
  float inputTEMPH_night_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_night_g=inputTEMPH_night_g;
  Serial.print("Maximale Nachttemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPH_night_g);
}

BLYNK_WRITE(V31)
{
  float inputTEMPH_night_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPH_night_b=inputTEMPH_night_b;
  Serial.print("Maximale Nachttemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPH_night_b);
}

BLYNK_WRITE(V12)
{
  float inputTEMPL_night_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_night_s=inputTEMPL_night_s;
  Serial.print("Minimale Nachttemperatur Samen eingestellt auf : ");
  Serial.println(TEMPL_night_s);
}

BLYNK_WRITE(V23)
{
  float inputTEMPL_night_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_night_g=inputTEMPL_night_g;
  Serial.print("Minimale Nachttemperatur Wachstum eingestellt auf : ");
  Serial.println(TEMPL_night_g);
}

BLYNK_WRITE(V30)
{
  float inputTEMPL_night_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  TEMPL_night_b=inputTEMPL_night_b;
  Serial.print("Minimale Nachttemperatur Blüte eingestellt auf : ");
  Serial.println(TEMPL_night_b);
}

BLYNK_WRITE(V4)
{
  float inputHUML_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUML_s=inputHUML_s;
  Serial.print("Minimale Luftfeuchtigkeit Samen eingestellt auf : ");
  Serial.println(HUML_s);
  }  

BLYNK_WRITE(V24)
{
  float inputHUML_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUML_g=inputHUML_g;
  Serial.print("Minimale Luftfeuchtigkeit Wachstum eingestellt auf : ");
  Serial.println(HUML_g);
  }  

BLYNK_WRITE(V32)
{
  float inputHUML_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUML_b=inputHUML_b;
  Serial.print("Minimale Luftfeuchtigkeit Blüte eingestellt auf : ");
  Serial.println(HUML_b);
  }    

BLYNK_WRITE(V7)
{
  float inputHUMH_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUMH_s=inputHUMH_s;
  Serial.print("Maximale Luftfeuchtigkeit Samen eingestellt auf : ");
  Serial.println(HUMH_s);
  }  

BLYNK_WRITE(V25)
{
  float inputHUMH_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUMH_g=inputHUMH_g;
  Serial.print("Maximale Luftfeuchtigkeit Wachstum eingestellt auf : ");
  Serial.println(HUMH_g);
  }   

BLYNK_WRITE(V33)
{
  float inputHUMH_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  HUMH_b=inputHUMH_b;
  Serial.print("Maximale Luftfeuchtigkeit Blüte eingestellt auf : ");
  Serial.println(HUMH_b);
  }     

BLYNK_WRITE(V13)
{
  float inputday_begin_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_begin_s=inputday_begin_s;
  Serial.print("Startzeit Tag Samen eingestellt auf : ");
  Serial.println(day_begin);
  }  

BLYNK_WRITE(V26)
{
  float inputday_begin_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_begin_g=inputday_begin_g;
  Serial.print("Startzeit Tag Wachstum eingestellt auf : ");
  Serial.println(day_begin_g);
  }    

BLYNK_WRITE(V34)
{
  float inputday_begin_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_begin_b=inputday_begin_b;
  Serial.print("Startzeit Tag Blüte eingestellt auf : ");
  Serial.println(day_begin_b);
  }    
  

BLYNK_WRITE(V14)
{
  float inputday_end_s = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_end_s=inputday_end_s;
  Serial.print("Endzeit Tag Samen eingestellt auf : ");
  Serial.println(day_end_s);
  }    

BLYNK_WRITE(V27)
{
  float inputday_end_g = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_end_g=inputday_end_g;
  Serial.print("Endzeit Tag Wachstum eingestellt auf : ");
  Serial.println(day_end_g);
  }      

BLYNK_WRITE(V35)
{
  float inputday_end_b = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  day_end_b=inputday_end_b;
  Serial.print("Endzeit Tag Blüte eingestellt auf : ");
  Serial.println(day_end_b);
  }      
  

BLYNK_WRITE(V15)
{
  float inputsensor_alarm = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  sensor_alarm=inputsensor_alarm;
  Serial.print("Alarm Schwellenwert : ");
  Serial.print(sensor_alarm);
  Serial.println(" °C");
  }

BLYNK_WRITE(V42)
{
  float inputmoistureL = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  moistureL=inputmoistureL;
  Serial.print("Minimale Bodenfeuchte eingestellt auf : ");
  Serial.print(moistureL);
  Serial.println(" %");
  }    

BLYNK_WRITE(V43)
{
  float inputmoistureH = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  moistureH=inputmoistureH;
  Serial.print("Maximale Bodenfeuchte eingestellt auf : ");
  Serial.print(moistureH);
  Serial.println(" %");
  }

BLYNK_WRITE(V44)
{
  float inputwateringtime = param.asFloat(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  wateringtime=inputwateringtime;
  Serial.print("Pumpenlaufzeit eingestellt auf : ");
  Serial.print(wateringtime);
  Serial.println(" Sekunden");
  }      

BLYNK_WRITE(V17)
{
  int input_erase = param.asInt(); // assigning incoming value from pin V1 to a variable
  erase_day_count = input_erase;
  Serial.println(String("lösche Tageszähler!!Tageszähler :")+(erase_day_count));

  // process received value
}




BLYNK_WRITE(V21)
{
  switch (param.asInt())
  {
    case 1: // Item 1
      Serial.println("Samenstadium aktiviert!!");
      TEMPL_day=TEMPL_day_s;
      TEMPH_day=TEMPH_day_s;
      TEMPH_night=TEMPH_night_s;
      TEMPL_night=TEMPL_night_s;
      day_begin=day_begin_s;
      day_end=day_end_s;
      HUML=HUML_s;
      HUMH=HUMH_s;
      Serial.println(HUML);
      break;
    case 2: // Item 2
      Serial.println("Wachstumsstadium aktiviert!!");
      TEMPL_day=TEMPL_day_g;
      TEMPH_day=TEMPH_day_g;
      TEMPH_night=TEMPH_night_g;
      TEMPL_night=TEMPL_night_g;
      day_begin=day_begin_g;
      day_end=day_end_g;
      HUML=HUML_g;
      HUMH=HUMH_g;
      Serial.print(TEMPH_night_g, TEMPL_night_g);
      break;
    case 3: // Item 3
      Serial.println("Blütestadium aktiviert!!");
      TEMPL_day=TEMPL_day_b;
      TEMPH_day=TEMPH_day_b;
      TEMPH_night=TEMPH_night_b;
      TEMPL_night=TEMPL_night_b;
      day_begin=day_begin_b;
      day_end=day_end_b;
      HUML=HUML_b;
      HUMH=HUMH_b;
      break;
    default:
      Serial.println("Unknown item selected");
  }
}


void readTubeSensor()
{
 if (!sensors.getAddress(insideThermometer, 0)) 
    {
      Serial.println("Unable to find address for Device 0");
      Blynk.notify("Fehler beim lesen des Zuluftsensors!!");
      return;
     }
  sensors.requestTemperatures(); // Send the command to get temperatures
  sensors.setResolution(insideThermometer, 12);
  float inputt_Tube = sensors.getTempCByIndex(0);
  t_Tube = inputt_Tube;  
}

void readBoxSensor()
{
  
  float inputh = dht.readHumidity();
  h = inputh;
  float inputt_Box = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  t_Box = inputt_Box;
  //Serial.println(t_Tube);
  if (isnan(h) || isnan(t_Box)) 
  {
    Serial.println("Failed to read from DHT sensor!");
    Blynk.notify("Fehler beim lesen des Boxsensors!!");
    return;
  }
}

void ctrlPtime()
{
int pinstate = digitalRead(PUMPPIN);
   if (pinstate == 0)
      {
        unsigned long currentMillis = millis();
        Serial.println("zähle Millis!!");
        Serial.println(currentMillis);
        Serial.println(starttime);
        
       
      if (currentMillis <= (wateringtime*1000+starttime)) 
        {
          Serial.println("in Schleife");
          
        }
      
      else
        {
          
          analogWrite(PUMPPIN , 1023);
          Blynk.virtualWrite(V46, 0);
          Serial.println("Pumpe aus!!");
          
         }
      }
}
void ctrlMoisture()
{
  int inputmoisture = analogRead(MOISTUREPIN);
  moisture = map(inputmoisture , 857, 438, 0, 100);
  // print out the value you read:
  Serial.println(String("Bodenfeuchte beträgt : ")+(moisture)+(String(" %")));
  if (moisture <= moistureL)
   {
    Serial.println("Boden zu trocken");
    Blynk.setProperty(V41, "color", "BLYNK_RED");
    analogWrite(PUMPPIN, 0);
    Blynk.virtualWrite(V46, 255);
    starttime = millis();
    //delay(3000);
    //digitalWrite(D2, HIGH);
    Serial.println(starttime);
   }
  else if (moisture >= moistureH)
   {
    Blynk.setProperty(V41, "color", "BLYNK_BLUE");
   }
  else
  {
   Blynk.setProperty(V41, "color", "BLYNK_GREEN");  
  }
}


  
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendBoxSensor()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  //Serial.println(t_Box);
  //Serial.println(t_Tube);
  Blynk.virtualWrite(V5, t_Box);
  Blynk.virtualWrite(V6, h);
  Blynk.virtualWrite(V8, t_Tube);
  Blynk.virtualWrite(V41, moisture);
}

// Digital clock display of the time
void clockDisplay()
{
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "." + month() + "." + year();
  Serial.print("Zeit: ");
  Serial.print(currentTime);
  Serial.print(" Datum: ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V9, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V10, currentDate);
}

void ctrlTimes()
{
  int input_actual_day = int(day());
  //Serial.println(input_actual_day);
    if (input_actual_day != actual_day)
      {
        day_count = day_count+1;
        actual_day = input_actual_day;
        Serial.println(String("Tageszaehler: ")+(day_count));
        Blynk.virtualWrite(V16, day_count);
      }
     
     
}

void erase_DayCount()
  {if (erase_day_count > 0)
    {
      day_count=0;
    }
  }

void ctrlAlarm()
{  
  //sensors.requestTemperatures(); // Send the command to get temperatures
  //float t_Tube=sensors.getTempCByIndex(0);
  //float t = dht.readTemperature();
  int currentHour = int(hour());// + ":" + minute() + ":" + second();  
  if(currentHour >= day_begin and currentHour <= day_end)  
    {if (t_Tube <= TEMPL_day-sensor_alarm) 
      {
       //Serial.print("kritischer Sensorwert box --> zu tief")+(TEMPL_day-sensor_alarm);
       Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu tief!!");
      }
    else if (t_Tube >= TEMPH_day+sensor_alarm)
      {
        //Serial.print("kritischer Sensorwert --> zu hoch")+(TEMPH_day+sensor_alarm);
        Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu hoch!!");
      }
    }
  else
    {if (t_Tube <= (TEMPL_night-sensor_alarm))
      {
        Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu tief!!");
      }
     else if (t_Tube >= (TEMPH_night+sensor_alarm))
     {
        Blynk.notify("Alarm,Temperatursensor Zuluft meldet kritischen Bereich, Temperatur zu hoch!!");
     }
    
    }
   //float t = dht.readTemperature(); 
   if(currentHour >= day_begin and currentHour <= day_end)  
    {if (t_Box <= (TEMPL_day-sensor_alarm)) 
      {
       //Serial.print("kritischer Sensorwert --> zu tief")+(TEMPL_day-sensor_alarm);
       Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu tief!!");
      }
    else if (t_Box >= TEMPH_day+sensor_alarm)
      {
        //Serial.print("kritischer Sensorwert --> zu hoch")+(TEMPH_day+sensor_alarm);
        Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu hoch!!");
      }
    }
  else
    {if (t_Box <= (TEMPL_night-sensor_alarm))
      {
        Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu tief!!");
      }
     else if (t_Box >= (TEMPH_night+sensor_alarm))
     {
        Blynk.notify("Alarm,Temperatursensor Box meldet kritischen Bereich, Temperatur zu hoch!!");
     }
    
  } 
}    

void ctrlAir()
{
  int currentHour = int(hour());// + ":" + minute() + ":" + second();
  Blynk.syncVirtual(V21, V36);
  Serial.print("Temperatur Ansaugkanal : ");
  Serial.print(t_Tube);  
  Serial.println(" °C");
  //float t_Tube=sensors.getTempCByIndex(0);
if(currentHour >= day_begin and currentHour <= day_end)
  { Serial.println("It's Daytime");                                 
      if(t_Tube <= TEMPL_day)
      {if (helligkeit >= 1023)
        {helligkeit=1023;}
        if (helligkeit < 1023)
          {
            helligkeit=helligkeit+(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String(" % erhöhen!!")));
            //delay(2000);
          }
        }
  
  
      else if(t_Tube >= TEMPH_day)
        {if (helligkeit <= 1)
          {helligkeit=0;}
        if (helligkeit >= 1)
          {
            helligkeit=helligkeit-(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String("% verringern!!")));
            //delay(2000);
            }    
        }
        else
          {
            Serial.println("Heizung kalibriert!!");
          }
   }
else   
  {Serial.println("It's nighttime!!");
      if(t_Tube <= TEMPL_night)
      {if (helligkeit >= 1023)
        {helligkeit=1023;}
        if (helligkeit < 1023)
          {
            helligkeit=helligkeit+(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String("% erhöhen!!")));
            //delay(2000);
          }
        }
  
  
      else if(t_Tube >= TEMPH_night)
        {if (helligkeit <= 1)
          {helligkeit=0;}
        if (helligkeit >= 1)
          {
            helligkeit=helligkeit-(multiplierH*10.24);
            analogWrite(HEATPIN, helligkeit);
            Serial.println(helligkeit);
            Blynk.virtualWrite(V0, helligkeit);
            Serial.println(String("Heizkraft um ")+(multiplierH)+(String("% verringern!!")));
            //delay(2000);
            }    
        }
        else
          {
            Serial.println("Heizung kalibriert!!");
          }
   }
}

void ctrlBox()
{
  //float h = dht.readHumidity();
  //float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  //Serial.print("Temperatur Box : ");
  //Serial.print(t);
  //Serial.println(" °C      ");
  Serial.print("Luftfeuchtigkeit: ");
  Serial.print(h);
  Serial.println(" %");
  
  
  if (h >= HUMH)
  {
    digitalWrite(FANPIN, HIGH);
    Serial.println("Luefter auf Stufe 2!");
    Blynk.virtualWrite(V1, 255);
  }
  else if (h <= HUML)
  {
    digitalWrite(FANPIN, LOW);
    Serial.println("Luefter auf Stufe 1!");
    Blynk.virtualWrite(V1, 0);
  }
  else
  {
    Serial.println("Luftfeuchtigkeit wird abgesenkt!!");
  }
}  

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

Sorry hatte vergessen das wieder aus dem loop zu nehmen
war nur zum testen
hab es jetzt bereinigt
das numeric input hängt an V36

was ich nicht verstehe ist, das es funktioniert wenn ich es in der app ändere aber nicht beim sync?

Because you’re calling the update function in your void loop before initialising the timers, there is no timer to delete, and the interval is being set later in the void loop.

Pete.

ok aber wo muss ich denn dann die update funktion ausführen das das vor dem initialisieren der timer geschieht?

Maybe do most of your syncs first, then this one after the timers are declared?

Pete.

guten morgen

habe die update funktion komplett hinter die timer gesetzt und jetzt scheint es zu funktionieren.

vielen danke erstmal oder ist das so nicht gut?

hätte da noch eine frage…ist es möglich die farbe eines gauge zu ändern via befehl

If it works the way you want it to then stick with it.

Here is the documentation for changing widget properties, including colours…

Pete.

vielen vielen dank für die hilfe
jetzt funktioniert es

läuft doch besser als mit nem raspberry pi und python falls du dich erinnerst :wink:

vielen dank nochmal

mit freundlichen grüssen

Matze K