Setting up the 1-wire interface for the RPi
( \newcommand{\kernel}{\mathrm{null}\,}\)
Setting up the 1-wire interface using the DS18B20 Temperature Sensor.
First enable the 1-wire interface on the RPi.
The following link demonstrates three methods for enabling 1-Wire Interface on the Raspberry Pi.
https://www.raspberrypi-spy.co.uk/2018/02/enable-1-wire-interface-raspberry-pi/
Methods, 1 and 2 use ‘sudo raspi-config’ or the GUI to enable 1-Wire.
Using ‘sudo raspi-config’ or the GUI will setup the default Pin 7 (GPIO4) port.
Method 3 shows how to enable 1-Wire Interface by editing the /boot/config.txt.
Understanding the manual editing of the /boot/config.txt file is essential for connecting two 1-Wire devices.
In the following example two gpiopins are initialized for 1-Wire interface, gpiopin=4 and gpiopin=5.
pi@aquaponics$ tail -6 /boot/config.txt [all] #dtoverlay=vc4-fkms-v3d dtoverlay=w1-gpio,gpiopin=4 dtoverlay=w1-gpio,gpiopin=5
If only one 1-Wire Interface is needed the following methods can be used;
Activate the 1-wire interface as shown here;
Enabling the 1-wire interface can also be accomplished remotely using ssh on the terminal.
sudo raspi-config
Activate the 1-wire interface as shown here;
After enabling the 1-Wire Interface by any method a reboot is required.
Attached the DS18B20 to the breadboard as shown in the following link;
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing?view=all
A 4.7K resistor is required, see wiring in the link above.
Attached 1-Wire devices can be listed with the following command;
ls /sys/bus/w1/devices/
For this example two DS18B20 sensors are shown.
pi@aquaponics$ ls /sys/bus/w1/devices/ 28-3c01b5569d9e 28-3c01b556bce8 w1_bus_master1 w1_bus_master2
The IDs for the two are 28-3c01b5569d9e and 28-3c01b556bce8.
These IDs are required for collecting data from the sensors.
The python script used in this example was found here;
https://www.raspberrypi-spy.co.uk/2013/03/raspberry-pi-1-wire-digital-thermometer-sensor/
The wget command can be used to download the python script.
wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/ds18b20.py
Note: in the python script ds18b20.py replace the device ID 28-00000482b243 with the ID for the device you are using.
The following link demonstrates how to setup one gpio port for several 1-wire devices.
https://raspberryautomation.com/connect-multiple-ds18b20-temperature-sensors-to-a-raspberry-pi/
The following fritzing diagram was found in the above link.
Note: when one of the two DS18B20 sensors failed the solution was to shut-down the RPi and reseat the pins into the breadboard. Both sensors were again showing up in the system.