Detecting Gate state based on 24v AC voltage presence

So I have a CAME Gate system and I would like to know if the gates are open or closed.

CAME has two connectors on board for connecting 24VAC lamps (max 3W) (one for open, one for closed, and one common). So I was thinking to hook onto those two contacts and read state with arduino (esp2866 to be precise)

I don't know much about electronics, but by googling and looking at various layouts online came up with the following layout based on 4N35 optocoupler (see attached)

As I understand the left side before the optocoupler is "half wave AC rectifier". The diode cuts off one part of AC wave, and capacitor ensures that there is enough power once that part of the wave is cutoff.

I wired everything to Arduino D1 Mini D2 pin, uploaded ESPHome, created two sensors to test (one regular, one inverted) and as you may have guessed, nothing is happening.

So does my layout make any sense ?

That should work.

The D1 Mini I suppose is a WeMOS ESP8266 board, not an Arduino. So don't pull up the signal to 5V, pull it up to 3.3V. You may enable the internal pull-up for this purpose.

Mind that when the opto is activated, your input signal is low, and be prepared for a pulsating signal (not sure if that 10µF cap is enough to keep the LED sufficiently on during the AC negative cycle).

Looks OK to me also (at least, from the HV side of the opto coupler) :

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.