How to set up a GPIO sensor with ha-rpi_gpio

Hi all.

I’m new to Home Assistant so please be gentle.

My wish with Home Assistant was to make a simple interface to look at readings from a DS18B20 thermometer sensor that I’ve got connected to the GPIO pins on the Raspberry Pi 4 where Home Assistant OS is installed. I saw that the popular rpi_gpio integration has been depreciated so I’ve been exploring a few ways to get around that. One of them is the new alternative custom integration ha-rpi_gpio (available to be installed via HACS) that is supposed to be a spin-off from the original depreciated integration.

I set everything up as per the very limited instructions on the ha-rpi_gpio github page but the only way I can read something from the sensor is that it has the state On. I feel like I’m probably missing some basic thing about how to configure the sensor. The problem with that is that the documentation for the original depreciated rpi_gpio has seemingly also disappeared.

Can anybody share some insight on how to configure this correctly?

My config for the sensor in configuration.yaml:


binary_sensor:
  - platform: rpi_gpio
    sensors:
      - port: 4
        name: "DS18B20"
        unique_id: "DS18B20_sensor_gpio_7"
        bouncetime: 50

rpi gpio integration (HACS) only supports binary sensor, cover, switch.
The Dallas DS18B20 is a sensor. A binary sensor only has an on or off state.
Go to ESPhome for this sensor. It works reliably

Ah, of course!

I now see that the module is only for binary sensors. But how about ESPHome - can I make use of that without a separate ESP device? All the information I find is how to set the sensor up with a ESP device, but I have no use for it in my setup.

Yes, you need a device, for example ESP D1 mini.
It works over wifi. You can place it anywhere on your LAN. General use for many sensors and more. Simple configuration in HA.

That sounds great… for when I have some need for a remote ESP device. At the moment I have no need or place for it in the electric panel where the Raspberry Pi will be located. It would only be an additional point of failure for the system.

I also found this github repo; ha-onewire-sysbus. It says it’s a spin-off from the now depreciated onewire integration (that you would have needed for all 1-Wire sensors, instead of the rpi_gpio integration, if I understand it correctly). I think I’ll go with this solution, even though it also involves some hassle for those with HA OS installed and no access to the /boot/config.txt file.