Output switching imself without command

I! I have problem with output logical. When the scketch is uploaded it work well but with many project with many online server blynk code only is do this thing: randomly the output change state, example after time “x” the output change state imself, no programme for change it absolulty nothing are programmed in eventor or other they change imself, i have made many project and all do the same thing, randomly they change state of pin , sometime it glitch and sometime it change for ever( or when the blynk server reconnect (seem to be pike here the problem) it rechange of state output. )Anybody have idea please tank you

#include <WiFiManager.h>
#include <SPI.h>
#include <Wire.h>
#include <FS.h>                   
#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
#include <BlynkSimpleEsp8266.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>          
#include <ArduinoJson.h>          
#define BLYNK_PRINT Serial   
#include <Ticker.h>
#include <DHT.h>
#define PIN_LED   D8   // Pin D4 mapped to pin GPIO2/TXD1 of ESP8266, NodeMCU and WeMoS, control on-board LED
#define DHTPIN 5  
BlynkTimer timer;
DHT dht(DHTPIN,  DHT11);

#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

Ticker     led_ticker;
#define AREF_VOLTAGE 3.27
   
//#define BLYNK_DEBUG
char server[15] = "192.168.4.1" ;
char port[6] = "8080";
char auth[34] = "";


bool shouldSaveConfig = false;


void set_led(byte status)
{
  digitalWrite(LED_BUILTIN, status);
}

void heartBeatPrint(void)
{
  static int num = 1;

  if (Blynk.connected())
  {
    set_led(LOW);
    led_ticker.once_ms(111, set_led, (byte) HIGH);
    Serial.print("B");
  }
  else
  {
    Serial.print("F");
    ESP.restart();
  }

  if (num == 80)
  {
    Serial.println();
    num = 1;
  }
  else if (num++ % 10 == 0)
  {
    Serial.print(" ");
  }
}

void check_status()
{
  static unsigned long checkstatus_timeout = 0;

#define STATUS_CHECK_INTERVAL     6000L

  // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
  if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
  {
    // report status to Blynk
    heartBeatPrint();

    checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
  }
}

void resetting()
{
  if (digitalRead(13) == LOW) 
    {
          WiFiManager wifiManager;
  wifiManager.resetSettings();
      SPIFFS.format();
    Serial.println("BLYNK resset");
  
  ESP.restart();
ESP.reset();
    ESP.restart();
}


}





  void checkPhysicalButtond0()
{
  if (digitalRead(16) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V99, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V99, HIGH);
   }
}
 // void checkPhysicalButtond1()
//{
 // if (digitalRead(5) == LOW) //D1 is GPIO5
   // {
    //  Blynk.virtualWrite(V1, LOW);
   // }
  //  else 
  // {
   // Blynk.virtualWrite(V1, HIGH);
  // }
//}
  void checkPhysicalButtond2()
{
  if (digitalRead(4) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V2, LOW);
   
      Blynk.virtualWrite(V2, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V2, HIGH);

   }
}
  void checkPhysicalButtond3()
  {
  if (digitalRead(0) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V3, LOW);
    
      Blynk.virtualWrite(V0, LOW);
   }
    else 
   {
    Blynk.virtualWrite(V3, HIGH);
       Blynk.virtualWrite(V0, HIGH);

   }
}
  void checkPhysicalButtond4()
{
  if (digitalRead(2) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V4, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V4, HIGH);
   }
}
  void checkPhysicalButtond5()
{
  if (digitalRead(14) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V5, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V5, HIGH);
   }
}
  void checkPhysicalButtond6()
{
  if (digitalRead(12) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V6, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V6, HIGH);
   }
}
  void checkPhysicalButtond7()
{
  if (digitalRead(13) == LOW) //D1 is GPIO5
    {
      
      WiFiManager wifiManager;
      wifiManager.resetSettings();
      SPIFFS.format();
      Blynk.virtualWrite(V7, LOW);
      Serial.println("ERASING");
    SPIFFS.format();
ESP.reset();  // reset button
ESP.restart();
    }
    else 
   {
    Blynk.virtualWrite(V7, HIGH);

   }
}
  void checkPhysicalButtond8()
{
  if (digitalRead(15) == LOW) //D1 is GPIO5
    {
      Blynk.virtualWrite(V8, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V8, HIGH);
   }
}

void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(true); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    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(V20, h);
  Blynk.virtualWrite(V21, t);
}
void setup() {{
    dht.begin();

  // Setup a function to be called every second
  timer.setInterval(10000L, sendSensor);
    
  


  
  pinMode(16, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(200L, checkPhysicalButtond0);
  
}
    // {

  
 // pinMode(5, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
//  timer.setInterval(200L, checkPhysicalButtond1);
//}

     {

  
  pinMode(4, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(200L, checkPhysicalButtond2);
  
}

     {

  
  pinMode(0, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
 timer.setInterval(200L, checkPhysicalButtond3);

}
     {

  
  pinMode(2, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(200L, checkPhysicalButtond4);
}
     {

  
  pinMode(14, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(200L, checkPhysicalButtond5);
}
     {

  
  pinMode(12, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(200L, checkPhysicalButtond6);
}
     {

  
  pinMode(13, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(100L, checkPhysicalButtond7);
  timer.setInterval(10L, resetting);
  
}
     {

  
  pinMode(15, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(100L, checkPhysicalButtond8);
}


   Serial.begin(115200);
  Serial.println();
  //***************DON'T TOUTCH WIFI-MANAGER AND BLYNK PART *************************
  //clean FS, for testing
  //SPIFFS.format();
  //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");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);
        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");
          strcpy(server, json["server"]);
          strcpy(port, json["port"]);
          strcpy(auth, json["auth"]);
        } else {
          Serial.println("failed to load json config");
          
        }
      }
    }
  } else {
    Serial.println("failed to mount FS");
    SPIFFS.format();
  }
  //end read
  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  WiFiManagerParameter custom_server("server", "server", server, 15);
  WiFiManagerParameter custom_port("port", "port", port, 6);
  WiFiManagerParameter custom_auth("blynk", "blynk token", auth, 34);
  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  
  WiFiManager wifiManager;
  //set config save notify callback
  wifiManager.setSaveConfigCallback(saveConfigCallback);
  //set static ip
  //wifiManager.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
  //add all your parameters here
  wifiManager.addParameter(&custom_server);
  wifiManager.addParameter(&custom_port);
  wifiManager.addParameter(&custom_auth);
  //reset settings - for testing
  //wifiManager.resetSettings();
  //set minimu quality of signal so it ignores AP's under that quality
  //defaults to 8%
  //wifiManager.setMinimumSignalQuality();
  //sets timeout until configuration portal gets turned off
  //useful to make it all retry or go to sleep
  //in seconds
  wifiManager.setTimeout(300);
  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP"
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.autoConnect("NotifySPA", "")) {
    Serial.println("failed to connect and hit timeout");
    //reset and try again, or maybe put it to deep sleep
    ESP.restart();//      ici ESP.reset();
  }
  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");
  //read updated parameters
  strcpy(server, custom_server.getValue());
  strcpy(port, custom_port.getValue());
  strcpy(auth, custom_auth.getValue());
  //save the custom parameters to FS
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    json["server"] = server;
    json["port"] = port;
    json["auth"] = auth;
    File configFile = SPIFFS.open("/config.json", "w");
    if (!configFile) {
      Serial.println("failed to open config file for writing");
    }
    json.printTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }
Serial.println("local ip");
Serial.println(WiFi.localIP());
  Blynk.config(auth);
  bool result = Blynk.connect();
 Blynk.run();
if (result != true)
{
  Serial.println("BLYNK Connection Fail");
  //SPIFFS.format();
  Serial.println(auth);
  //wifiManager.resetSettings();
  Serial.println("local ip");
Serial.println(WiFi.localIP());
  Blynk.config(auth);
  bool result = Blynk.connect();
 Blynk.run();
if (result != true)
  ESP.restart();
}
else
{
  Serial.println("BLYNK Connected");
//WiFi.mode(WIFI_STA);

//        ***************END  DON'T TOUTCH WIFI-MANAGER AND BLYNK PART *************************
}}
void notify(){ 
}
void loop() {
  notify();

  check_status();
notify();
timer.run(); // Initiates BlynkTimer
 Blynk.run();
}

I think I’ll bookmark this as an example of how not to write a C++ sketch!

Pete.

have found the basic example in trapuz wifimanager+ blynk , after i have add virtual pin in and out fonction, the code work well 90 day aproximativly and now it do this everyday anytime , and i don’t know why. i’m not programmor c+ , sorry and my apology for why u are so
to discourage

I can know why you say that please , and why i will do now? I use wemos d1 mini . Tank’s

To be honest, if you want people to help you with your problem, and take a look at your code, then you need to describe the problem in an understandable way, and format your code so that it’s readable - otherwise community members will skip past your post because it’s going to be far too much work.

You talk about “outputs changing state” but you don’t say which outputs these are. You have only one object in your sketch that could be considered an output, and that’s the built in LED, but you have no pinMode statement declaring this as an output.
So, community members will struggle to understand exactly what it is that is changing state - therefore making it difficult to understand how to help.

Then we have the sketch…
It has multiple lines like this…

and this:

Where the comments are incorrect. It would be better to have no comment, than one which is wrong.

Then you do this multiple times in void setup…

The opening and closing curly brackets are unnecessary, and confusing.

It would also make sense to put all of your pinMode statements together, preferably in numerical order of their pins, and all of your timers together.

You also need to sort-out the indents (tabs) to make your code more readable.

You also have this function which does nothing…

but which is called twice from within your void loop, meaning that it’s called hundreds of times per second for no reason.

And the check_status()function is also called within the void loop, but that function does a millis comparison to see if it needs to be executed. This ought to be managed with another timer, removing the function call from the void loop and also removing the millis comparison.

Once you place all of your timer commands together in the same part of the void loop, you’ll see that they all try to execute together every 200ms. Your board’s processor can’t do multi-threaded processing, so these timers should be staggered so that one function can complete before the next one is called.

Pete.

1 Like

i can’t eable to modify the code here ? i post the news code or reopen news ?

[quote=“filz35, post:1, topic:55334”]
this is the news code without lot of error do you have mean peter

#include <WiFiManager.h>
#include <SPI.h>
#include <Wire.h>
#include <FS.h>                   
#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
#include <BlynkSimpleEsp8266.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>          
#include <ArduinoJson.h>          
#define BLYNK_PRINT Serial   
#include <Ticker.h>
#include <DHT.h>
#define PIN_LED   D8   // Pin D4 mapped to pin GPIO2/TXD1 of ESP8266, NodeMCU and WeMoS, control on-board LED
#define DHTPIN 5  
BlynkTimer timer;
DHT dht(DHTPIN,  DHT11);

#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

Ticker     led_ticker;
#define AREF_VOLTAGE 3.27
   
//#define BLYNK_DEBUG
char server[15] = "192.168.4.1" ;
char port[6] = "8080";
char auth[34] = "";


bool shouldSaveConfig = false;


void set_led(byte status)
{
  digitalWrite(LED_BUILTIN, status);
}

void heartBeatPrint(void)
{
  static int num = 1;

  if (Blynk.connected())
  {
    set_led(LOW);
    led_ticker.once_ms(111, set_led, (byte) HIGH);
    Serial.print("B");
  }
  else
  {
    Serial.print("F");
    ESP.restart();
  }

  if (num == 80)
  {
    Serial.println();
    num = 1;
  }
  else if (num++ % 10 == 0)
  {
    Serial.print(" ");
  }
}

void check_status()
{
  static unsigned long checkstatus_timeout = 0;

#define STATUS_CHECK_INTERVAL     6000L

  // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
  if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
  {
    // report status to Blynk
    heartBeatPrint();

    checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
  }
}

void resetting()
{
  if (digitalRead(13) == LOW) 
    {
          WiFiManager wifiManager;
  wifiManager.resetSettings();
      SPIFFS.format();
    Serial.println("BLYNK resset");
  
  ESP.restart();
ESP.reset();
    ESP.restart();
}


}





  void checkPhysicalButtond0()
{
  if (digitalRead(16) == LOW) 
    {
      Blynk.virtualWrite(V99, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V99, HIGH);
   }
}

  void checkPhysicalButtond2()
{
  if (digitalRead(4) == LOW) 
    {
      Blynk.virtualWrite(V2, LOW);
   
      Blynk.virtualWrite(V2, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V2, HIGH);

   }
}
  void checkPhysicalButtond3()
  {
  if (digitalRead(0) == LOW) 
    {
      Blynk.virtualWrite(V3, LOW);
    
      Blynk.virtualWrite(V0, LOW);
   }
    else 
   {
    Blynk.virtualWrite(V3, HIGH);
       Blynk.virtualWrite(V0, HIGH);

   }
}
  void checkPhysicalButtond4()
{
  if (digitalRead(2) == LOW) 
    {
      Blynk.virtualWrite(V4, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V4, HIGH);
   }
}
  void checkPhysicalButtond5()
{
  if (digitalRead(14) == LOW) 
    {
      Blynk.virtualWrite(V5, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V5, HIGH);
   }
}
  void checkPhysicalButtond6()
{
  if (digitalRead(12) == LOW)
    {
      Blynk.virtualWrite(V6, LOW);
    }
    else 
   {
    Blynk.virtualWrite(V6, HIGH);
   }
}
  void checkPhysicalButtond7()
{
  if (digitalRead(13) == LOW) 
    {
      
      WiFiManager wifiManager;
      wifiManager.resetSettings();
      SPIFFS.format();
      Blynk.virtualWrite(V7, LOW);
      Serial.println("ERASING");
    SPIFFS.format();
ESP.reset();  // reset button
ESP.restart();
    }
    else 
   {
    Blynk.virtualWrite(V7, HIGH);

   }
}
 

void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(true); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    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(V20, h);
  Blynk.virtualWrite(V21, t);
}
void setup() {{
    dht.begin();

  // Setup a function to be called every second
  timer.setInterval(10000L, sendSensor);
    
  


  
  pinMode(16, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(100L, checkPhysicalButtond0);

     

  
  pinMode(4, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(110L, checkPhysicalButtond2);
  


     

  
  pinMode(0, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
 timer.setInterval(120L, checkPhysicalButtond3);


     

  
  pinMode(2, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(130L, checkPhysicalButtond4);

     

  
  pinMode(14, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(140L, checkPhysicalButtond5);

     

  
  pinMode(12, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(150L, checkPhysicalButtond6);

     

  
  pinMode(13, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(160L, checkPhysicalButtond7);
  timer.setInterval(10L, resetting);
  

     

  
  pinMode(15, INPUT_PULLUP);

  // Setup a function to be called every 100 ms
  timer.setInterval(170L, checkPhysicalButtond8);



   Serial.begin(115200);
  Serial.println();
  //***************DON'T TOUTCH WIFI-MANAGER AND BLYNK PART *************************
  //clean FS, for testing
  //SPIFFS.format();
  //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");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);
        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");
          strcpy(server, json["server"]);
          strcpy(port, json["port"]);
          strcpy(auth, json["auth"]);
        } else {
          Serial.println("failed to load json config");
          
        }
      }
    }
  } else {
    Serial.println("failed to mount FS");
    SPIFFS.format();
  }
  //end read
  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  WiFiManagerParameter custom_server("server", "server", server, 15);
  WiFiManagerParameter custom_port("port", "port", port, 6);
  WiFiManagerParameter custom_auth("blynk", "blynk token", auth, 34);
  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  
  WiFiManager wifiManager;
  //set config save notify callback
  wifiManager.setSaveConfigCallback(saveConfigCallback);
  //set static ip
  //wifiManager.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
  //add all your parameters here
  wifiManager.addParameter(&custom_server);
  wifiManager.addParameter(&custom_port);
  wifiManager.addParameter(&custom_auth);
  //reset settings - for testing
  //wifiManager.resetSettings();
  //set minimu quality of signal so it ignores AP's under that quality
  //defaults to 8%
  //wifiManager.setMinimumSignalQuality();
  //sets timeout until configuration portal gets turned off
  //useful to make it all retry or go to sleep
  //in seconds
  wifiManager.setTimeout(300);
  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP"
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.autoConnect("NotifySPA", "")) {
    Serial.println("failed to connect and hit timeout");
    //reset and try again, or maybe put it to deep sleep
    ESP.restart();//      ici ESP.reset();
  }
  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");
  //read updated parameters
  strcpy(server, custom_server.getValue());
  strcpy(port, custom_port.getValue());
  strcpy(auth, custom_auth.getValue());
  //save the custom parameters to FS
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    json["server"] = server;
    json["port"] = port;
    json["auth"] = auth;
    File configFile = SPIFFS.open("/config.json", "w");
    if (!configFile) {
      Serial.println("failed to open config file for writing");
    }
    json.printTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }
Serial.println("local ip");
Serial.println(WiFi.localIP());
  Blynk.config(auth);
  bool result = Blynk.connect();
 Blynk.run();
if (result != true)
{
  Serial.println("BLYNK Connection Fail");
  //SPIFFS.format();
  Serial.println(auth);
  //wifiManager.resetSettings();
  Serial.println("local ip");
Serial.println(WiFi.localIP());
  Blynk.config(auth);
  bool result = Blynk.connect();
 Blynk.run();
if (result != true)
  ESP.restart();
}
else
{
  Serial.println("BLYNK Connected");
//WiFi.mode(WIFI_STA);

//        ***************END  DON'T TOUTCH WIFI-MANAGER AND BLYNK PART *************************
}}

void loop() {
  

  check_status();

timer.run(); // Initiates BlynkTimer
 Blynk.run();
}

this is the news code without lot of error do you have mean peter

no matter which pin is used the problem occurs. I am currently using the gpio4 and gpio14 pin.
once the televerser code and the blynk key link to the wemos. strange phenomena are happening. Sometimes the output changes alone for no reason, other times it glitch, this can happen several times in an hour like 1 time per day. I did not notice any coincidence with any situation. even if I change the spindle the phenomenon occurs. I uploaded the new code without the errors that peter mentioned and it does it again. this is very messy, it destroys my equipment every time. I have the impression that it comes from the server of blynk because before for several months it never did, and all of a sudden the phenomenon appeared. any idea or suggestion will be greatly appreciated. thank you very much for your help and your time. I hope I have described the problem in plenty of detail

Purpose of this ? 3 times !!!

I would suggest you study few codes on this forum under projects made with blynk see how the code flows.

  • Include lib
  • Global variables
  • Timers initialising
  • Setup
  • Loop
  • Functions

Its not about it was working earlier not now. If you want someone to help you out then the code must be in a proper order!! Else no one would go back n forth to understand the code.

And to check physical button, there is a very good example on the github page and also many in this forum !! Check them out and adapt the same in your code.

I can see ESP.reset in your code which causes the esp to reset n as you know there are few pins that goes high during boot up. This may cause the issue that you are facing.

You have gathered all the pieces of code from all over the internet n came up with something which is not stable…

You need to first understand how the code works n then start.

START FROM SCRATCH

This is the best suggestion i can give you.

I have write it like that because i need to reset it if i change the wifi , i kniw some pin are low and high at start and example d3 if is high on boot the esp not start .is not the reason of my probleme i use d7 for reset .

Why this code have work very long time without any issue and sufdently i jave theres probleme and at the same tine blynk are updated🤷‍♂️ it is that reason i mind it is blynk server … dont know, this for reason i ask here

If i stop my blynk project in the app. And the probleme it do it against , the probleme come from my code for sur or not?

@filz35 you don’t seem to taken onboard my comments about explaining in detail exactly what the problem is, and what these “outputs” are. You’ve mentioned something about GPIO pins 4 and 14, but these are declared as inputs, so I still have no idea what these outputs you keep mentioning are, or what type of devices they are attached to.

Also, your code is still structured in a way that makes it almost unreadable. This may work for you, but it certainly doesn’t make it easy for others to view, understand and suggest improvements.

Pete.

Wemos d1 mini with node mcu 0.9 ( i have choose in arduino for upload). I turn on 2 relay with output. Ok

If i stop my blynk project in the app. And the probleme it do it against , the probleme come from my code for sur or not?

So you’re using two boards??

Which pins are these relays connected to?
Are the relays powered separately, or from your board?
Are the relays active HIGH or LOW ?

Pete.

No is mistake of my part , i use wemos d1 mini pro , i choose the board with the same name (lolin wemos d1 r2 & mini) and when i use wemos d1 mini model esp8266 12f i choose nodemcu 0.9 (esp12) it is you peter in previous post , you have recommande it for spiff (wifimanager)

Pin d2 and d5 the relay are active when it low and powered by the wemos (usb 5volt in 2.1amp)

If i delete or change de pin for dht the result are the same, if i change the #pin output is the same , any pin i choose is always the same thing

The problem is on all board (2 previously mentionned)