Go service for a Raspberry Pi Zero W operating a FAAC-E124 gate control unit through a DIDO relay board and MQTT.
The service subscribes to MQTT commands, pulses the DIDO relay connected to the
FAAC IN 1 input, and publishes the assumed gate state back to MQTT.
There is no USB FAAC protocol support in this project. The FAAC control is operated through the existing DIDO board only.
The MQTT base topic defaults to faac/gate.
Inbound command topic. Supported payloads:
open
close
Retained state topic. Published payloads:
OPEN
CLOSED
The service starts with assumed state CLOSED. Because no feedback pins are
connected yet, this state is based on the last successful command, not on real
gate position.
Retained target topic. Published payloads:
open
close
Retained availability topic. Published payloads:
online
offline
The hardware that is used to control the entrance gate is a FAAC-E124 Control Unit.
The FAAC unit is extended with:
- Raspberry Pi Zero W
- DIDO module with MCP23S17-compatible SPI GPIO expander
- 4 Channel Optocoupler
- USB Powerconverter
These components need to be connected according to the following circuit diagram:
Please refer to the FAAC-E124 manual for details on the control unit. Chapter 5 of the document explains how to program the device.
The following values need to be configured:
LO = E or EP
o1 = 05
o2 = 06
Setting LO to either E or EP configures input IN 1 to operate the gate
semi-automatically: a first impulse opens the gate, a second impulse closes it.
o1 and o2 are documented for future input feedback. The current Go service
does not read those outputs yet.
Environment variables:
MQTT_BROKER(default:localhost): MQTT broker hostname or IP addressMQTT_PORT(default:1883): MQTT broker portMQTT_CLIENT_ID(default:gatecontrol): MQTT client idMQTT_USERNAME: optional MQTT usernameMQTT_PASSWORD: optional MQTT passwordMQTT_BASE_TOPIC(default:faac/gate): MQTT base topicLOG_LEVEL(default:info):debug,info,warn, orerrorSPI_BUS(default:0): SPI bus used by the DIDO boardSPI_CHIP_SELECT(default:0): SPI chip select used by the DIDO boardSPI_HARDWARE_ADDR(default:0): MCP23S17 hardware addressDIDO_RELAY_PIN(default:0): DIDO output pin used for the relaySPI_SPEED_HZ(default:100000): SPI transfer speedPULSE_LENGTH_MS(default:500): relay active time and follow-up delayUSE_MOCK_DIDO(default:false): use in-memory DIDO mockUSE_MOCK_MQTT(default:false): use in-memory MQTT mock
Local build:
go build ./cmd/gatecontrolRun tests:
go test ./...Cross-compile for the original Raspberry Pi Zero W:
GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 go build -o bin/gatecontrol-armv6 ./cmd/gatecontrolEnable SPI on the Pi:
sudo raspi-configThen check that a device such as /dev/spidev0.0 exists:
ls -l /dev/spidev*.*Copy the compiled binary to the Pi, for example:
scp bin/gatecontrol-armv6 pi@ip_address_of_pi_zero:/home/pi/gatecontrol/gatecontrolAdjust gatecontrol.service, copy it to
/lib/systemd/system, and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable gatecontrol.service
sudo systemctl start gatecontrol.serviceThe mock DIDO backend mimics the relay pulse sequence without touching
/dev/spidev*.
USE_MOCK_DIDO=true USE_MOCK_MQTT=true go run ./cmd/gatecontrolThe service does not read gate feedback inputs yet. It assumes the gate is
initially CLOSED and updates the state after successful commands. The assumed
state can be wrong if the gate is operated by another remote, keypad, wall
switch, safety stop, obstacle detection, or power interruption.
- FAAC-E145-Gate-Connect - similar FAAC work for a different board and protocol

