Location and language of GPIO code

Good morning

I am trying to set up a Home Assistant in a Raspberry pi 5. After many tries I have decided to use a HAOS configuration. Now I need to program the GPIOs and my question is, where do I do it (In what plug in) and what language should I use ? The point with the HAOS configuration is that it does not have linux terminal as far as I know. So what libraries should I install and how do I do it?
I have already checked the documentation and I have not been able to find answer to my questions.

Sorry for my lack of knowledge. I need help.

Regards

HA has add-ons and integrations to add functionality, including the use of GPIOs. Which you need will depend on what you want to use the GPIOs for. Unfortunately there is not a one-stop-shop summarizing all the options, so it will take some research to find the right option.

I found these with a quick search, hopefully this is a starting point to find what you need:

  • an integration for binary sensors, switches, and covers
  • an add-on to use GPIOs for PWM e.g. for a fan speed control
  • an add-on to use GPIOs to connect i2c bus devices
1 Like

Last I knew there was no stable, supported add-on to support GPIO pins on the RPi platform. There was a lot of discussion when it was removed, and a few attempts to fork a new version, but I don’t think it’s been picked up by anyone.

It has to work. If it does not, I am going to die

Hi friend
Thank you for your answer. I don´know how to install the plugins since I am using an HAOS architecture and as far as I know the Home assistant console that is in my raspberry pi does not have a linux terminal interface so I will try to install the plugins with the Home assistant console but I am not sure this is possible. Thank you

Regards

Use HACS to install the ‘plugins’ (custom integrations)

Thank you. I already installed Hacs. Let s see if I can install the plugins

I have some bad news for you. Pi5 GPIO support doesn’t currently exist RPi 5 GPIO

Before you do anything drastic, I was able to transfer my GPIO sensors to an ESP8266 board using ESPHome. Obviously an ESP32 would work even better. I don’t like the extra complexity or maintenance overhead, or having to re-route wires and get a new power supply set up, but it does work. And I guess there’s a bit of benefit from isolating that function from the HA Core function.

Yeah the reason I put that first link above was because it is a fork of ha-rpi_gpio that uses libgpiod2 which, in theory, should work on the Pi 5. (There is limited feedback in that repo that it works “inconsistently” but might be worth a try). However @CaptTom is correct that these are third-party, community-contributed options and have no support, bug fixes, etc. and that a better solution for GPIO is a esp32 dev board with esphome.

1 Like

First don’t be melodramatic. The lack of gpio support won’t kill you nor will your assumption that it exists.

Second - describe what you’re actually trying to accomplish and the folks here can help you figure it out.

…And I agree with everyone else. ESP32 boards are usually a much better option.

Hi friends

I am just trying to process the value of 9 humidity sensors and control 3 valves for water irrigation. It is just a matter of resources optimization since it work with solar energy. But the point here is not the optimization but the call of the sensors in the yarl program and the visualization in the Home Assistant interface. That is what I am working now in. I am not able to read a physical tag and show its value in Home Assistant
Sorry again for my lack of knowledge.

Regards

Somewhat trivial with ESPHome. You don’t say what protocol the sensors are using- it would make a difference. For example, one i2C channel (two GPIO pins) can address up to 63 devices. Analog would be more difficult since the ESP32 only has 2 Analog ports. (The Arduino Uno R2 has eight, but the Arduino won’t run ESPHome so you would have to use MQTT to get the data into Home Assistant).

The Home Assistant host computer is basically a Web Host.

Hi
The Raspberry pi is the only option. I can´t switch technologies at this point of the project. The inputs must be processed and the outputs must be activated when it is necessary. There is no return point. The question here is how to do it? I am trying with scripting in yaml but I dont get neither call physical inputs nor create a light indicator that change color depending on the physical input Thank you
Regards

We get the frustration really. But You have not described the actual equipment you’re trying o control yet. Without that we’re going in circles.

We’re not saying throw it all out. We’re saying you light need to add one or two 10 dollar parts to your concept. (add an esp32 and esphome to your setup, most likely)

We need manufacturers, model and if it has any firmware version so we can help you figure out HOW. To connect. Then once you have that then get the correct gear to adapt your situation. Again, probably a very cheap esp32.

But we need to know EXACTLY what your connecting to. SO. What devices are you trying to control. Make, model, firmware of possible.

Hi friend
Ihave bought 9 humidity sensors PIS-12821910-PIS-1282-ND OCTOPUS SOIL MOISTURE SENSOR BRI
I have 3 valves 24-V IO discrete signal for irrigation
I have a solar panel and all the instruments necessary for making it work safely
Then pipes, cables, connectors , In total I have invested 500 euros aprox

500 Euros Materials for the moment. Hours dedicated. Maybe 150

Can you return them?

First problem- no link to the product. A Google search brings up dozens of different configurations. But the core component is the same for most.

Second- they are analog. You need an analog input for each sensor and the Raspberry Pi has no analog input. For that you need an ADC (Analog Digital Converter). You need three for nine sensors.

Third- Resistive moisture sensors have a bad reputation with accuracy and repeatability. The sensor is basically a resistor (the two probes in the soil) and an op-amp to make the analog output. The probes in the soil have to be cleaned daily for any reliability because they oxidize quickly, increasing the resistance. You can stick these probes into a bucket of wet mud and after a few days the output will say “dry”. (I have personal experience with this).

If I were designing such a system, I would use capacitive moisture sensors. They are less unreliable than the resistive sensors.

I would use an ESP board, in my case the Wemos D1 Mini (only because I have a dozen of them in my workshop), but lately there seems to be an obsession with ESP32. Any ESP will do this. The ESP board would connect to the sensors and communicate their values to Home Assistant over the Home Assistant API. The Adafruit sensor is i2C, so you just need two GPIO pins to run up to 63 sensors.

The Raspberry Pi running Home Assistant is only one component in the system.

Oh, BTW- turning relays on or off is falling down simple for any ESP.

1 Like

And this. Is why we asked. I had guessed that was where op was going buuuuut…

I second capacitive sensor to esp32 a Wemos d1 mini of similar) using esphome. Resistive sensors are crap.

The esp32 Should also cover you for the valve controls worst case, an additional relay if it’s hi amperage.

The OP mentioned 24V which is typical of irrigation valves, so a simple relay board should handle that.

1 Like