Viewing topic: Software

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:

Running Baikal DAV server on a RunCloud VPS

28 Mar 2022 / / /

A proper tech post…

If, like me, you need to keep a calendar and contacts synced between computer (M1 Mac) and phone (Android), have a limited budget, but are not willing to sell your soul or your data to a tech giant in order to do so, your options are limited. Apple iCloud? No. Microsoft Outlook? Nope. Google? Absofuckinglutely not. Zoho? No, I don’t trust them either.

Away from the giants, the best known third party option is Fruux, and I used it for quite some time, but increasingly it throws errors when Apple Calendar tries to sync, and its web interface displays HTTP 500 errors more often than real pages.

Some web hosting companies also offer CalDAV and CardDAV hosting if you use their services, but none of these companies are ones that I would actually trust to keep my data safe and help me if there was a problem (Ionos? Do me a favour…).

Self-hosting options

Now you’re talking.

There are a few possible contenders:

  • OwnCloud – PHP-based groupware, focus is on corporate solutions but self-hosting available
  • NextCloud – Fork of OwnCloud by the original creator, widely used
  • Radicale – Python-based pure CalDAV and CardDAV server (much narrower focus than NextCloud)
  • Baikal (styled as Baïkal for some reason) – PHP-based pure CalDAV and CardDAV server

There may be more but these were the ones I found.

Because I’m a PHP expert with no real experience of Python, that put Radicale out of the running for me. And after reading many comparisons of OwnCloud and NextCloud, it was clear that NextCloud attracts many more self-hosters than OwnCloud.

So, NextCloud or Baikal? One is a complete groupware environment, the other a small, lightweight, focussed solution.

Well, I tried both. Duh.

In fact, and here is a small diversion in the interests of completeness, I tried them both about 2 years ago, and failed to get either one working reliably, which is why I ended up using Fruux for ages.

In NextCloud’s case, I got it installed successfully (I believe I was using Cloudways hosting at the time), but I wanted to make proper use of the groupware features such as file storage, and I couldn’t make it accept any file uploads larger than about 10Mb. No way, no how. Looking back now, I guess it would have been related to this issue, but at the time I couldn’t get NextCloud support to take me seriously. So my assessment of NextCloud was “fuck this for a game of soldiers”.

Then I tried Baikal, but couldn’t get either Apple Calendar or Thunderbird’s Lightning to connect and sync. Since I think this was in 2020, I would have been using Baikal 0.5.x, though I can’t recall precisely.

I figured the “0.” in front of the version meant that Baikal simply wasn’t ready for primetime, and didn’t pursue it further. I found Fruux, which was free for up to 2 devices, so for a while that was OK.

Now, fast forward to 2022, and both Thunderbird and Apple Calendar keep failing to connect to Fruux. Also, as noted above, logging in to Fruux to check if events are getting through often results in HTTP 500 error pages.

So the inevitable thought that crossed my mind (well, inevitable if you’re me) was, “hmm, I wonder if Baikal is better now?”

Setting up Baikal

These days I manage a set of bare-metal VPS servers with RunCloud, which means I have far greater control over everything than when I used Cloudways. I decided that Baikal had to be worth one more try.

So, here are the steps I followed:

  1. Set up a subdomain to use for Baikal (you know, like dav.mydomain.com).
  2. Created a new system user in RunCloud.
  3. Created a new empty hybrid webapp (Nginx + Apache) in RunCloud, controlled by the above system user, and added a Let’s Encrypt certificate.
  4. Created a new database + user in RunCloud.
  5. Downloaded and unzipped Baikal 0.9.2.
  6. Read the installation instructions.
  7. Uploaded the Baikal install files to the webspace, and set the application root to point to the html folder in the RunCloud console.
  8. Ran the installer in my browser, choosing the MySQL database option.
  9. Set up a user account in Baikal and tried to connect from my Mac. No joy.

Damn, I thought.

Then I read the installation instructions again, particularly the Nginx Configuration section.

What I had thought was unnecessary code (because RunCloud sets up the virtual host automatically) actually contained a couple of lines that were related specifically to a DAV setup:

rewrite ^/.well-known/caldav /dav.php redirect;
rewrite ^/.well-known/carddav /dav.php redirect;

Oops!

So I added these two lines to a fresh custom Nginx config file in my RunCloud console. I selected the “location.main-before” priority and called the file “wellknown.conf”.

BINGO.

The Accounts app in Apple System Preferences instantly connected to Baikal – both CalDAV and CardDAV. Note that I used just the basic subdomain name as the server name when connecting (like dav.mydomain.com, no https, no slashes, no path, nothing else).

So I imported my calendar and contacts files and could see the event and contact counts gradually increasing in the Baikal admin console.

Next, I used DAVx5 on my Android phone to connect, which it did without problems.

A simple, satisfactory solution

So, I now have a private online calendar and contacts address book, hosted using open source software on a server that I pay for anyway, and accessible by as many devices as I choose. I can back it up whenever I like, either via exporting in macOS or a complete FTP backup and database dump, and I can restrict access to specific IP addresses in RunCloud if I choose.

Job done.

Share:

Free as in beer

19 Feb 2022 / /

I have a complicated relationship with FOSS (Free and Open Source Software) .

I like not paying for things where possible – who doesn’t? It makes my money go further (sometimes quite a bit further). I am also vehement in my dislike of the concept of software by subscription – if I buy something, it should be mine to use forever.

So for many years I have sought out and used free alternatives to the commercial software I would otherwise have had to buy. I use LibreOffice instead of Microsoft Office. Before LibreOffice I used OpenOffice. (Before OpenOffice I used a pirate copy of Microsoft Office like everyone else, but this article isn’t about piracy.)

As someone involved in web development, I also use graphic and design software. Initially because of the massive financial outlay, and later because of their subscription model, I have avoided Adobe software like the plague, and for several years my primary tools have been The Gimp and Inkscape.

But as my need to create SVG illustrations has grown over the last year, I have encountered more and more problems with Inkscape. The user interface is nosebleed-inducingly complex and not at all intuitive, SVGs downloaded from the web often look completely different when loaded in Inkscape, dealing with paths is very fiddly, and it continues to crash with distressing frequency.

Recently I found Inkscape simply couldn’t properly render some SVGs I had to edit, and as I was up against a deadlne, I had to find something else, and it had to be easy to use (no time for a steep learning curve).

So I had a hunt online. After I had eliminated everything that didn’t work on a Mac, everything that needed an account to use (Why? It’s a fucking image editor!), everything that ran in a browser (that’s just silly), and everything on a subscription model (see above), there wasn’t much left. There was the free macSVG, which is just garbage, and there was Affinity Designer, which isn’t free but is quite cheap and there is no ongoing subscription.

I downloaded Affinity Designer and tried it out (10 day free trial), and within 24 hours it had persuaded me to stump up the $50 for a license. Now I use it daily and it’s an absolute joy to use. After that I had to try Affinity Photo and found that it was also light years better than its open-source counterpart (The Gimp), so I’ve bought that as well. I’m saving hours every week in previously lost productivity.

Now, the point of these musings isn’t to advertise Affinity Designer or Affinity Photo, but rather to make the point that, often, you get what you pay for. Or as my wife endearingly says, you pay what you get for.

To put it another way, an application like Inkscape may have a number of talented developers working on it, but if they are not being paid for their work, that means it is not their primary focus, and they cannot be relied on to make improvements or squash bugs in a timely manner. And when an application is mission-critical, that’s often not good enough.

In its favour, free software is generally (though not always) open source, which has the useful attribute of allowing the source code to be audited to ensure it contains nothing malicious, but I’ve come to realise that this in itself isn’t enough to make the free option the best option. I feel this fact is often missed by FOSS purists (you know, the ones who think Richard Stallman is sane).

So let’s hear it for pragmatism. It’s good to save money and have access to source code, but it’s also good to get things done.

Share: