It controls lights, heating, ventilation, a robot vacuum cleaner, and even an automated cat feeder. Its Levels referring to the diagram Functional levels of a manufacturing control operation (see 2. in details) are:
Level 0: field devices
Sensors: DHT11, DHT22, BH1750, HC-SR501, DS18B20
Actors: stepper and DC motors, solenoid valves, radio-controlled plugs and relays (433Mhz), IR-remote controlled devices
Level 1: I/O modules
Remote input/output (RIO) modules made from Arduino's which sends the sensor data to the CodeSys software PLC and directly controls critical functions (as feeding the cats, positioning roller blinds).
Additionally a Pixtend I/O Board is connected to a Raspberry PI.
Level 2: supervisory
A Raspberry PI with CodeSys software PLC and graphical HMI which controls
Level 3/4: coordinating
A Raspberry PI With Node-RED and Grafana to collect and store all my data. And Alexa voice control.
Usually, I don't let go of a lot of my time to visual aspects of my projects. But the current situation gives me a bit more time to do some visual upgrades. I printed a case for one of my Raspberry Pis, the one which runs Node-red and connects all of the third-party apps to my Software PLC and HMI.
To have not only a visual benefit i decided to add two status LEDs which are connected to GPIO Pins and can be controlled direct by Nodered.Currently the blue one gets lit on every status change of devices (light on/off) and the red LED is reserved for network or system errors.
Since I had one of these lying around I wanted to add it to my smart home System.
The nearest I/Os to the preferred location are the digital inputs on the Pixtend Extension Board.
The only problem is that the HC-SR501 sensor outputs a 3.3V Signal and the DIs need at least 3.3V to flip high.
My solution should only involve components I had already in stock. So I decided to use a BC547 NPN transistor.
The signal gets inverted but that's no problem since I can negate the input in the PLC. I also mounted a lux meter (a photoresistor board with 0...2.5V output) in the motion sensor case. The boolean signal of the motion sensor and the analog value of the lux meter are processed from the PLC and the light gets switched on when needed.
I added the capability to monitor the state of my two balcony doors (open/closed).
The door state is monitored with a magnet and reed switch combination. The reed switch is in parallel with a resistor and changes the current through the loop.
So the different current states are corresponding with different door states. It is also possible to detect a short circuit (>10.65mA) or an open loop (wire failure <5.5mA) and all this with just two wires.
Current states with 24VDC supply voltage:
I only had 0.25W resistors, so i had to use some in parallel to distribute the load:
The current input gets analyzed (0...20mA current loop interface) and visualized by the RasPi PLC:
The simplest function of the system is also one of my favorites. It automatically refills the water tank of my coffee maker. All it needs is a float switch and a solenoid valve that lets fresh tap water flow in the tank.
Thanks to the SCADA like the design of my smart home system it is easy to derive the water usage from the time the valve was open (@ Level 3/4: A Raspberry PI With Node-RED and Grafana).
Every step up on the following graph represents a refill of the tank.
Don't worry there are some safety functions implemented in Level 2: (A Raspberry PI with CodeSys software PLC ) of the system. Such as maximum filling time or only refill when someone is at home.
And it is possible to trace all actions within Grafana: