Home > Industry Insights >Gear Motor
TECHNICAL SUPPORT

Product Support

How To Connect And Control The Communication Protocol Of Micro Servo 9g Sg90 In One Go

Published 2026-03-30

Have you ever encountered this kind of embarrassment: you excitedly bought a few microservo9g sg90 smallservos, but they didn’t move even after they were online. The information you looked up was all English protocols, and the more you looked at them, the more confused you became? In fact, it’s not that theservois broken, but that you don’t understand its “communication language”. Simply put, it listens to your command through a signal line. If you use it in the right way, it can accurately turn to the angle you want. Today we will talk about this communication protocol thoroughly, so that you will no longer be stuck by the technical threshold.

What signal is it listening for?

Standard servos such as micro servo 9g sg90 listen to a signal called PWM. You don't need to remember the full name, just know that it's like a code for "pulse width". The servo will decide which position to turn to based on the pulse width you send. For example, when the pulse width is 0.5 milliseconds, it points to 0 degrees; when it is 1.5 milliseconds, it points to 90 degrees; when it is 2.5 milliseconds, it points to 180 degrees. This rule is common to almost all standard servos. As long as you understand this, you will master more than 90% of the control logic.

You may ask, do I have to be precise to the millisecond level to control it? That's right, but don't be afraid, these operating microcontrollers or development boards have been figured out for you. You only need to call a library function and enter an angle value from 0 to 180, and the underlying code will automatically convert it into the corresponding pulse signal. So for product innovation, what you really have to do is to choose the right control interface, such as STM32 or ESP32, and then connect the signal line of the servo to the pin that supports PWM output.

Why should we test the power supply and wiring first?

Many novices take the 5V of the development board and directly supply power to the servo as soon as they get started. As a result, it restarts as soon as it starts running. This is not a program problem, but the power supply cannot keep up. Although the micro servo 9g sg90 is small, the instantaneous current at startup can reach 0.5A or even higher, which is simply not possible for the voltage stabilizing chip of an ordinary development board. So the correct approach is: use an external 5V power supply to power the servo. The development board and servo only need to share the same ground, and the signal lines are connected separately.

The wiring logic is actually very simple. There are three wires in the servo. Brown or black is the ground wire, red is the positive terminal of the power supply, and orange or yellow is the signal wire. If you measure it with a multimeter, you can basically tell. Don't believe the saying "just plug it in". If the power supply is connected reversely or the voltage exceeds 6V, the internal circuit of the servo may be burned directly. When we make products, we can add a large capacitor to the power line, for example, to effectively buffer the startup impact.

How to judge whether the agreement is correct or not?

Some friends will find that even though the code says 90 degrees, the servo only moves a little. In this case, either the pulse range is not calibrated, or the library you use does not match the actual protocol of the servo. Although micro servo 9g sg90 produced by different manufacturers are all called "standard servos", the pulse width range may be slightly different, some are 0.5 to 2.5 milliseconds, and some are 0.7 to 2.3 milliseconds. You need to use an oscilloscope or a simple angle test program to find the actual mapping relationship.

There is also a more hidden problem, that is, the control board you are using outputs analog PWM, but the servo requires digital PWM. If the simulated PWM frequency is too low, the servo will shake or even not respond. It is generally recommended to set the PWM frequency to 50Hz, which is a cycle of 20 milliseconds. This is the most comfortable receiving frequency for the servo. If you use a high-performance board such as ESP32, remember to configure the LEDC timer and make sure the frequency is not wrong.

How to use serial port and knob to control

If you want to make the servo control more intuitive, you can try using a knob potentiometer with serial port debugging. First connect the potentiometer to the analog input pin of the development board, map the read 0-4095 or 0-1023 value to an angle from 0 to 180, and then update the servo angle in real time through the program. You will find that when you turn the knob, the servo will also move. The whole process is like physically "holding" the servo to rotate, which is especially suitable for product prototype demonstrations.

Another common scenario is to use the serial port to send commands for control. For example, if you enter "90" in the computer serial port assistant, the servo will turn to 90 degrees. The logic is very simple, that is, the serial port receives the string, parses it into an integer, then limits the angle range, and finally calls the servo library function. You can use this method to quickly verify the action combinations of multiple servos without having to repeatedly change the code and upload it. For those who make interactive products, this combination is very efficient.

How to deal with simultaneous movement of multiple servos

It's okay to use only one or two servos in a product. Once four or five are installed, you will find that when moving at the same time, the servos compete for resources with each other and the movements are laggy. This is because most development boards can only process one PWM signal update at a time under single thread. The solution is to use this type of servo drive module, which is controlled through the I2C interface and can output 16 independent PWM channels at the same time, and the frequency and duty cycle do not interfere with each other.

The benefit of this is obvious: your main control only needs to send a command once, and the drive module can automatically maintain the angles of all servos, greatly releasing the calculation pressure of the main control. Moreover, the driver module supports external power supply and directly solves the problem of power management. Many robotic arms and robot head products actually use this method to achieve multi-server collaboration internally. It is stable and reliable and is also the most commonly used solution in professional products.

What hidden pitfalls should you pay attention to when choosing a servo?

The micro servo 9g sg90 on the market looks similar, but the prices vary greatly. The cheaper one costs a few yuan, while the more expensive one costs twenty or thirty. The difference is mainly in the gear material and motor quality. Plastic gears are cheap, but their teeth are easily swept after several consecutive runs; metal gears are more expensive, but durable and suitable for products that require frequent rotation. Also pay attention to the length of the servo cable. If your product structure is scattered, the standard 15cm cable may not be enough. You must either extend it yourself, or ask about the cable length before buying.

Another common pitfall is that the nominal torque does not match the actual performance. Some merchants will falsely state that it can reach 2 kilograms of torque, but in fact it will stall as soon as you press it with your hand. If you are making a product rather than playing with it, it is recommended to go directly to a brand or supplier with actual measured data, buy a few and do load testing. We usually drive it using a standard protocol during the selection stage, and then hang it on the force arm to measure the maximum locked-rotor torque to ensure that it meets the product application scenario.

Have you ever been stuck in the last 10% of a product due to servo communication or power supply issues? Welcome to share your experience in the comment area, or you can directly search "Xinying Technology official website" to see our commonly used servo selection and drive solutions, and work together to make the product more stable.

Update Time:2026-03-30

Powering The Future

Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.

Mail to Kpower
Submit Inquiry
+86 0769 8399 3238
 
kpowerMap