Share This
//CBus MQTT Bridge on Raspberry PI

CBus MQTT Bridge on Raspberry PI

Installing C-Gate on a Raspberry Pi, and adding a MQTT Bridge.

Turn back to 2007; My wife and I built our home, integrating many smart technologies, including the Clipsal C-Bus lighting system. This solution is classified as a Prosumer technology, and is designed to integrate into whole house automation systems.

The C-Bus system implements however a propriatory technology, and utilizes a communication protocol which is not ‘open source’; however, accepting a licence agreement will permit access to this protocol for creating an programming interface.

To simplify (arguable) the process of integrating with the CBus environment Clipsal released a Bridge solution which enables a TCP interface using a special Java application called ‘C-GATE’.

Using a Raspberry Pi, with a USB to RS-232 cable, which is then connected to a Clipsal interface called the Serial PCI Module,


Deploy the current relase of Rasbian for your Pi.

Update: Jan 2021 - Currently using Rasbian 2021-01-11

Once the Pi have been configured and added to the network, we can connect via SSH, and begin installing the pre-requisites for our gateway.

# Serial 2 Socket Build Tools
sudo apt-get install git build-essential autotools-dev devscripts libssl-dev 
# Java 8 Runtime for CGate
sudo apt-get installopenjdk-8-jdk
# Node and NPM for CGateWeb
sudo apt-get installnode npm

TCP to Serial Bridge

Configuring the CBus system over TCP however will not work with just C-Gate alone, we need to also establish a TCP connection directly to the Serial PCI Module.

Serial To Socket

This requires that we compile and run a small C application (Don’t worry, this is painless and fast); It took a lot of searching to find, posted the source to the following GIT repository; the application is called ser2sock.

Here’s the steps to get it set up:

git clone  
cd ser2sock

./configure --without-ssl
cc -o ser2sock ser2sock.c  

sudo mv ser2sock /usr/local/bin  
cd /usr/local/bin/ser2sock  
sudo chown -R pi:pi /usr/local/bin/ser2sock 

Running as a service - System.d

The source offers us a sample init script which we can use for starting the service. First we will place this in the SystemD folder, and then update it to match our requirements for C-Gate

sudo cp ~/ser2sock/init/systemd/ser2sock.service /etc/systemd/system

Update the startup script, /etc/systemd/system/ser2sock.service to have the daemon auto-start with the required C-Gate port, which is TCP 10001, and the serial interface baud rate set to 9600.

Description=Proxy that allows tcp connections to serial ports

ExecStart=/usr/local/bin/ser2sock -p 10001 -s /dev/ttyUSB0 -b 9600 -d
ExecReload=/bin/kill -HUP $MAINPID


Then activate using:

sudo systemctl enable ser2sock.service  
sudo systemctl start ser2sock.service

Installing C-Gate

Download the current software release of C-Gate off the clipsal website and unzipped the files into /usr/local/bin/cgate.

cd ~
unzip cgate-*.zip  
sudo mv cgate /usr/local/bin

Running C-Gate as Service - System.d

Adding the following ‘system.d’ startup script, to have the daemon auto-start with the operating system /etc/systemd/system/cgate.service

Description=Clipsal CBUS Gateway

ExecStart=/usr/bin/java -Djava.awt.headless=true -jar -noverify /usr/local/bin/cgate/cgate.jar  


Then activate using

sudo systemctl enable cgate.service  
sudo systemctl start cgate.service

C-Gate Access Control

We must configure the C-Gate service to allow remote connections from machines on the network by editing the access control file nano /usr/local/bin/cgate/config/access.txt; adding a line, providing the ip address of the remote system. In the example I am allowing the network or the IP’s in the range of to

echo "remote Program" >> /usr/local/bin/cgate/config/access.tx

Save, then restart cgate:

sudo systemctl restart cgate.service

C-Gate Auto-Connect

Edit the file /usr/local/bin/cgate/config/C-gateConfig.txt. Set the project.default and project.start lines to the name of the C-Gate Project.


MQTT interface for C-Bus lighting written in Node.js

cd /usr/local/bin
sudo git clone
cd cgateweb
npm install
sudo nano settings.js

Put in your settings.

sudo cp cgateweb.service /etc/systemd/system
sudo systemctl enable cgateweb
sudo systemctl start cgateweb


01. About Author

Damian Flynn

I define myself as an evangelist; an entrepreneur & author with an ideology rooted in business insights, technology exploration, pattern analysis and high energy. I envision, theorize and develop system architecture and strategic business platforms, soaked in storytelling and innovative technology.

Find on :

02. Last Posts

Do you want to learn more ?

© / 2020 / All rights reserved.
Get in Touch