I've been trying to implement a project that's been in my head for a while, I want to wirelessly control my light and fan switches using an ESP32 and 2 servos (one for each switch) through an HTML page, and then later integrate it with Alexa

I have seen how one servo can be controlled by connecting the servo's power cable to the ESP32's Vin pin, but how can I control two? I want to avoid using an external power supply like a battery pack because I want it to be a completely automated process, and I don't want to have to keep switching out batteries often for the thing to work. I'll be using a 5V wall outlet to power the ESP32 using a USB.

Also, if anyone can provide a few more tips on how I can make my project more efficient or point out where I might be making a mistake, I'd be glad. I'm still new to the microcontroller world.


EDIT : I've attached a picture of the circuit diagram, just have a look and let me know if it is workableenter image description here


1 Answer 1


The power wire is just needed, well, to power the servo. The control is done via the third wire (the other wire being Ground).

You can connect the second servo's power in parallel, only the control wire must be separated from the first servo's control wire.

Note: You need to make sure that the current consumption of both servos does not exceed the provided power.

  • Oh okay, thanks for that. But I have one doubt, how exactly do I calculate if current consumption of the servos is lesser than what the ESP can provide? I'm using an ESP-WROOM-32, one SG90 servo and one MG90 servo. If anybody can do the calculations as to whether I can control the servo using the ESP32, it'll be very helpful, as I'm still new to this stuff, and another opinion is always better :) Commented Mar 20, 2021 at 14:46
  • Your servos should be documented, and you are looking for the maximum current of each. Add them. Then add the maximum current of the ESP32, it should be in its documentation, too. The total must be less than the maximum current your 5V wall wart provides. Commented Mar 20, 2021 at 14:55
  • This is the safe way. If you are sure that your servos never block, the current is much lower, see their documentation. Also the ESP32 consumes in average less current. Only at startup and when peak calculation power is needed, it rises. You might simply try. If the provided current is insufficient, you will notice that your project behaves strange and/or unreliable. Commented Mar 20, 2021 at 14:55
  • So it IS possible for me to just try it out right? As in, if the servos do demand more than the ESP32 can provide, it won't cause any fatal damage to the servos or the ESP, right? Commented Mar 21, 2021 at 4:48
  • Since you said that you connect your servos to Vin of the ESP32, which is the same point where you connect your supply device, the ESP32 has nothing to do with it. Its copper line from the USB to this pin should be able to handle the servos current. -- If this is not correct, please edit your question (there is a little link below the question) and show us your circuit. You can draw it with any graphic tool you know. Commented Mar 21, 2021 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.