Can't connect to my esp01

So my team tried to connect arduino MEGA 2560 + ESP-01
we flash the necessary AT firmwares, download the latest blynk libraries but could not make the ESP 01 connect to the blynk server. There are times that it connects, but the connection will drop after 20 to 30 seconds.! Here’s my serial monitor after uploading the code to the MEGA board

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.1 on Arduino Mega

[3642] AT version: 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
[10771] +CIFSR:STAIP,""
[10779] Connected to WiFi
[21219] Redirecting to

And the nothing happens.
any suggestions on what might be the problem?
here’s my code

#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "MYAUTHTOKEN";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "MYSSID";
char pass[] = "MYPASSWORD";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

#define DHTPIN 22          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT22     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

BlynkTimer timer;
void myTimerevent ()
  Blynk.virtualWrite(V7, millis() / 1000);

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

void setup()
  // Debug console

  // Set ESP8266 baud rate

  Blynk.begin(auth,wifi, ssid, pass);
  // You can also specify server:
 // Blynk.begin(auth, wifi, ssid, pass, "", 8442);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);


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

void loop()

Too much too fast?? both timers are trying to run at the same time… try changing the timer for the DHT22 to 5 seconds (5000L)

And put this up with the Serial.begin()… before your Blynk.begin()… as it might help get the DHT up and running quicker.

I’ll try that later! Thanks for the suggestion.

How is the hardware connected? The ESP is VERY picky about power. Adding a seperate powersupply and some elco’s seems advisable.


One more, 115200 is way too fast for ESP softserial. Try lowering it to 9600 and set the ESP accordingly with the AT command.

The OP is running Serial1, the 2nd of 4 total hardware UARTs on a Mega… so not softserial. And I can confirm that 115200 runs just fine on Serial1.

Crap, I need to learn to read…

But still, it can’t hurt to try a lower speed. Maybe the ESP itself is not 100%. I got one who works now but doesn’t do any serial output…