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

mega128
Posts: 11
Joined: Tue Oct 24, 2017 12:54 am

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

Postby mega128 » Wed Jul 26, 2023 10:13 pm

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

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Thu Jul 27, 2023 1:23 am

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.

mega128
Posts: 11
Joined: Tue Oct 24, 2017 12:54 am

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

Postby mega128 » Thu Jul 27, 2023 7:01 pm

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

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Sun Jul 30, 2023 9:41 am

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.)

Who is online

Users browsing this forum: No registered users and 57 guests