Published 2026-03-10
Play with ESP01: Small size, great use, easy to control theservono more worries
Many friends must have encountered this embarrassment when playing with smart cars or small robots: they happen to have a small ESP01 module on hand and want to use it to wirelessly control theservoto achieve a simple remote switch or angle adjustment function. But when I started using it, I discovered that although the ESP01 was cheap and easy to connect to the Internet, it had so few pins that it couldn't be connected directly to theservo. I didn't know how to write the program, so I had no choice but to give up. Don’t worry, today we are going to talk about this thoroughly and help you to fully unleash the potential of this “small size” ESP01, so that it can easily control the servo and contribute to your creative projects.
When many friends try it for the first time, they directly plug the signal line of the servo into the GPIO port of ESP01, and then write the code with great anticipation. The result? The steering gear either doesn't move at all, or it vibrates wildly and doesn't obey the orders at all. This is because you have encountered two "stumbling blocks". First, the working voltage of ESP01 is 3.3V, while most servos (such as the common SG90) require 5V to work stably. If the voltage is insufficient, the servos will naturally have no power. Second, when the servo rotates, it requires a large current, which is directly powered by the pins of ESP01. The current is too small and cannot be pushed at all. Instead, it may burn out the module. This is like asking a child to drag a big box, it will definitely not work.
Since the problem lies in the power supply, we have to take appropriate measures. The solution is actually very simple, which is to "separate": let ESP01 and the servo take their own power. We can use an external 5V power supply (such as two 18650 batteries or a mobile phone power bank) to specifically power the servo. As for ESP01, it can be used by converting 5V voltage into 3.3V through a voltage stabilizing module. The most critical step is to connect the negative poles (GND) of the two power supplies together so that they have a common voltage reference point and the signal transmission will not be messed up. In this way, the servo has sufficient power and ESP01 can work stably without interfering with each other.
There are various types of servos on the market, how should you choose? For an entry-level Wi-Fi module like ESP01, it is recommended that you start with the most classic SG90 9g micro servo. It's cheap, only a few dollars each, and you won't feel bad if it breaks. More importantly, its power consumption is relatively low, and an ordinary 5V power supply can easily drive several. Moreover, its control method is very standard, and you can find a large number of code examples and tutorials on the Internet, which is very suitable for players like us who are just getting started. After you have mastered the basic gameplay, it is not too late to try to control a more powerful metal servo.
Before writing the code, we must first briefly understand how the steering gear works. To put it bluntly, the control signal of the servo is a pulse with a period of 20 milliseconds. We tell the servo to which angle to turn by changing the duration of the high level in this pulse (that is, the pulse width). Typically, a pulse width of 0.5 milliseconds corresponds to 0 degrees, 1.5 milliseconds corresponds to 90 degrees, and 2.5 milliseconds corresponds to 180 degrees. In the programming environment, we can easily use the "Servo.h" library function, which encapsulates the complex pulse width calculation. We only need to tell it how many degrees to turn to, which greatly simplifies our development work.
Okay, now that the theory is over, let’s get into the practical stuff. The core idea of the following code is: ESP01 connects to your home Wi-Fi, and then sets up a simple web server on the intranet. If you access the IP address of ESP01 through your mobile phone or computer browser, you will see a control interface. Click the button above to control the servo to rotate to different angles. Specifically, you need to introduce the necessary libraries at the beginning of the code and define the pins to which the servo is connected (such as GPIO2). In the part where the Wi-Fi connection is successful, set up the function that handles web page requests. When the server receives a request like "/?angle=90", it calls the.write(90)command to turn the servo to 90 degrees. The whole process is logically clear and easy to get started.
The code was written and burned into the ESP01 using a data cable. I turned on the power and tested it happily, but the result was that the servo remained motionless. Don't worry, this is a common thing, and there is a high probability that there is a problem with the wiring. You can check it one by one according to the following steps:
️ 1. Check the power supply: Use a multimeter to test whether there is 5V between the VCC and GND of the servo? Is the 3.3V power supply of ESP01 stable?
️ 2. Confirm the common ground: Confirm again whether the GND of ESP01 and the GND of the servo power supply are reliably connected together?
️ 3. Check the pins: Is the signal line of the servo really plugged into the GPIO port specified in your code? (such as GPIO2).
️ 4. Check the serial port monitor: Open the IDE's serial port monitor and see if the ESP01 successfully prints out its IP address and connection status. This can help you determine whether the program is running.
After reading this, I believe you already have a clear idea on how to use ESP01 to control the servo. From power supply solutions to hardware selection, to code logic and troubleshooting, every step is actually not difficult. The key is to try it out. With a small ESP01 and a servo, you can create endless possibilities, such as making a remote-controlled camera pan/tilt, or a model window that can be opened and closed through a web page. Do you already have a plan in mind for your next creative project? Let’s talk about what interesting things you want to use this combination to do in the comment area. Don’t forget to like and share so that more friends can join the ranks of makers!
Update Time:2026-03-10
Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.