Controlling cooling fan for Raspberry Pi 4

Just updated Home Assistant and the fan shim has stopped working, just on all the time.
My setup is the same as the original. Any idea’s of what should be changed?

EDIT: Just installed the HACS source and all wroking again. Thanks

1 Like

I have been trying to reconfigure the Yaml code but really struggling to get the fan working again, would you be able to share your updated Yaml code for this?

You don’t need any other yaml code. Install custom rpi gpio integration over HACS.

I did have it with a sensor though, and on a thermostat card, see attached. Now the fan is always on, day and night, this card no longer works. Yaml code is:

climate:
  - platform: generic_thermostat
    name: RPI Cooling Fan Controller
    heater: switch.rpi_cooling_fan
    target_sensor: sensor.cpu_temperature
    min_temp: 40
    max_temp: 80
    ac_mode: true
    target_temp: 50
    cold_tolerance: 0.1
    hot_tolerance: 0.1
    min_cycle_duration:
      seconds: 30
    keep_alive:
      minutes: 5
    initial_hvac_mode: "cool"

Any ideas?
Screenshot 2022-07-14 at 18.27.35|550x500

Update rpi gpio to version 2022.7.0.
If there is a problem, restart the host

Check this post for updated code (older syntax commented)…

Thanks for the info, I really do struggle getting my head around things like this.

I have updated the code: See Below, but it doesn’t appear to have made any difference to the fan, it is still running constantly.

  - platform: rpi_gpio
    switches:
      - port: 18
        name: "RPi Cooling Fan"
        unique_id: "rpi_cooling_fan" 
climate:
  - platform: generic_thermostat
    name: RPI Cooling Fan Controller
    heater: switch.rpi_cooling_fan
    target_sensor: sensor.cpu_temperature
    min_temp: 40
    max_temp: 80
    ac_mode: true
    target_temp: 50
    cold_tolerance: 0.1
    hot_tolerance: 0.1
    min_cycle_duration:
      seconds: 30
    keep_alive:
      minutes: 5
    initial_hvac_mode: "cool"

Am I doing something wrong here?

Make sure you’re also using gpio 18.
50C may be a lil’ too low.

Does the switch actually work? Try to manually turn off the fan by using the switch.

The coding seems right,but maybe there’s a problem with your fan/shim/circuitry.

It did work, but when I switch the fan off on the thermostat, it says ‘Idle’ but the fan keeps running?

It was using Port 18, I have tried increasing 50c to 58c but it hasn’t made any difference.

Weird that before the update it was working fine, the whole thing is less than 6 weeks old.

Not sure if this sheds any light on it?

You are not listening to my suggestions. You don’t have a problem with the fan, but with the rpi gpio integration that doesn’t work for you after the update. After HA update to version 2022.7.x rpi gpio integration was broken. A new version 2022.7 has been released that you need to update to and if it doesn’t work you can try restarting the host or remove the integration (configuration yaml), restart HA and add the integration again.
The consequence of the rpi gpio not working is that the fan is still spinning.

@adrian.walsh , I’m assuming you’re using this integration via HACS and not the deprecated gpio integration (as @pepe59 said above).

I also assume it uses HACS integration because native rpi gpio integration was removed in HA version 2022.6

1 Like

Thanks all.

I’ve just added a Pimoroni Fan SHIM to my Retroflag NESPi 4 Case as the existing fan was too noisy and permanently on.

The rpi gpio integration worked beautifully.

Hello,
my fan is connected to GPIO 4 (red wire, with the black wire going to GPIO 6, i.e. ground) so I used port 4. But my fan remains on no matter what, even if I toggle the switch manually. What am I missing?

switch:
  - platform: rpi_gpio
    ports:
      4: RPI Cooling Fan
climate:
  - platform: generic_thermostat
    name: RPI Cooling Fan Controller
    heater: switch.rpi_cooling_fan
    target_sensor: sensor.cpu_temperature
    min_temp: 55
    max_temp: 80
    ac_mode: true
    target_temp: 55
    cold_tolerance: 0.1
    hot_tolerance: 0.1
    min_cycle_duration:
      seconds: 30
    keep_alive:
      minutes: 5
    initial_hvac_mode: "cool"

1 Like

Looks like the pins you are using are always on.

Can’t smart-control a dumb fan unless you do some modification. Cheapest would be my current setup, detailed in this post. Takes minimal soldering skills and extremely cheap electronic parts.

2 Likes

Hello,
I saw your post, but I also found another link.
Could you explain to me the difference between these two methods?

The first uses a 680Ω resistor, an NPN transistor (2N2222), and 5V pin.
And the second uses a 110 Ohm resistor, an NPN S8050 transistor, and 3.3V
NOTE: I use a Raspbee II which is already present on PIN 1,2,3,4,5,6,7,8,9,10,11,12.
So I wanted to know your opinion on this second assembly?
Thanks a lot !!

Have you downloaded the GPIO interface via HACS?

I have edited the YAML file, I get the temperature indication on the dashboard.

However: I’m getting these errors:


Unable to find referenced entities switch.rpi_cooling_fan or it is/they are currently not available

20:27:34 – (WARNING) helpers/service.py - message first occurred at 16:02:34 and shows up 54 times

Error setting up trigger test utility

15:57:37 – (ERROR) Automation

Platform error: switch - Integration ‘rpi_gpio’ not found.

15:57:33 – (ERROR) config.py


What am I doing wrong? Do I need some dependencies installed?

Any Help, please?

You should download GPIO integration from HACS repo