1
\$\begingroup\$

I'm trying to close an external circuit very briefly (0.2 seconds) with an ESP32.

I have a motorized garage that is not capable of having a remote (internet-enabled) switch (or so all the professionals tell me). So what I'm doing is using some Hall-effect sensors to determine if the garage door is fully open or fully closed.

Then when one of them is true, I can tap on a button on a web page (which is on the ESP32) to actuate the garage door.

To pull this off, I've managed to solder a few wires onto the garage's micro-switch. When I close the circuit (literally touch the wires together), the garage either opens or closes depending on the garage door status.

What I need to do now is figure out a way to "touch" those wires together using logic on the ESP32 so that I can check on the status of the garage door and close it over the internet.

What is the best way I can go about doing this?

If this is the wrong stack exchange site, please let me know, and I'll remove the post.

I've been using this github post as a basis for my project

\$\endgroup\$
4
  • \$\begingroup\$ The best way is to us delay function of 100ms or so. Of course that delay time should be longer than your Relay response time. \$\endgroup\$ Commented Feb 10, 2023 at 0:49
  • \$\begingroup\$ Hi @PCBCrewEngineer, Uh, thanks, yeah, the intention is to use delay(200);, but the real crux is how to get the esp32 to close the circuit. \$\endgroup\$
    – Jim
    Commented Feb 10, 2023 at 0:52
  • 1
    \$\begingroup\$ Max current draw/sink of an IO pin is 12mA. Thus, you cannot use ESP32's IO pin directly for shorting a circuit. It is even not enough for driving most relay solenoids. Thus, use a MOSFET to drive a relay using ESP32's IO pin, use Relay's NO and COM pin for closing your circuit. \$\endgroup\$ Commented Feb 10, 2023 at 1:03
  • 1
    \$\begingroup\$ you could use an optocoupler instead of a relay, the GPIO current is so weak it can just run the led side without other components, and the transistor side can switch your switch without moving parts. \$\endgroup\$
    – dandavis
    Commented Feb 10, 2023 at 1:54

1 Answer 1

2
\$\begingroup\$

There are a lot of ways doing this but the most straightforward way is to use a relay module. These are opto isolated from the load. Be sure it will turn on with 3V, some will only work with 5V. They are only a few $$$.

enter image description here

Since you want to do this wirelessly I would suggest purchasing an esp relay module. You can search for "esp relay module". I got several million hits.

enter image description here

The ESPs are not capable of switching this much current. The relay is a safe method, you have not specified the voltage, current required or if AC/DC on the leads. Relays are inductive and the flyback will destroy the port. If you want to do another way post an annotated schematic so we can determine what is needed.

\$\endgroup\$
2
  • \$\begingroup\$ Is there no way to do this using 2 pins on the esp32 board itself? \$\endgroup\$
    – Jim
    Commented Feb 10, 2023 at 1:16
  • 1
    \$\begingroup\$ Have you measured the voltage and current flowing through the cables when they are in contact? (you should have done this as very first step, for your own safety) \$\endgroup\$
    – markus-nm
    Commented Feb 13, 2023 at 13:53

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.