Page 1 of 1

Connect small N20 geared 3v motor directly to ESP32-S3 GPIO

Posted: Wed Jul 26, 2023 10:13 pm
by mega128
HI all,

A newbie question so please tolerate with me.

I understand that a toy motor should not be directly connected to a GPIO. However, my project is 3v battery operated and mostly in deep sleep state and it runs motor for 2 seconds approx. once a day. I would like circuit to be as simple as possible so I do not want to connect and transistor or motor IC. Motor consumes around 10ma and connected directly to one GPIO and GND.

What do you suggest I should do to make sure it does not burn ESP32 in long run. Do you think I should add a resistor/diode in series to the motor, just to make sure?

Thanks,
Jay

Re: Connect small N20 geared 3v motor directly to ESP32-S3 GPIO

Posted: Thu Jul 27, 2023 1:23 am
by ESP_Sprite
Honestly, just use a transistor or better, a mosfet. A GPIO is relatively sensitive to under- and over-volting; the components you'd need to add in order to protect against that would take up more space than a simple transistor/mosfet.

Re: Connect small N20 geared 3v motor directly to ESP32-S3 GPIO

Posted: Thu Jul 27, 2023 7:01 pm
by mega128
Thanks for the suggestion!

So, can I connect BSS138N logic level mosfet directly to ESp32 GPIO and that should suffice?
No resistor between GPIO and BSS138N should be fine?

Thanks again,
Jay

Re: Connect small N20 geared 3v motor directly to ESP32-S3 GPIO

Posted: Sun Jul 30, 2023 9:41 am
by ESP_Sprite
Yes. Looking at the datasheet, figure 7, a Vgs of 3.3V (as sent out by the ESP32) will allow you to control a device needing 200mA or less. You don't technically need a resistor although it's good practice to add a resistor from the gate to Gnd, to make sure that if the ESP32 is not controlling the GPIO yet, the gate has a defined signal. Not doing it in your case probably doesn't hurt, but it may make the motor turn on for a fraction of a second during boot.

(Note that the BSS138 is kinda old... not that you need it here, but it may be good to know you can get mosfets with way better specs nowadays. For instance, the AO3400 would be able to control devices requiring multiple amperes in this situation.)