Blynk + ESP8266 : piloter un mini kit Pan-Tilt PTZ SG90 en WiFi avec un smartphone ou tablette [Exclusive Guide]

8:56 am May 6, 201715397

Dans ce Tutorial nous allons apprendre comment assembler un mini kit PTZ (Pan-Tilt) à base de servo moteur SG90. We will use Blynk to control the PTZ in WiFi turret. If you have an account Blynk you can directly go to the Assembly stage. For best performance, it is recommended to install a local Blynk server. Indeed, even if the transfer is very fast, orders are encountered by the servers of By installing a local server, you will eliminate the lag time. In addition to better performance, you will be more limited energy.

For this project, you can use your official Blynk account (and use a little energy) or install a local Blynk server and enjoy unlimited energy and reduce latencies. Depending on your environment, follow the tutorial which is to install and configure your local private server

one finds kits PTZ in from 4 euros in China. If you already have 2 servos SG90, you can buy only the bare kit for less than one euro (à condition d’être patient pour le délai de livraison)! The kit is composed of 6 pieces in plastic molded and the necessary screws. As there is no documentation, I have to do some research on the internet. To avoid this, here is how to assemble the kit step by step.

mini ptz pan tilt kit sg90 parts

Assembly of the base (PAN)

Let’s start by assembling the base. Here are the necessary parts.

mini ptz kit pan tilt sg90 base assembly

Follow these steps to assemble the base

Assembly of support for tilt (Tilt)

for the support of tilt, you will need the following parts. You can replace the 2 short screws through the 2 long screws with nut and spacer. It is more solid, especially during Assembly of the inclination (Tilt) on the base (Pan) support.

mini ptz kit pan tilt sg90 top

Follow these steps to assemble the tilt support

mini ptz kit pan tilt sg90 top screw the servo on the base. The servo shaft must be the opposite hole of the pivot
mini ptz kit pan tilt sg90 arbre lateral insert the tree of enslavement to a branch in the slot
mini ptz kit pan tilt sg90 fixation arbre lateral fix the using 2 mini screws from inside

final Assembly

now there are to assemble the support of tilt on the base

mini ptz kit pan tilt sg90 montage dessus insert the axis of the servo in the housing of the servo shaft
mini ptz kit pan tilt sg90 clips axe insert the support on the pivot

do not screw the enslavement of the tilt support shaft.

Before complete Assembly, we will carry out the wiring and uploaded the program in the ESP8266. This will allow us to position each actuator to its original position. Then we can fix them permanently

material used

I therefore propose here to drive the mini Pan/Tilt kit in WiFi. You can use any ESP8266.


mini kit pan tilt servo wemos d1 mini wifi blynk

project Blynk

run Blynk. If you have a local server, connect you on this one.

blynk create account local server

Create a new project. Add a slider for the PAN and give him the PIN virtual V0. Change the upper limit to 180 (degrees). Check Send Value we Release Only .

 blynk virtual pin Pan servo

Then a second slider the tilt (V1). Change the upper limit to 180 (degrees). Check Send Value we Release Only .

blynk virtual pin tilt servo

Blynk is ready. Select the project by pressing the arrow in the upper right of the screen.

blynk virtual pin tilt servo

Arduino code

in previous tutorial we have seen how to use a servomotor with an Arduino and fly it using a potentiometer. Here, the program is not so different. We will recover the position of each actuator on two pins (PIN) virtual server Blynk.

Launch the Arduino IDE and create a new sketch, paste the code below and edit the following parameters:

  • SSID of your Wi – Fi network
  • the Wi – Fi network password
  • the Token of the Blynk project received by email
  • choose the mode to connect to the server Blynk among these three possibilities:
    • official account logon : Blynk.begin (auth, ssid, pass)
    • connect to one account by specifying the server: Blynk.begin(auth, ssid, pass, “”, 8442)
    • connecting to a local server Blynk: Blynk.begin (auth, ssid, pass, IPAddress (xxx, xxx, xxx, xxx), 8442)
  • make sure the Pin on which each servo is attached. Here Pan is on D5, Tilt is on D6
  • the Pan servo will be piloted by the virtual pin V0. The Tilt servo will be piloted by the virtual pin V1

upload program

origins setting

turn on the Blynk application and move the Tilt slider to 90 (degrees). Make sure the tilt is in the correct position. Complete Assembly is screwing the tree of servo on the servo axis.

servo tilt 90 degrees

Check that the base is correctly fixed by setting it to 0 ° and 180 °.

pan servo 180 degree

Blynk offers a joystick. It is less precise than the slider, but it’s more fun to use. Give the project Edition (square in the top bar) and removed the two sliders. Drag the sliders to the top of the screen. You can also go on the widget page. You will find a Delete button at the bottom of page.

Add a Joystick. Choose V0 and V1 for the two pins. Change the maximum values (180). Turn off the Auto Return option if you do not want the servos back to the original position.

pan tilt blynk joystick configuration pan tilt blynk joystick servo sg90

Start the project and have fun! In the next tutorial, we’ll add a camera to the mounting. A small video summing up everything.