MisterBill2
- Joined Jan 23, 2018
- 28,704
Sometimes a simple mechanical change is the way to go!
Correct, please note the screenshot I attached to my previous post, which shows the circuit diagram of the water dispenser.Is one side of the button directly connected to ground?
If the ESP32 is using a different power source then I would use an optocoupler.Would it be better to place a small optocoupler in parallel with the momentary button instead?
Using the same power supply would be redundant. A GPIO pin configured as an output will have voltage on the pin when in the high state which is why I show a diode in series. I don't see any need for additional protection on the GPIO pin with the diode in series. The diode is the protection.Would using the same power supply make the optcoupler redundant because all GND would be tied together?
I think it would still protect the ESP32 gpio pin, no?
void optoButton() {
// Switch optocoupler to actuate the motor
// pressing button to start the motor
digitalWrite(10, HIGH);
delay(500);
digitalWrite(10, LOW);
delay(20000); // let the motor run for 20 seconds
// pressing button another time to turn off the motor
digitalWrite(10, HIGH);
delay(500);
digitalWrite(10, LOW);
}