Changed baud to 115200. Got junk on the serial monitor. Changed it back to 9600 and was able to see readable text.
Deleted the old project and created a new one. App has 4 buttons only.
Saw all sync examples using Virtual pins. Attached a virtual pin to each button. In the sketch, for every Virtual pin, used pinMode to set appropriate GPIO pin for output and used digitalWrite (HIGH/LOW). Worked well.
Inserted Blynk.syncAll() in setup() and the reboot started all over.
Thought it was sync of physical pins that possibly created the issue, maybe causing a reset due to GPIO16. Was not the case here. There seems to be a 30 second delay between each reboot. Is this caused by the connection timeout timer?
Pardon my ignorance. I’ve the sketch on the IDE. I did try to copy and paste it to a reply. Has vanished. Could you educate me on what you meant in your terse message? Should I enclose the sketch within backticks?
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "9bfce62ec5f248e1962a0f0d135426f4";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Linksys-01750";
char pass[] = "sundaram!@#";
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
pinMode(14, OUTPUT);
if (pinValue)
{
digitalWrite(14, HIGH); //GPIO2
Serial.print("\nV1 is set to ");
Serial.print(pinValue);
}
else
{
digitalWrite(14, LOW); // GPIO2
Serial.print("\nV1 is set to ");
Serial.print(pinValue);
}
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
pinMode(12, OUTPUT);
if (pinValue)
{
digitalWrite(12, HIGH); //GPIO2
Serial.print("\nV2 is set to ");
Serial.print(pinValue);
}
else
{
digitalWrite(12, LOW); // GPIO2
Serial.print("\nV2 is set to ");
Serial.print(pinValue);
}
}
BLYNK_WRITE(V3)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
pinMode(4, OUTPUT);
if (pinValue)
{
digitalWrite(4, HIGH); //GPIO2
Serial.print("\nV3 is set to ");
Serial.print(pinValue);
}
else
{
digitalWrite(4, LOW); // GPIO2
Serial.print("\nV3 is set to ");
Serial.print(pinValue);
}
}
BLYNK_WRITE(V4)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
pinMode(13, OUTPUT);
if (pinValue)
{
digitalWrite(13, HIGH); //GPIO2
Serial.print("\nV4 is set to ");
Serial.print(pinValue);
}
else
{
digitalWrite(13, LOW); // GPIO2
Serial.print("\nV4 is set to ");
Serial.print(pinValue);
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, IPAddress(188,166,206,43), 8442);
// 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.print("Setup done");
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}
Blynk.syncAll or Blynk.syncVirtual should be called in BLYNK_CONNECTED and not setup
BLYNK_CONNECTED() {
// Request the latest state from the server
Blynk.syncVirtual(V2);
// Alternatively, you could override server state using:
//Blynk.virtualWrite(V2, ledState);
}