Viewing topic: Hardware

Argon One v2 case fan control with LibreElec 10

I do like my 8Gb Raspberry Pi 4B. With LibreElec installed, it’s an excellent way to have Kodi streaming on a TV. The only trouble is, the case I got with my Pi 4B kit was a lightweight plastic one, and the cables sticking out of the back and side stop it from sitting flat on its shelf by the TV.

So I’ve treated myself to what seems to have become the serious Raspberry Pi case – the Argon One v2. I particularly like it because:

  • It’s relatively heavy so doesn’t tilt off its feet when cables are connected
  • All the ports (except the SD card) are at the back which is much tidier
  • It has a programmable fan and a power/reset switch
  • Although pricier than some cases, it still won’t break the bank.

It arrived in a smart box with a printed instruction booklet in English (not Chinglish!), and a bag containing thermal pads, screws and rubber feet. Nice considering the low cost and the fact that the Pi is a hobbyist computer.

Argon One v2 Hardware installation

Installing my Pi in its new home was fairly easy:

  1. Take it out of the old case
  2. Twist off the 4 heatsinks (the old case didn’t have a fan) while still warm (so the thermal pads are soft)
  3. Use a few cotton buds dipped in anti-COVID alcohol to remove the residue of the thermal pads from the chips that were heatsinked
  4. Follow the instruction booklet. I set the power jumper so that whenever there’s a power failure, it switches on automatically when power is restored (and if you live in the Philippines as well, you’ll almost certainly want to do the same).

After that, I connected everything (I had to switch to a full-sized HDMI cable instead of the micro-HDMI one I had been using) and powered up. No problems – except that the fan was running at full tilt (and full tilt is bloody noisy – it can be heard clearly over 10 metres away).

Happily this can be corrected in software (and this is the whole point of this article). Read on.

LibreElec Software Installation

Argon Forty provides software that lets the operating system control the fan and also the power/reset switch. The primary version of this software is for Raspberry Pi OS (formerly Raspbian), but there is a simpler version available for LibreElec.

To install it, do the following:

  1. In the Kodi UI, install the Raspberry Pi Tools and System Tools here:
    Addons > Install from Repository > LibreElec Addons > Program Addons
  2. Check that you have SSH enabled in LibreElec/Kodi
  3. Reboot your Pi (either via SSH or in Kodi)
  4. SSH in as root
  5. Run the following command:
    curl https://download.argon40.com/argonone-setup-libreelec.sh | bash
  6. Reboot your Pi

Now, you have a new command available to you. In a SSH session, you can enter ./argonone-config to adjust the fan control. When you run the command, it asks you to confirm that you want to override the fan setting, then it asks you if you want the fan always on or not. Simples.

Except it doesn’t work. The fan just keeps running at full speed.

After hitting the search engines, it seems this may be a problem introduced in LibreElec 10 because it uses an updated version of Python. I could be wrong about this conclusion, but that doesn’t matter. What matters is finding a solution.

And I found one – in two parts.

Fixing the lack of control, part 1

Firstly, you have to get the Argon One system service to reference Python at a different location. Here’s how you do it:

  1. SSH in to your Pi as root.
  2. Edit the argononed.service file
    nano /storage/.config/system.d/argononed.service
  3. In that file, there is a line starting with ExecStart. Change that line to read as follows:
    ExecStart=/bin/sh -c ". /etc/profile; exec /usr/bin/python /storage/.config/argononed.py"
  4. Reboot your Pi.

Now, when you use the ./argonone-config command, the fan will obey. Woot!

But it’s still either full speed or off, all or nothing. We can improve on that.

Fixing the lack of control, part 2

If you do some exploring, you’ll see that argonone-config is actually just the name of a bash script file and you can edit this file. So let’s take a look. If you enter nano argonone-config in the default SSH folder, you’ll see the contents of the bash file, and near the end you’ll see something like this:

if [ "$confirm" != "Y" ]
then
        echo 90"="100 >> $daemonconfigfile
        echo "Fan off."
else
        echo 1"="100 >> $daemonconfigfile
        echo "Fan always on."
fi

Let’s focus on those numbers. On each echo line with numbers in it, the first number is the minimum CPU temperature (in celsius), and the second number is the fan speed percentage.

For example, 90"="100 means “When the temperature is 90 degrees or higher, run the fan at 100% speed”.

From checking some online examples, I found that you can provide multiple instructions and they will all be obeyed. For example:

echo 40"="50 >> $daemonconfigfile
echo 60"="100 >> $daemonconfigfile

This means “When the temperature is 40 degrees or higher, run the fan at 50% speed, but when it reaches 60 degrees, run the fan at 100% speed”.

Now, my Pi tends to run at about 42 degrees when idle, increasing somewhat when it’s working harder (and that’s fine – as long as it doesn’t increase by too much).

So after some experimentation I edited the above code block so it looks like this:

if [ "$confirm" != "Y" ]
then
        echo 45"="5 >> $daemonconfigfile
        echo 50"="10 >> $daemonconfigfile
        echo 60"="40 >> $daemonconfigfile
        echo 70"="70 >> $daemonconfigfile
        echo 80"="100 >> $daemonconfigfile
        echo "Fan is progressive."
else
        echo 1"="100 >> $daemonconfigfile
        echo "Fan always full speed."
fi

So now, when my Pi is idle (i.e. below 45 degrees), the fan is off. When it starts heating up a bit, the fan kicks in, low speed at first, then progressively higher to cool it more aggressively. It works a treat.

Job done!

The fan’s still a bit noisy even at low speeds, but the only way around that would be to install a better quality one in the case.

And if you want an even more versatile script with additional options, like the one Argon Forty provided for Raspberry Pi OS, you can explore this LibreElec forum post. Lots of juicy coding goodness.

But what about the power/reset switch?

Well, that’s another story.

Sadly, the currently-available LibreElec code for the Argon One v2 case does not allow customisation of the power button. So I’m stuck with the default settings, which are:

  • Short press (<3s): does nothing
  • Long press (>3s): shutdown
  • Very long press (>5s): force shutdown
  • Double-click: restart

But to be honest that’s totally fine for me. These defaults seem very sensible and I’m not sure what I’d change even if I could.

Share: