Program execution starts when open serial monitor in Arduino IDE?

I was just able to complete POC to control LED using Blynk mobile app. I am using Arduino Uno and ESP8266. What I see is, the program starts executing only when I opens serial monitor in Arduino IDE.
How will it work in actual hardware where it will not have serial monitor.

THanks,
Krunal

It’ll reset because if you open een serial connection in the Arduino monitor it’s reset the board (I think it’s because of RTS or DTR pin which get switched to on). You can easily check this by opening the serial port using a different terminal program which leaves DTR and RTS alone on connection (I’m using CoolTerm, but I’m on Mac).

In normal use cases when there is nothing attached it’ll work just fine and only resets when you push the reset button or ground the reset pin.

I am also facing the same issue. My esp8266 is connected to my arduino like this:

And the arduino is connected to my PC with USB cable. The blynk program only connects to blynk cloud when I open the Serial Monitor from the Arduino IDE. Without opening the Serial Monitor, it does not connect to the blynk cloud although it can connect to the wifi and get an IP address.

How to solve this problem? I would like the Arduino and ESP to be able to connect to blynk cloud without needing to open the Serial Monitor.

Here is my code:

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#define ESP8266_BAUD 9600

char auth[] = "863f1a05b91b95b496c46cpa03ad253z";
char ssid[] = "wifissid"; // set your wifi router
char pass[] = "3dconnectpass"; // set your password
SoftwareSerial EspSerial(2, 3); // RX, TX
ESP8266 wifi(&EspSerial);
BlynkTimer timer;

void setup()
{
  Serial.begin(9600);
  delay(10);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
}
void loop()
{
  Blynk.run();
}

@paulc Please take note of the time/date stamps before posting… (and the answers)… this is an OLD topic.

No… it only restarts each time you open the Serial Monitor, as was explained over a year ago :wink: That is an Arduino issue/feature.

Your sketch will actually work just fine even if the serial monitor is not open… although your wiring is wrong… you should NOT power the ESP from the Arduinos 3.3v pin as it cannot properly supply the needed current, causing the ESP to brownout and fail to connect. Use a seperate 3.3v PSU with MIN 700+mA current (and share the GND with the Arduino).

Please create a new relevant topic if you have further questions. Thanks.