Came ZA3 gate controller with ESPHome

Hello everyone!
Today I would like to share an automation project I made a couple of months ago and I rewired and fixed it just a couple of days ago.
It’s a system interacting with a Came ZA3 control board to open/close a swing gate. It’s based on Home Assistant and ESPHome.
Long story short: with a NodeMcu (ESP8266), a couple of power rectifiers and converters, an optocoupler and a relay, I am able to open/close the gate and to know if the gate is open or closed. :boom:

Here’s a video of the system in action: https://twitter.com/ermannob/status/1226467698558763009

Here are some pictures of the system.
Work in progress and temporary wiring (black and red cables):


Final layout of components fixed with hot glue (my new best friend!):

My box (light grey) next to the control board (dark grey):

And this is the scheme:

The power supply comes from the Came control board (pins 10 and 11), and it’s 24V AC. It gets converted to 5V DC and it feeds the NodeMcu.
The NodeMCU drives a relay that “presses the button” to open/close the gate using pins 7 and 2 of the control board.
Then, the final part: getting to know if the gate is open or closed. If the gate is open, on pins 10 and 5 there’s a 24VAC current, that is rectified with a power converter similar to the one I use for the power supply of the NodeMcu and it feeds the optocoupler. Then the optocoupler is connected to a pin of the NodeMcu.

The relevant code:

api:
  services:
  - service: gate_controller
    then:
      - switch.turn_on: apricancellone
      - delay: 1000ms
      - switch.turn_off: apricancellone

binary_sensor:
  - platform: gpio
    name: "Gate open"
    pin: GPIO14

switch:
  - platform: gpio
    pin: 
      number: GPIO5
    id: apricancellone

Now a funny thing: with the temporary red-black wires, the Came remotes stopped working. My system was generating some interference that disturbed the 433MHz band. :man_facepalming:
After rewiring with a proper multi-wire single cable, remotes started working again! :vulcan_salute:

Thanks for reading! Comments and suggestions are welcome!

3 Likes

Hey, thanks for detailed post. I also have Came gate system ZBX7N (sliding gates) and was thinking about the same… I will probably need two optocouplers since I have two contacts one for open, one for closed (if they both are off, means the gate is half open or currently opening/closing)
Couple of questions:

  • I see that you are using pre-made electronics, can you post a link where you bought them?
  • You say that when the gate is open there is 24AC on 11 and 5 pins, but the diagram shows 10 and 5?
  • How does the optocoupler work? I see you have GND, VC and pin both wired to optocoupler, but the ones I saw for sale have only two connections? IN and GND?

Hi!
Glad you are interested! Here are my answers to your questions.

  • I bought them on Aliexpress and Banggood. I am not able to build my own components, and they are just cheap to buy. A couple of links of similar products (can’t find the original links):
  1. Relay https://www.aliexpress.com/item/32898156749.html

  2. Optocoupler: https://www.aliexpress.com/item/32917870734.html

  3. 2x Power converters: https://it.banggood.com/5V-LM7805-DC-or-AC-8-24V-To-5V-Three-Terminal-Voltage-Regulator-Power-Supply-Module-Output-Max-1_2A-p-1508724.html (you can use the same component for both power supply and “gate open” signal, as in my schematics. I had lying around the boxed version with silver label, but it’s just the same as the component at the link)

  4. ESP32 board with external antenna (much better wifi range!): https://www.aliexpress.com/item/4000155919030.html

  5. External antenna for ESP32: https://www.aliexpress.com/item/32995478602.html

  • You are right! I fixed the description. The diagram is correct. Thanks!

  • I’m not familiar with the optocouplers you are talking about… are they those? https://www.aliexpress.com/item/4000121424232.html probably they are equivalent, I’m such a beginner I can’t tell the difference… :sweat_smile:

Happy tinkering!

Thanks for response :slight_smile: I didn’t want to wait so I’ve tried to solder my own solution by just using optocoupler 4N35, diode, capacitor and couple of resistors, but oh well that does not seem to work :slight_smile:

So will have to order and wait.

Nice work, using your example I have made some changes and instead of switch in UI I have gate icon.
My config for esphome:

api:

binary_sensor:
  - platform: gpio
    name: "Gate sensor"
    pin:
      number: 27
      mode: INPUT_PULLUP
    id: gate_sensor

switch:
  - platform: gpio
    pin: GPIO5
    name: "Gate Switch"
    id: gate_switch
cover:
  - platform: template
    name: "Gate"
    device_class: gate
    lambda: |-
      if (id(gate_sensor).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - switch.turn_on: gate_switch
      - delay: 0.5s
      - switch.turn_off: gate_switch
    close_action:
      - switch.turn_on: gate_switch
      - delay: 0.5s
      - switch.turn_off: gate_switch
    stop_action:
      - switch.turn_on: gate_switch
      - delay: 0.5s
      - switch.turn_off: gate_switch
    optimistic: true
    assumed_state: false

In UI it is:
gate

1 Like