I have one of those basic motor kits you can buy off of Amazon. I was wondering what steps I should take to make it so that I can turn the motor on/off with the press of a button.
I’m still very new, so any information you can offer no matter how basic will probably be useful to me.
TCB13@lemmy.world 3 months ago
Easiest and cheapest way will probably be an ESP32 board. For your needs the ES32-S2 Mini or the ESP32 S3 Mini is more than enough.
Both can be bought from Aliexpress very cheap (< 5$) here and there with fast shipping. To be fair it isn’t worth to buy any electronics form Amazon, you’re looking are resellers that just mark up the price from Aliexpress.
In order to have it control the motor you’ll also need a relay or a transistor because you can’t drive the motor directly from the ESP32 GPIO pins as they are designed for signals and not power.
Choosing between a relay or transistor will depend on the power and voltage your motor requires. For a larger motor here’s a tutorial with a relay: randomnerdtutorials.com/esp32-relay-module-ac-web…. You can find a cheap relay here.
If you’re talking about a cheap 5V or 12V DC motor that runs of a few mA then a transistor like the BC517 or the 2N2222A will be enough and very cheap. The circuit should be something like this:
Image
The 1K resistor is optional but advisable and on the picture the 3v3 DC that is powering the motor can be whatever power supply voltage your motor already has assuming it is bellow 30V. If you’re above those voltages use the relay circuit above.
The software should be the same for both the relay or the transistor, just look up at the example.
tofubl@discuss.tchncs.de 3 months ago
Don’t forget a flywheel diode at the inductive load or your transistor will bacon at midnight.
TCB13@lemmy.world 3 months ago
Fair enough:
Image