In the communications area of the industrial Raspberry PLC, there is a direct pin which is the GPIO 25 that goes to the GPIO 25 directly.
In this post, we are going to learn how to get temperature from a Dallas DS18B20 temperature sensor to a Raspberry Pi based PLC through the One-Wire protocol.
Dallas sensor and an industrial Raspberry Pi PLC for industrial automation
The DS18B20 sensor is a digital sensor that can be used with the open source PLC Raspberry Pi easily. Check out its datasheet for more information: Go >>
1. Go and edit the /boot/config.txt file:
sudo nano /boot/config.txt
2. Add the following line to configure the 1-Wire:
Exit the nano editor by pressing CTRL-X and then S, and then ENTER to exit, saving the file.
3. Reboot the system to apply changes:
sudo reboot now
4. Run the following commands to enable the one-wire interface on demand:
sudo modprobe w1-gpio
sudo modprobe w1-therm
5. Go to the /sys/bus/w1/devices directory:
6. List the files:
7. Several directories will appear, including one (or several, if we have several thermometers connected) with the name 28-XXXXXX, which is the serial number of the thermometer, different for each transistor. Go to yours, in our case:
8. Read the file w1-slave where you will see the temperature:
9. Extract only the temperature:
cat w1_slave | sed -e 's/.*t=//' | sed '1d'