Problem with the Blynk app when the arduino is restarted (all pins start with high)

Hello people.

I’m a beginner in this area and I’m having a problem with the Blynk app every time the arduino is restarted.

When I upload the sketch on the arduino and click “play” in the Blynk app to test all the digital ports used in the app, they are “high”, even when they were set to start at “low” on the app buttons.

After I press the buttons to turn on / off everything goes back to normal.

But I am worried about a possible lack of power to make the arduino restart and after starting the app to use it, turn on all equipment at once, causing damage to the equipment.

I’ve tried using the app on different smartphones (Androids).

I already changed the tested digital ports.

Can you help me understand what may be happening?

I am using “MEGA + WiFi R3 ATmega2560 + ESP8266” and the following code below:

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
char ssid[] = "XXXXXXXXXXX";
char pass[] = "XXXXXXXXXXXX";
#define EspSerial Serial3
#define ESP8266_BAUD 115200


ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(115200);
  Serial3.begin(115200);
  pinMode(13,OUTPUT);
  delay(10);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
 
  }

void loop()
{
  Blynk.run();
    if ( Serial3.available() )   {  Serial.write( Serial3.read() );  }
    if ( Serial.available() )       {  Serial3.write( Serial.read() );  }
}

Add this to your code…

BLYNK_CONNECTED()
 {
    Blynk.syncAll();
}

Pete.

1 Like

Pete,

Thank you! I’ve been trying to solve this problem for many hours!

Sometimes it’s just a case of RTFM…

:smiley:

Pete.