this post was submitted on 28 Jul 2024
17 points (100.0% liked)
Ask Electronics
3325 readers
1 users here now
For questions about component-level electronic circuits, tools and equipment.
Rules
1: Be nice.
2: Be on-topic (eg: Electronic, not electrical).
3: No commercial stuff, buying, selling or valuations.
4: Be safe.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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 large motor here's a tutorial with a relay: https://randomnerdtutorials.com/esp32-relay-module-ac-web-server/. 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:
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.
Don't forget a flyback diode at the inductive load or your transistor will bacon at midnight.
Fair enough: