Home automation with PLCnext and openHAB 2
I was speaking with a customer last week who has automated his home using a Raspberry Pi running openHAB 2 software. He asked me if the PLCnext could do the same. Not one to pass up a challenge ... here's a summary of the steps needed:
Prerequistes:
- PLCnext must be connected to the Internet - to verify: ping www.google.comDownload Zulu Embedded (OpenJDK) from https://www.azul.com/downloads/zulu-embedded/
- ARM 32bit JDK on Linux (for ARM v8/v7/v6 Hard Float ABI)
- Downladed tar file is (for example) ezdk-1.8.0_152-8.25.0.76-eval-linux_aarch32hf.tar.gz
- Extract contents of tar file: tar -xf ezdk-1.8.0_152-8.25.0.76-eval-linux_aarch32hf.tar.gz
- Copy to PLCnext: scp -r ezdk* root@192.168.1.10:/usr/lib/jvm/
- Create a symlink: ln -s /usr/lib/jvm/ezdk-1.8.0_152-8.25.0.76-eval-linux_aarch32hf/bin/java /usr/bin/java
- Verify the installed version: java -versionDownload latest OpenHab distro from https://bintray.com/openhab/mvn/openhab-distro
- Downloaded file is (for example) openhab-2.2.0.tar.gz
- Extract contents of tar file: tar -xf openhab-2.2.0.tar.gz
- Copy to PLCnext: scp -r * root@192.168.1.10:/opt/openhab2/Follow the instructions on https://docs.openhab.org/installation/linux.html#manual-installation
- sudo adduser --system --no-create-home openhab
- sudo chown -hR openhab:openhab /opt/openhab2
- sudo su -s /bin/bash -c '/opt/openhab2/start.sh' openhabNow open a web browser and navigate to 192.168.1.10:8080
I got this working on the PLCnext EA hardware but it should also work on the release version.
- Martin.
Comments
Openhab is nice, I also like Domoticz and HomeAutomation. should all fly on the AXC 2152.
Often used in conjunction with Node-Red
Thanks Vincent.
It would be nice to have an OpenHab Binding for the PLCnext Global Data Space, like the one currently available for Modbus/TCP - then data could be exchanged directly between OpenHab and PLCnext I/O and applications.
It's on my list of things to do, for when someone invents a time machine that adds an extra 8 hours of leisure time to each day. :-)
- Martin.
Hi Martin,
A faster means of integration, could be using MQTT in openhab (already a binding present), placing mosquitto in the Linux domain of the AXC F 2152. and adding a mqtt-client in a CPP program .This way, you could get it up-and-running, without the help of H.G. Wells
Right, nice one.
There's also a TCP & UDP Binding that could be used to exchange information with a C/C++ program running on the PLC.
- Martin.
How can I reach the OPC UA datapoints from PLCnext from Openhab2.
Hi Jozef,
I image that you may be able to install the
node-red-contrib-openhab2
package and then use this, along with thenode-red-contrib-iiot-opcua
package, to build a flow that exchanges data between OpenHab2 and the PLCnext OPC UA Server.- Martin.
Thanks Martin,
If openhab2 package is also installed, so too much memory is occupied.
I think openhab2 should be installed on external RPi and nodered on PLCnext.
Do you agree ?
Installed HW: 02 FW: 1.2.0.51 without SD card and nodered with opc-iiot-ua.
Hello Jozef,
The AXC F 2152 was designed with enough resources (memory etc) to run deterministic, real-time automation applications. While it's interesting to see what else we can run on this device, it's easily possible to reach the limit of what can be installed - as you've discovered. What runs on the AXC F 2152, and what runs on other devices like an RPi, is really up to the designer of each individual solution. Some pureists may say that node-red and openhab2 should both be run on an external device. It's really up to you.
I'll try to get answers to the other questions, and post them on the other thread.
- Martin
My experiences with Openhab3 v.3.4.0 at january 2023
AXC F 2152 HW v.2 FW 2023.0.0 LTS (23.0.0.65)
java version: zulu11.60.19-ca-jdk11.0.17-linux_aarch32hf.tar
Openhab3 addons openhab-addons-3.4.0.kar
Memory: 80%, User Partition:82% from 2GB SD card
All working, trying to make openhab autostart.
My wish is to integrate python modbusTCP for communication with servers.
I'm trying also mail binding for sending emails.
Is it possible to transfer AXC controller and PLCnext I/Os variables to openhab items please ?
restAPI or c-code etc.
Thanks for answer.
Hello Matrin.
As you mentioned: The AXC F 2152 was designed with enough resources (memory etc) to run deterministic, real-time automation applications.
It's absoltelly true PLCnext components should be used only for that job for true real time data aquisition.
I can confirm from my professional life, that data aquisition should be fast achieved on the lowest hardware level. Higher functions should be realised on higher level components like Scada, SW PLC tools.
I would recomend to integrate this PLC world into Openhab or other "higher level" systems via ModbusTCP or OPC UA. PLCnext needs act as ModbusTCP server and be able to exchange own data.
Implementation of PLCnext datapoints would be fine e.g. as a Openhab Phoenix PLCnext binding.
Communication to other automation component groups is possible from Openhab on it's own platformusing a lot of present bindings.
Hi Martin.
No nodered, no OPC UA (but would be nice),
-> REST API approach.
https://www.plcnext.help/te/Service_Components/REST_data_interface/REST_data_interface_Variables.htm
Disadvantage vs. internal OPC UA server - no spontaneous data transfer possible, only polling like Modbus.
Openhab can poll PLC vars via HMI REST API and communicate via own REST API.
https://www.openhab.org/docs/configuration/restdocs.html
I will prepare some example for Starterkit variables,like di_IN0xy, do_OUTxy and ai_INxy and post it here 😎 No secure communication at this time !
----------------------------------------------------------------------------
GET http statement examples:
//AXC_IP/_pxc_api/api/variables?pathPrefix=Arp.Plc.Eclr/&paths=di_1_IN01
Answer parseable as JSON:
apiVersion "1.10.0.0"
project CRC115377137
userAuthenticationRequired false
variables 0
path "Arp.Plc.Eclr/di_1_IN01"
value false
--------------------------------------------------------------------------------------------------------
//AXC_IP/_pxc_api/api/variables?pathPrefix=Arp.Plc.Eclr/&paths=do_1_OUT01
Answer parseable as JSON:
apiVersion "1.10.0.0"
project CRC115377137
userAuthenticationRequired false
variables 0
path "Arp.Plc.Eclr/do_1_OUT01"
value true
--------------------------------------------------------------------------------------------------------
//AXC_IP/_pxc_api/api/variables?pathPrefix=Arp.Plc.Eclr/&paths=ai_1_IN01
Answer parseable as JSON:
apiVersion "1.10.0.0"
project CRC115377137
userAuthenticationRequiredfalse
variables 0
path "Arp.Plc.Eclr/ai_1_IN01"
value 8389
Great, thank you.
Please feel free to share example applications in the Makers Blog.
OK. I will transfer all to blog. After that please "reduce" my posts here 😎