ESP8266 NodeMCU – Simple Wifi Servo control

In this tutorial, we will learn how to control a small servo-motor from your smartphone. If you want to control the position of a mechanism, just have to use this tutorial. Good for beginners who want to make stuff move without building a motor controller with feedback & gearbox, especially since it will fit in small places. If you need an introduction to servo-motors and how they work, you can check this tutorial, ESP8266 NodeMCU – Simple Servo control.

Parts Required

To build the global setup you must have the following parts:

Blynk Android app

There are a lot of android applications for IoT. We will use blynk APP. Other application for desktop can be used, but we will keep it android for now.

Blynk is a hardware-agnostic IoT platform with white-label mobile apps, private clouds, device management, data analytics, and machine learning. You should check their Website to know more about Blynk.

Figure 1

So to install and configure the app, you must follow the tutorial on their website. However, if you follow the blynk tutorial, you will end up using the server. A server is a good option because, is safe, continuous and fast. Although server is currently providing 2.000 of energy, which limits your Dashboard. To solve this problem, you can use public free blynk servers, from this GitHub. Remember that these servers are unreliable and can have an intermittent shutdown. I will use the second server, but you can use any of them.

2º Server :
App Port: 9443
Device Port: 8080
Status : Alive (seen 10 Nov 2019)
Energy : 1,000,000
Blynk Email Sending : unknown
Server location : Thailand (TH)
Admin : Krisana Meesuk Department of Electronic Science, Chiang Mai

To change the server for the, in the login in the page of the app, when choosing the server, you need to click on the “3 dots” button and copy the server name and App port, as shown in figure 2.

Figure 2

After making the instructions above, you will receive an email with a token. We will use that token in the code for access to the server. To begin, create a new project and name it as you desire. In this tutorial, it will be “Wifi Switch”.

Figure 3

Below the project name, you need to especify the hardware. Choose the ESP8266 option.

Figura 4

Go to the main screen again. Swipe the main screen to the left to open the widgets menu, and insert a Slider. Press the slider to open the slider settings, and choose the output pin in the device and the min and max values.

Figure 5

From now on, we just have to program our devices and connect them with the blynk app, and we are fine.


Figure 5

Connect the signal cable (Yellow) to GPIO pin 2 (D4) because it is a PWM pin, Vcc (Red) to 3.3V and GND (Black), as figure 5. Everything will be powered from your PC using micro-USB to USB cable. In this configuration, the servo will be powered directly from the GPIO 2 pin with 3.3V. It is low voltage level but it works. All the current for the will be drawn from the board, and since each GPIO delivers only no more than a few mA, the torque can be low. Let’s try it.


Copy the main sketch below to your Arduino IDE project and save it. The Servo.h library is already included in the Arduino IDE. The Blynk library and EPS8266 library must be included by you, I give you the links. Have fun!!

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>

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

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

int Slider_Val = 0;

Servo servo;

BLYNK_WRITE (V0){ // On and Off Botton

  Slider_Val = param.asInt();

  servo.write(Slider_Val); // sets the servo position according to Slider value
  delay(1000); // waits for the servo to get there


void setup() {

//Blynk.begin(auth, ssid, pass);
Blynk.begin(auth, ssid, pass, "", 8080);
//Blynk.begin(auth, ssid, pass, IPAddress(128,199,173,118), 8080);

servo.attach(2); // attaches the servo on pin D4 to the servo object

void loop() { // main program loop;

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.