Introduction: Wi-Servo: Wi-fi Browser Controlled Servomotors (with Arduino + ESP8266)

Picture of Wi-Servo: Wi-fi Browser Controlled Servomotors (with Arduino + ESP8266)

This instructable shows how to control some servomotors remotely in a wi-fi network, using an ordinary internet browser (Firefox, for instance). This might be used in several applications: toys, robots, drones, camera pan/tilt, etc.

The motors were attached to an Arduino Uno, which connects the wi-fi network through a ESP-8266 module. The control interface was designed with HTML and jQuery.

Miguel's tutorial (, which shows how to turn LEDs on/off using ESP-8266, served as inspiration for this post.

The technique shown here is used in one of my projects: "Robô da Alegria". You might found more about this in one of the following links:

Step 1: Electronics

Picture of Electronics

For this project you'll need the following components:

You won't need specific tools for the assembly of this project. All the components can be found online on your favourite e-commerce store. The circuit is powered by the USB port (connected to a computer or a ordinary phone charger), but you may also add an external DC power supply or a battery connected to the Arduino power jack.

Step 2: Assembly

Picture of Assembly

Connect all componets according to the schematic. You'll need some jumper wires to connect the ESP-8266 module and the servomotors. You might use a protoshield (for a more compact circuit), an ordinary breadboard, or design you own Arduino shield.

Plug the USB cable to the Arduino Uno board and proceed to the next step.

Step 3: Arduino Code

Install the latest Arduino IDE. In this project servo.h library was used for the control of the servos. In order to avoid conflict between the wi-fi module and computer's USB port during the upload of the code, softserial library was used. No additional library was needed for communication with ESP-8266 module. Please check the baudrate of you ESP8266 and set it properly in the code.

Some servomotors start to jitter and make strange noises when its position is close to the limits (0 and 180 degrees). To avoid that, the angle was limited between 10 and 170 degrees both in the Arduino code and in the control interface (later).

Unfortunatelly, servo.h library and softserial.h library use the same timer of the microcontroller. This might cause jitter in the servos whenever the Arduino communicates with the ESP-8266. To avoid that, the servos are detached from the Arduino after each command. You might also connect the module to the standard serial pins. In this case, remember to disconnect the module before each upload.

Download Arduino code (wi-servo.ino) and replace the XXXXX by your wifi router SSID and YYYYY by router password. Connect the Arduino board to your computer USB port and upload the code.

Step 4: Interface

Picture of Interface

A html interface was designed for the control of the servomotors. In this example, two servos were used, but more can be added to the Arduino Uno (I tested up to four motors).

A textbox form is used to enter IP address of the ESP module.

Download Wi-servo.html and jquere.js files and save both in the same folder.

Step 5: Usage

Picture of Usage

When the Arduino is restarted, it will try to connect your wi-fi network automatically. Use the Serial Monitor to check if the connection was successfull, and to obtain which IP was assigned to your ESP-8266 by your router.

Open the html file in an internet browser (Firefox).

Inform the IP address of your ESP-8266 in the textbox and you'll be ready to go. Select the angle desired for each servo using the sliders. The browser will automatically send a request to the Arduino when you release mouse button, and move each servo.


hrp1937 (author)2017-12-07

how can I control four servos simultaneously in four different rooms in my house? The servos will be arranged to open and close the window shutters. I will have the servos and the mechanical linkages, I need help with the wi-fi control. I am handicapped now and I need a way to open and close the shutters without having to go from room to room. Thank you.

IgorF2 (author)hrp19372017-12-08

Hi there.
If you want to use the method described in this tutorial, I think you'll have to use four Arduinos (otherwise you'll need cables between each servo and you microcontroller). To actuate them simultaneosly, you'd chenge the control interface (html + jquery), so that it sends the same command to four different IP addresses at the same time.
There are easier ways (using less hardware). You'd use a standalone ESP8266 (without the Arduino) to reduce the number of devices, for instance.

EfimV (author)2017-11-20


IgorF2 (author)EfimV2017-11-21

You're welcome! :D

Jan Kaizoku (author)2017-10-30

Hi Igor,

So you need the same connection to use this? And it doesn't work if using different connection? for example, I'm at coffee shop using their wifi trying to connect to the esp8266 at home using different wifi.

IgorF2 (author)Jan Kaizoku2017-10-31

Hi there,

This only works if the computer (or smartphone) and the Arduino are connected to the same wi-fi network. It would be better if it was possible to send commands from outside networks, but for now it only works locally... :/

FrankieBabay (author)2017-09-23

Hi Igor,

What a great tutorial. I've been made it. Thank You.

Now I have a little experiment. I am trying to make the interface using android (app inventor).But how about the arduino code? I need an examples the arduino code. can you help me, please!

IgorF2 (author)FrankieBabay2017-09-26

Hi Frankie!
I'm glad you liked it and made it!
I haven't used Android App Invertor yet. But you can make your interface on the html file itself. This way it will be multiplatfom.
Copy the html file and javascript file into your Android device. The navigate do the file (using Astro file manager for instance) and open the html file on your smartphone browser (Chrome or Firefox).

zztrolk (author)2017-09-18

Hello Igor!

First of all, great tutorial!

I have used the esp8266 for some time now together with other processors like the attiny85 to make use of e.g. the ADC. As my projects evolve I am starting to look more into the development of the web servers UI to make my projects more user friendly. Sooo about that .js file, did you use some kind of program to make the code? It is so intense and vast! If you use some kind of help program, what is it? And if you indeed wrote it, hats off!!!

Best regards, Kristian from Sweden

IgorF2 (author)zztrolk2017-09-18

Thanks, Kristian. I'm glad you liked the tutorial.

Regarding the jquery.js file, it's a library which, among other things, handles events in a HTML document. I've just downloaded the jquery library and used it.

The scripts I wrote are inside the .html file itself (mouseUpSr1 function for instance), and I used Notepad++ for making the code.

You can find more about jquery on the following website:

I hope it helps! :D

AyushS108 (author)2017-06-09

I need urgent need on this. I am getting the output as follows:

I have tried both the baud rates of 9600 & 115200.

Please help.

Best Regards

IgorF2 (author)AyushS1082017-06-09

This probably means your baudrate still isn't right.

Notice that there are two baudrates: one between the PC and the Arduino, and other between the Arduino and the ESP8266.

You can choose the first one (between PC and Arduino) and set it both on your code (Serial.begin(9600), for instance) and on the Serial monitor.

You will have to discover the baudrate of the ESP8266 by trial and error and configure on your code (esp8266.begin(9600), for instance). Those are the possible values (300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200).

AyushS108 (author)IgorF22017-06-09

I tried each suggested value of esp8266.begin while keeping the arduino and serial monitor baud-rate rate as 9600.

But, it didnt work sir!! :-(

AyushS108 (author)IgorF22017-06-09

Ohk Sir.

Let me try what you just suggested. You kindly remain online! :-D

I will ping in a couple of minutes about the result!

Best Regards

UjjwalT2 (author)2017-06-06

Would you please send me another modified form of your code?

IgorF2 (author)UjjwalT22017-06-07

You receive this message ("yyyyyyyyy") only? When the Arduino is
powered, it sends a message to verify if the ESP8266 is ok, then sends
another command for the connection to the wi-fi router.

If the connection is successfull, it receives other messages...

ujjjwal (author)2017-06-05

i am getting

yyyyyyyyyyyyyy on my serial monitor.

what to do?

IgorF2 (author)ujjjwal2017-06-05

Please verify the baudrates of your Serial Monitor.

UjjwalT2 (author)IgorF22017-06-05

I have tried both 9600 and 115200

IgorF2 (author)UjjwalT22017-06-06

Can you try other baudrate values?

You receive this message ("yyyyyyyyy") only? When the Arduino is powered, it sends a message to verify if the ESP8266 is ok, then sends another command for the connection to the wi-fi router.

If the connection is successfull, it receives other messages...

ujjjwal (author)IgorF22017-06-06

i am stilling getting yyyyyyyyy in my serial monitor.

KyleJ74 (author)2017-05-13

Hi Igor - I am not getting any response in my serial monitor at all. Do you have any idea what the issue could be?

IgorF2 (author)KyleJ742017-05-13

Please check if you selected the right COM port and baudrate on Serial Monitor.

KyleJ74 (author)IgorF22017-05-14

Okay, playing with the baudrate appears to help, but I am getting a random string of text as well:








no change"

I updated the firmware on the ESP8266 and expect it to run on 115200, but I have had trouble updating the script to reflect this:

//start serial communication



sendData("AT+CIOBAUD=115200\r\n", 2000, DEBUG);


// Remove Reset

//sendData("AT+RST\r\n", 2000, DEBUG); //reset module

IgorF2 (author)KyleJ742017-05-15

SoftwareSerial library doesn't work well with baudrate = 115200 kbps. This way, data transfered between the ESP8266 and the Arduino may be corrupted.
Please set you ESP module to a slower baudrate (9600 kbps, for instance). Don't forget to change the speed during the setup as well (esp8266.begin(9600);).

KyleJ74 (author)IgorF22017-05-31

I have been changing around the rates to no avail. Is there a different package or setting that I should have initialized? I am thinking there's an issue with the ESP8226 itself maybe

IgorF2 (author)KyleJ742017-06-02

You won't need to install any additional library or package for this instructable.

You can upload the "BareMinimum.ino" example (it comes by default on Arduino IDE), then connect Arduino's RX/TX to ESP8266 TX/RX. Then open the Serial monitor and send an "AT" message. If your module is ok, it will answer with "OK". If you receive a junky message, it means you're using a wrong baudrate (change it on the Serial Monitor until the answer makes sense).

I hope it helps...

DanRBarker (author)2017-03-19

Hi, my serial monitor output is this;




ets Kan 8 2013,sst cause:2, boot mode:(3,6)

load 0x40100000,6tail 0

chksum 0x63

lo`d 0x3ffe8etail 0

chkux2tail 0

Ai-Thinkdr Technologx Co. Ltd.












9 : ( 1Œãœï“pƒŒóŒ

each time it's slightly different. I've tried several baud rates and none seem to work. Does anyone have a solution to this? Also, sometimes I get an IP address from the monitor, in this case but when I use this in the browser the servo does nothing (I'm only using one servo on Pin 9). Thanks!

IgorF2 (author)DanRBarker2017-03-20

Do you know if your baudrate is set to 115200kbps? Software serial library doesn't work well at that speed and, even though you can read the messagens, it displays that noises sometimes.
If that's the case, maybe you should change the baudrate of your ESP8266 to something slower (9600kbps would be great).

DanRBarker (author)IgorF22017-03-20

Hi Igor, I believe that's what I have done (I am completely new to the ESP8266). I used the code from a previous comment below:

"Try this :

//start serial communication
sendData("AT+CIOBAUD=9600\r\n", 2000, DEBUG);
// Remove Reset
//sendData("AT+RST\r\n", 2000, DEBUG); //reset module"

and this has fixed the issue. The servo now moves! Thanks for the quick response!

IgorF2 (author)DanRBarker2017-03-20

You're welcome!

MohammadG29 (author)2017-01-24

Some of the serial monitor messages is not understandable:this is mine:




ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000,oٹ

tail 4

chksum 0x88

loa‚‚•mtail 4

chkx tail 8cutb IDSi¦پ¢صة‚

َn't use rtc mem data


Ai-Thinkdr Technolog¾ Co.,Ltd.

re`d^CلAT+CWMODQOLCC،C،jھHüAT+CWJAP="Mohamlad is awesolest","andinovehim100pescentsure"







also the motor doesn't turn sometimes moves and sometimes doesn't.what is the solution?

IgorF2 (author)MohammadG292017-01-24

My ESP8266 module also display some strange characters sometimes.
Regarding the motor, I believe it's a problem regarding the speed of the network. If you send a lot of commands quickly, the ESP8266 might lose some of the packages. So maybe you'd adapt the code, to reduce the number of packages between you computer and the Arduino.
Maybe change it so that the motor gives "x" turns on each buttom click, instead of allowing a continuous movement.

ThenyanS (author)2016-12-06

The servo doesn't work and I have this massege :


A K+Ëk«É�Technology Co.,Ltd.



what is the problem? , please help

IgorF2 (author)ThenyanS2016-12-08

Maybe your ESP8266 module runs on a different baudrate. This might be the reason you are receiving those strange symbols.

Try to change the baudrate of the serial communication between the Arduino and the ESP8266 on line 42 (esp8266.begin(19200);).

Ziyadyassar08 (author)2016-11-22

thanks servo is already running. whether we can control via smartphone? I have tried but can not.

IgorF2 (author)Ziyadyassar082016-11-23

It worked on my Android smartphone. I copied the html file + jquery to the phone and opened it using Firefox browser.

Ziyadyassar08 (author)IgorF22016-11-25

I have tried with my smartphone but do not want to walk servo, esp8266 also led her not blinking does not indicate that there is communication between the smartphone and esp8266. do you have a solution?

IgorF2 (author)Ziyadyassar082016-11-27

Did you connect both (your smartphone and the ESP8266) in the same wi-fi network (same wireless router)?

Ziyadyassar08 (author)IgorF22016-11-28

yes I am already connected to the same wifi. but it still can not. whether there are additional applications to run in a smartphone?

IgorF2 (author)Ziyadyassar082016-11-28

Did it work when you opened the html interface on your browser's desktop?Did you copy both the html file an jquery file to the same folder?

Ziyadyassar08 (author)IgorF22016-11-28

html can be opened in firefox my smartphone but for the servo control can not, I have servo move through a browser, but it would not work at all. I also have to put the file html and jquery are in the same folder.

Ziyadyassar08 (author)2016-11-21

thanks. Sorry I want to ask . ip already out on the serial monitor but why servo can not it work?

YohanesG1 (author)2016-09-12

So we actually need 3 x 10 kohm resistors (instead of 2 x 1 kohm + 1 x 10 kohm), right? It would be helpful for newbie if you maintain consistency between the component list & diagram

IgorF2 (author)YohanesG12016-09-13

I agree on you that the consistency between the diagram and the component list is important. So I revised the list from 2 x 1kohm + 1 x 10kohm to 3 x 10kohm resistors.

Those 1 kohm resistors where used in a voltage divider, to reduce Arduino's TX voltage. So we might use almost any two resistors with the same value in this voltage divider.

YohanesG1 (author)IgorF22016-09-17

Thanks. I just tried it but couldn't make it work. The esp8266 couldn't connect to wifi (debugged through serial monitor). Its led is constantly red. Is because I only use arduino uno USB as power?

IgorF2 (author)YohanesG12016-09-19

My ESP8266 module has two LEDs: a red one for power indication (always on) and a blue one for communication stutus (turns on when the module is receiving or transmitting data). If your module is the same, did you verify if this blue LED blinks? What does the serial monitor display when you reset your Arduino?

YohanesG1 (author)IgorF22016-09-21

I just noticed that mine has 2 LEDs too. But besides the red one, the blue one only blinks 2-3 times whenever I reset my arduino then it stays off. These are the only messages shown in my serial monitor:





YohanesG1 (author)YohanesG12016-09-21

Ups, wait, I got those messages only after I add "Serial.print(command);" inside "sendData" function. Otherwise I only got these strange characters:


IgorF2 (author)YohanesG12016-09-21

Maybe it's because your ESP8266 works at a different baudrate than that configured in Arduino. The baudrate configured in the code was 19200. Sometimes the ESP8266 comes at 115200.

Try changing the baudrate (from "esp8266.begin(19200);" to "esp8266.begin(115200);", for instance) and check if those strange characters change to something understandable.

Regarding the blue LED, it's blinking three times because the Arduino is sending three commands: reset, set station mode and connect your wi-fi router. If the baudrate is actually wrong, the ESP8266 is receiving something data, but isn't able to understand it.

About This Instructable




More by IgorF2:Glass Mounted Hanging Cat BedIoT Air Freshener (with NodeMCU, Arduino, IFTTT and Printed Articulating LED Lamp
Add instructable to: