Problem with operating Servo with ESP8266 on Arduino Mega using Blynk app

Hello everyone.

I need some help regarding the working of servo with esp8266 wifi module on Arduino Mega using the Blynk app.

I have connected all the hardware correctly as to my knowledge. The main problem what I am facing is - in every 30 seconds I get a pop-up on blynk app “Device was disconnected” and it automatically gets connected in 30 seconds and following the same pattern. I have already checked if my esp8266 is fine by just operating a LED, and it works fine being connected for all the time. I am facing this issue whenever I am connecting my servo to the board. I assume it to be some power issue which I have no idea about.

Hardware:

  1. Arduino Mega 2560
  2. ESP8266 WiFi Module
  3. Tower Pro Micro Servo 9g (SG90)

Connections:

  1. Power supply of 3.3V to both Servo and ESP8266 from Arduino board, and same ground connection
  2. Power supply of 3.3V to ESP8266 and 5V to Servo, and different ground connection

I have tried both of the above connections listed but, still the issue persists.
Blynk Application:

  1. Slider Widget - OUTPUT (V3) -> 0 - 180
  2. Button Widget - OUTPUT (D13) -> 0 - 1

The code is a simple one listed below:

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include<Servo.h>
#define EspSerial Serial1
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);


//WiFi Connection
char auth[]="My Token";
char ssid[]="My ID";
char pass[]="My Password";

Servo servo;
BLYNK_WRITE(V3){
  int value = param.asInt();
  servo.write(value);
  }
  

void setup() {
  Serial.begin(9600);
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
  servo.attach(8);
  }

void loop() {
  Blynk.run();
}

I need the solution as early as possible.

This doesn’t make sense… are you powering the servo from 3.3v or 5v??

Either way, a servo can draw a lot of current and best to use a suitable external power supply… just make sure everything, ESP, Mega & PSU is sharing same Ground.

It actually worked. I got the Servo connected to an external power source - Battery

Thanks for the help.