MichielVanwelsenaere / HomeAutomation.CoDeSys3

Home Automation system build in CoDeSys 3 with MQTT communication to any third party Home Automation software
MIT License
114 stars 38 forks source link
codesys domoticz home-assistant home-automation homeautomation mqtt openhab plc

MQTT enabled CoDeSys 3 Home Automation

Releases Gitter License

This CoDeSys 3.5 project is built for home automation purposes. The goal of the approach is to perform any critical operations like reading inputs, switching light, controlling sunscreens, etc. Inside the PLC itself and make use of MQTT events to send events to an MQTT broker. Using MQTT subscriptions it's possible to send commands to the PLC to control -for example- outputs.

The purpose? Redundancy on a software level but also on a hardware level!

Supported Runtimes

The project is developed using the IEC 61131-3 standard, there are multiple development environments with their own runtime that support the standard:

GeneralArchitecture

Software Architecture

More information on the software architecture here.

Function blocks

Basic function blocks

Basic function blocks for basic IO events and operations.

Virtual function blocks

Function blocks developed to easily set and get values from the processing logic through MQTT.

Modbus RTU over RS485

With many PLCs having a onboard RS485 serial port it is a popular protocol to create a robust Modbus RTU sensor network.

Using Modbus RTU

How to use Modbus RTU differs depending on the PLC/development environment used. The topics belows address the usage of Modbus RTU in several development environments:

RS485 function blocks

To translate the byte array received by the modbus device to their actual value and send their values through MQTT the function blocks below have been developed. Note that a specific function block is required for each type of Modbus RTU device.

In addition to the above a buscontroller function block (FB_RS485_BUSCONTROLLER) is used to control access to the RS485 bus between multiple RS485 device function blocks.

DALI

Control DALI drivers using the WAGO DALI modules (753-647).

DMX

Control DMX drivers.

Additional functionality

FAQ

Libraries

The following libraries are used in this PLC project and can be found under src\Libraries:

Special thanks to Stefan Dreyer for his assistance in some of the MQTT aspects of this project and his great work on his open-source CoDeSys MQTT library.