Raspberry Pi cooling fan and case

A photo of my Raspberry Pi in its new case with a cooling fan

We finally had some nice, warm weather a couple of weeks ago. Which was nice for being outside, but not so nice for my poor little Raspberry Pi, which couldn’t keep cool. So, I’ve upgraded it with this cooling fan and case from The Pi Hut.

Until now, I’ve been using the standard, official Raspberry Pi case. Which does the job of keeping dust out off the main board and protecting it, but not much else. As it’s plastic, it doesn’t do a good job of heat dissipation.

This was a problem last week, as my Raspberry Pi was getting so hot that it was shutting itself down to prevent damage. The impact of this was that my phone couldn’t access the internet, as I use AdGuard Home as the DNS server.

Cooling options

When it comes to cooling down a computer, there are three ways of doing it. Most use all three:

  • Ventilation – letting air flow through the computer
  • Active cooling – using a fan (or water cooling system) to move hot air away
  • Heat dissipation – using heat sinks to help get heat away from components like the processor

The Raspberry Pi has an ARM processor which is a RISC (Reduced Instruction Set Computer) type, and these tend to run cooler than CISC (Complete Instruction Set Computer) processors like those from AMD and Intel. This is why just about every smartphone uses ARM processors, as otherwise they would probably need fans too. Let’s just say Intel’s attempts at putting x86 processors into smartphones didn’t go well.

If you’re not doing anything too taxing with your Raspberry Pi, then the lack of cooling in the official case probably isn’t going to cause you issues. Indeed, I’d only had occasional issues until the recent warm weather. In addition to Home Assistant and AdGuard, my Raspberry Pi also runs Plex, MariaDB, Nextcloud, Calibre-Web, a Matter server and Nginx Proxy Manager, and it manages all these okay normally.

Cooling case

I ordered the new case from The Pi Hut on a Friday, and it arrived through my letterbox within 24 hours. It’s only £10 and includes a fan, which plugs into your Raspberry Pi’s GPIO (General Purpose Input and Output) ports for power. It comes in a tiny package, because there’s some assembly involved; essentially, you get four acrylic plates, the fan, and lots of screws. Each acrylic plate has been laser cut, and peeling off the protective film and popping out the tabs is quite satisfying.

You’ll need a screwdriver; I have one from the iFixit Essential Electronics Toolkit which seems to be the same one used in the assembly guide. Preparing the plates actually takes longer than the assembly – there’s not many screws and it all slots together.

Up and running with the cooling fan

Once assembled, I re-connected all the cables and booted my Raspberry Pi up. And then had to unscrew the top and re-connect the cooling fan wires as I’d put them in backwards. But after that, the fan whirred into action and I could feel a slight breeze coming out.

The fan is whisper quiet; whilst my hearing isn’t the best, I couldn’t hear it at all. It’s also worth noting that I run my Raspberry Pi on Debian, and not the official Raspberry Pi OS, and yet the fan still works. In other words, there’s no special drivers or scripts to install to get it to work.

If heat is still a problem, then there’s still plenty of space inside the case to add heat sinks, and again, The Pi Hut has you covered. In the meantime, I’ll see how I get on with this new case.

Water cooling?

I mentioned liquid cooling, which is more effective than a cooling fan, and sometimes used for high performance gaming computers. Of course, someone has done this for their Raspberry Pi, and the video is embedded above. The cooling system is huge compared to the Raspberry Pi board, which suggests that just because you can, doesn’t mean you should.

A temperature-controlled fan using Generic Thermostat in Home Assistant

A screenshot of the description of the generic thermostat integration in Home Assistant

So earlier this month, in my review of the ThermoPro Bluetooth Thermometer, I mentioned some ‘additional functionality’ in Home Assistant that I would write about. Well, later is now, and I’m going to talk about how I have a temperature-controlled fan in our bedroom, powered by Home Assistant and its Generic Thermostat integration.

Generic Thermostat is one of the older Home Assistant integrations, having been around for several years. It allows you to take any temperature sensor, and any smart switch, and automatically turn the switch on and off in response to temperature fluctuations. In essence, Home Assistant itself provides the thermostat functionality.

The switch should power something that can either heat up or cool down a space – for example, a plug-in heater, or an air-conditioning unit. In my case, I’ve hooked it up to a standard pedestal fan, and used a smart socket to turn the fan on or off at the plug.

Enabling the integration

Note: within days of publishing this blog post, Home Assistant 2024.7.1 was released, which allows you to configure the Generic Thermostat through the Lovelace UI, so you don’t need to add the YAML code anymore.

I mentioned that it’s an old integration, and sadly it’s not one that has been updated much since it was implemented. This means that you can’t add it using the Home Assistant interface (Lovelace), and instead you’ll need to add it to your configuration.yaml file.

Here’s mine:

# Generic thermostat
climate:
  - platform: generic_thermostat
    name: Bedroom thermostat
    heater: switch.bedroom_fan_socket
    target_sensor: sensor.tp357s_55ab_temperature
    min_temp: 15
    max_temp: 30
    ac_mode: true
    target_temp: 19
    cold_tolerance: 0.5
    hot_tolerance: 0.5
    min_cycle_duration:
      minutes: 20
    away_temp: 19
    precision: 0.1

Here’s what each variable refers to:

  • Platform specifies the integration, and the Name is the friendly name of the device.
  • Heater is the name of the entity that controls the smart socket that the fan is attached to.
  • Target_sensor is the name of the thermostat entity that provides the temperature.
  • Min_temp and Max_temp set the minimum and maximum temperatures that you’ll see on the Climate card in Lovelace – I’ve set these to 15°C and 30°C respectively.
  • AC_mode is set to ‘true’ because we’re using a device that’s supposed to cool down the room. If this were a heater, I would leave this line out.
  • Target_temp is the temperature that I want the thermostat to achieve, which is 19°C.
  • Cold_tolerance and Hot_tolerance mean that Home Assistant will only turn on the fan when the room reaches 19.5°C, and will only turn it off when it reaches 18.5°C.
  • Min_cycle_duration means that if Home Assistant turns the fan on, it should stay on for at least 20 minutes, and vice-versa, so it’s not constantly cycling on and off.
  • Precision is how much precision I want when setting the temperature; at 0.1, this means I can set it to 1/10th a degree.

Once you’ve added or amended the settings for your thermostat, you’ll need restart Home Assistant.

How it works in practice

So, once set up, if the temperature in our bedroom reaches 19.5°C, the fan will come on. It’ll then stay on until the room reaches 18.5°C, or 20 minutes, whichever happens first.

You can also control the thermostat like you would with, say, a Nest thermostat through Home Assistant. It will create an entity which you can add a card for on your dashboard. So, although you may have set a target temperature in the initial configuration, you can change this without editing your configuration file. However, if you re-start Home Assistant, it may forget this.

If you also use Google Assistant or Alexa, then you can also make them see and interact with your generic thermostat, if you have integrated these with Home Assistant.

Whilst I use a fan and a smart switch, if you have an air conditioning unit with an RF control, you could use an RF bridge to allow General Thermostat to control it.

Fans vs air conditioning

If you do use a fan with Generic Thermostat, you’ll notice that your fan may stay on for a long time. That’s because fans don’t actually cool the air; they move air around which helps sweat evaporate more quickly. That makes you cooler, but not the air around you. It’s a bit like a hot day at the seaside, where the breeze takes the edge off the heat.

Air conditioning systems actually cool the air down, but are much more expensive and need an outlet for the hot air to be pumped out. Most British homes don’t have air conditioning, including ours – most of the year, it’s too cold, and our houses are designed to retain heat.