My circuit is as below:
And the Arduino is connected to my PC via a USB cable and I am using Arduino IDE to upload my program below:
#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);
const int ldrPin = A0;
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();
}
When I open Serial Monitor, it connects to the Wifi and obtains an IP address and then returns a ping response. I then use the Blynk App on my Android phone to connect.
However, the problem is this. If I do not open Serial Monitor, it will still be able to connect to my Wifi Router and get an IP address, but it will not be able to connect to the blynk cloud. The Blynk App on my Android phone says “Offline since…”
But when I use zenmap to do an IP scan I can see my espressif device (esp8266) and I can also ping it. The problem is, it will not connect to blynk cloud unless I open the Serial Monitor.
How do I fix it so that it can connect to the blynk cloud without needing to open a Serial Monitor.