I use a PLC (CLICK series from AutomationDirect) to control all lighting at my home. Although the PLC and the basic lighting functionality operates independently, I needed a bridge between the PLC and the embedded Linux computer for my automation tasks implemented on a higher level. This is a simple implementation of the MQTT to Modbus bridge written in C language that allows to easily control the lights using the MQTT publish commands.
MQTT publish commands:
mosquitto_pub -t plc/y709/set -m true
mosquitto_pub -t plc/y709/set -m false
mosquitto_pub -t plc/y709/toggle -n
MQTT publish responses:
plc/y709/set/ok (null)
plc/y709/toggle/ok (null)
- Mosquitto - MQTT broker
- libmosquitto - MQTT client library
- libmodbus - Modbus library
- GCC + Make - GNU C Compiler and build automation tool
The software has been tested on Debian 9.3 (amd64).
Clone the repository:
git clone [email protected]:hubpav/mqtt2modbus.git
Go to the repository:
cd mqtt2modbus
Build the program:
make
Currently the program does not take any arguments. The parameters can be adjusted in the beginning of
main.c
.
Run the program:
./mqtt2modbus
You can use PM2 process manager to keep this program starting on the boot.
pm2 start mqtt2modbus
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Pavel Hübner - Initial work
This project is licensed under the MIT License - see the LICENSE file for details.