Introduction
The industrial Raspberry PLC can always work properly unless it is disconnected from the power supply. It is always a problem to suffer a power outage or disconnection. Fortunately, Industrial Shields Raspberry-based devices also have the UPS, a part that provides a long enough period of time to power the device until the shutdown process is executed correctly, ensuring that the data will not be corrupted. In this post, you will see how to send a warning message when this phenomenon happens, sending it to an MQTT server, so you can receive the notification wherever you want thanks to industrial automation.
Related links
MQTT Client: open source PLC Raspberry Pi
1. First of all, you have to make the set-up for the MQTT:
sudo apt update
sudo apt upgrade
sudo apt-get install mosquitto mosquitto-clients
2. Now, you must follow the steps shown on the section 14.1.1 of the UserGuide or the last link on Requirements and write the following code inside the pre-poweroff file:
#!/bin/bash
server=10.10.10.3 #MQTT broker server address
port=1883 #MQTT broker server port
topic=test #MQTT topic
message="Raspberry_PLC_power_off"
mosquitto_pub -h $server -p $port -t $topic -m $message
MQTT Server: PC (Localhost)
The MQTT broker server can be installed in the most convenient location in each case. In this example, the broker will be a PC, and the alert message will be received using Node-RED.
1. First of all, you have to make the set-up for the MQTT:
sudo apt update
sudo apt upgrade
sudo apt-get install mosquitto mosquitto-clients
2. You have to run Node-RED in the free port that you prefer:
node-red -p 8081
How to send a warning message when Raspberry Pi industrial PLC is Powered Off