Continuing to explore the GPIO and the devices and sensors we can use with Fedora installed on a Raspberry Pi 3, in this post I will describe how to use a 1wire temperature sensor, in this case a DS18B20.
Disclaimer: I’m not an engineer nor a kernel developer. This post comes from try and fail tasks, googling for info, observations, etc. Pay attention when working with the GPIO pins and the electricity. I’m still alive and my RPi still works pretty well, but damages to your RPi coming from tasks here described cannot be attributed to me :-) As usual, forgive my English. The purpose of this post is for test and tinkering. Tested on on F28.
1wire is not available by default.
The simple way should be to enable it in the device tree as an overlay in the
Unfortunately dtoverlay still doesn’t work on Fedora.
/boot/dtb/bcm2837-rpi-3-b.dtb with the new one, reboot the Raspberry.
wire, w1_gpio and w1_therm modules
If you issue the
lsmod |grep wire command, you should see that
w1_gpio modules are loaded.
In order to read the DS18B20 themperature sensor, we need also the
w1_therm module, that we can find in the kernel-modules-extra RPM.
We can now load it using
At this point we can find the sensor in
/sys/bus/w1/devices/28-xxxxxxxxxx, in my case
Let’s read the temperature:
t=26000, that is 26°C
Note, I’m not sure, but since I have a resistor between data and v+ pins of the sensor, I used the content of the w1-gpio-pullup-overlay (definitions for w1-gpio module with external pullup, maybe if you want to enable the RPi internal pullup you have to use the content of the w1-gpio overlay?).
The gpio pin to use with the sensor data pin is BCM4 (https://pinout.xyz).
Remember that the /boot/dtb is a link to a directory related to the current kernel and it will be changed at every kernel update, so the
bcm2837-rpi-3-b.dtb loaded at boot will be replaced.