RPI4 fan control

I installed the latest HAOS on my raspberry pi 4.

On my raspberry pi 4 I have the official fan, which is very loud so I want to be able to configure the speed so it only run fast when is above 80°C and the rest of the time is quiet. Installing Raspberry Pi Os is possible to configure it like this, so I imagine this souble be doable in HAOS as well

I tried looking for addons, settings, everywhere but I found nothing useful. I’m using the GPIO 14 for the fan if that helps

1 Like

Look at using this.

2 Likes

Thanks Adam, I finally made it work!

After installing the addon you told me I had to add this config

switch:
  - platform: rpi_gpio
    switches:
      - port: 14
        name: "RPI Cooling Fan"
        unique_id: "rpi_cooling_fan"
        
climate:
  - platform: generic_thermostat
    name: RPI Cooling Fan Controller
    unique_id: 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.5
    hot_tolerance: 0.5
    min_cycle_duration:
      seconds: 120
    keep_alive:
      minutes: 5
    initial_hvac_mode: "cool"
3 Likes

where are you adding that config? is it possible to do it from the GUI, or just from SSH?

/homeassistant/configuration.yaml via HA and File editor

I’ve added this and can trigger the fan by the switch. However, I cannot find a CPU temp in entities and don’t think my CPU temp is being read. Any way to check? Thanks.

You need to add it to your configuration.yaml

@at9 Hi, i have been following exact same config but in my case nothing is happening in the way that my fan keeps turning no matter if i switch it off with switch platform or not. It seems the pin 18 that i am using is not “sending” any info to cut the power form pin +5v…

Here is my code:

switch:
  - platform: rpi_gpio
    switches:
      - port: 18
        name: "Fan Office"
        unique_id: "fan_office_switch_port_18"

any help would be so much helpful :slight_smile:

I don’t actually use the GPIO pins I just have my fan running all the time.

If I was to troubleshoot it though are you using pin 18 or GPIO 18 as they are not the same?
And also try a different pin to see if that one works.

1 Like

Are you use Home Assistant OS?

If no hardware sensor data is available (e.g., because the integration runs in a virtualized environment), the sensor entity will not be created.

from here.