ESP-01S and GPIO2 - trying to figure out how to indicate that there is voltage on the pin?

Hey All,

Recently got my esp-01s connected to my gate-motor. This is working really well and allows me to open the gate remotely. I have the same sort of setup on my doorbell by the gate, which uses GPIO2 to detect that the doorbell was pressed. Using this i can easily send a notification to telegram (with camera image attached) and then decide what todo (Open, Phone them, speaker, …).

The issue i’m a bit noobish about is that on the gate motor there is a output pin that shows when the gate motor is working (status) that fluctuates between 2.2v (gate moving) to 4.8v (stopped in open position) and then once closed it goes to 0.

I want to know how do i connect this to PIN2 to indicate that something is happening, i dont need the voltage but want to say pin2 “activated” while its moving.

From reading, i can configure it as a sensor, but is i understand correctly attaching more than 3.3v could damage the pin. How would i go about this if at all possible?

Thanks
Derick

A 10K/22K Ohm voltage divider would protect your ESP from the 4.8V by reducing it to 3.3V but would prevent detection of the running voltage as the 2.2V would be reduced to 1.5V. See the Vin HIGH for 3.3V TTL on this graph. It needs to be at least 2.0V.

So a better way to do it would be with a Zener diode to limit the peak voltage.

zenerd

+Vs is your motor sense point.
+Vz goes to your ESP.
0V is common to both.

If you use a 1N4728 Zener diode and a 300 Ohm 1/4W resistor it will limit the maximum voltage to the ESP to around 3.3V.

When the motor is running you should get 2.2V to the ESP which is just enough (>2.0V) to be read in as a HIGH signal. When the motor is stopped in the open position the voltage will rise to 3.3V (4.8V limited to 3.3V by the Zener), also being detected as a HIGH signal. Once closed the ESP should detect a LOW logic level.