Unsociable Christmas Tree (Part 2)

Back in 2020 I talked about my Raspberry Pi powered Christmas Tree. Today’s blog delves into what I’ve done this year.

Previously, I decided that setting up a web server on which family members could change the light patterns on the tree was too boring. At the time, I was thinking of extending the sample Python code – much as I did with the OpenCV frontend – with a simple Python-based web server.

There are a few problems with this approach. Firstly, while I’ve never set up a Python web server, I don’t necessarily feel that it would be a challenge. More of a challenge would be my web development skills, which are, for the most part, stuck in about 1997. If you want formatting using tables rather CSS, I’m your man.

I found a way to solve both problems, while also using a Raspberry Pi Zero W for something outside its intended purpose.

I decided to use the Vaadin Java framework for the user interface. With Vaadin you don’t need to worry about HTML and formatting, you say, for example, I want a block with a group of radio buttons and a text box, and it generates your HTML, JavaScript and backend code. You can kind of think of it as SwiftUI for the web.

I wrapped it all in Spring Boot, because using an enterprise-grade UI library on a slow, single-core, 32-bit ARM CPU with 512Mb of memory isn’t ridiculous enough.

Jumping ahead for a second – spoiler alert – the application takes about two minutes to start on the Pi Zero W. It performs reasonably well once it’s started, but I think it’s fair to say that few corporations are going to be using Pi Zeros as part of their infrastructure.

It sounds bad, but the other way of looking at it is that it runs! A computer that costs £15 is able to run 47Mb of modern Java 17 code1. It’s not practical, but it is pretty amazing.

Before figuring out the user interface, the first thing I needed to work on was how to get Java to talk to the LED Christmas Tree. The sample Python code uses some library code that reads and writes to the Pi’s GPIO pins. Can you even do that in Java?

It didn’t take a lot of searching around to find Pi4j, a Java library to do exactly that.

It took a lot of experimentation to get it working. The defaults didn’t work – no errors, it just didn’t light up the LEDs. The Pi Zero isn’t an ideal Java development platform, so I did the coding on my MacBook, which also isn’t an ideal Java development environment. I was lazy, in a bad way, and didn’t properly build a test environment, instead building a JAR file on my laptop, manually copying over to the Pi and running it. I also found that Visual Studio Code isn’t as good as IntelliJ for writing Java programs.

Through a process of experimentation, I realised that I needed to use the pigpio backend provider2. The downside of using pipgio is that it requires super-user access. The alternative LinuxFS plugin does not need to be run as root, but it does not currently support access to the GPIO pins3.

Having proved that it was possible to flash the Christmas Tree’s lights in Java, I set out to port the Python library that came with it. The basics were pretty straight-forward. The sample code, however, uses sleep statements between the various lighting patterns, something that I didn’t want to do. I overestimated how complicated this would be and ended up simplifying my code. This is rare; I normally start super-simple and iterate.

Finally, I connected the two parts together, et voila, a working, Java-based program driving the Christmas Tree lights with a web interface for configuration.

Computer JVM Startup time
Pi Zero W openjdk version “17.0.8” 111
MacBook openjdk version “21.0.1” 4.2
Pi 4 openjdk version “17.0.9” 15
Pi 5 openjdk version “17.0.9 5.6

Interestingly, the Pi Zero and the Pi 4 both start the JVM in “client” mode, while the MacBook and the Pi 5 use “server” mode4. The Pi Zero also runs in 32-bit mode. I suspect, but didn’t verify, that the difference between the 4 and 5 is at least partly down to the newer instruction set in the 5, which supports native “atomic” operations5.

Software is never completed, only abandoned. And in that spirit, there are a number of things that it would be nice to improve.

The most important aspect is that it’s currently running as root (well, my user with sudo). One perk is this is that it can trivially run on port 80. The risks of running as root on my home network are pretty low, but it’s still not a good idea. I’ll need to update the Pi library so it can access the GPIO pins as a non-privileged user. I’ll then need to figure out a clean way to have the server accessible on port 80 (a web proxy?).

Since we’re not aiming for practical, another option would be to go for the micro services approach. One service to manage the LEDs and another for the UI.

Who knows if I’ll get time for all that. Next year, maybe.


  1. I’m sure it used to cost less than this. The Pi Zero 2 W is now available for about the same price, but has a quad-core, 64-bit CPU. ↩︎
  2. “Pig-pio” is how I always think of it. ↩︎
  3. As I write this, I see that there’s a new release of the Pi4j library which does support accessing the GPIO pins with LinuxFS. I’ll update the code when I get a chance. ↩︎
  4. Switching the Pi 5 to client mode didn’t make a huge difference. ↩︎
  5. At work, we benchmarked Apache Ignite on an ARM-based server, and found that it performed relatively poorly because it lacked the Large System Extensions. ↩︎

Escape

Marie Le Conte is one of my favourite panelists on the Oh God What Now podcast. I thought I should make an effort to read one of her books, hence “Escape” (affiliate link). It is about how Millennials were the first generation to grow up with the internet and how they shaped it.

Whatever you make of the ideas or commentary1, one thing is abundantly clear: her personality shines through. You can hear her speaking every sentence. Fast, slightly scattered thoughts with the occasional random aside. In books of this type, it’s rare to come across lines such as:

Still, that isn’t quite the point I was trying to make

In works with less personality the preceding paragraph would have been edited out!

Another example.

(I’m very sorry, I’m going to have to pause for a moment to childishly laugh at the sentence ‘we were using our fingers instead of our mouths.’)

(Okay, I’m good.)

It’s not pretending to be a serious book, though there are serious points to make. It doesn’t quite hang together as a whole. She describes the chapters as essays, and that’s pretty accurate. Think of it as a collection of loosely related essays rather than a cohesive, single narrative.

The essays cover topics from finding your tribe to dating to how nothing is ever as good as it used to be2.

One of the serious points continues to be very relevant with the recent changes in ownership, and therefore moderation, of Twitter and Tumblr.

All we have now is this tiered internet, where everything non-sexual can co-exist — including racism, fake news, abuse, misogyny and the like — but nipples are beyond the pale.

And apparently I’m a terrible person.

I have been in full-time employment for nine years and I still bristle whenever someone sends me a short message with a full stop at the end.

I’ve seen people sign off their text messages. I don’t do that. But tapping space twice at the end of a text message feels like a small price to pay for have a full stop in the correct place3.

Overall, I quite enjoyed “Escape.” I wouldn’t say that it’s essential reading, or that it uncovers many new and unique insights, but you might find it relatable or funny.


  1. I’m not entirely convinced, personally. As a Gen X, I don’t feel substantially less online than many Millennials. ↩︎
  2. Millenials are getting old. ↩︎
  3. I guess this is the marker of me being Gen X. ↩︎

How Britain Broke The World

Popular opinion is that the whole of the UK was against Blair’s invasion of Iraq. Over a million people marched in London.

I wasn’t one of them.

I’m not sure that I was as politically engaged then as I am now, but the main reason that I wasn’t there was because I wasn’t entirely against the intervention. Sure, I never believed the justifications that they gave. The whole ability to attack in 45 minutes seemed unlikely, and the connection to Al Qaeda didn’t seem plausible either. Blair deserved all resistance he got for such obvious untruths.

So if I didn’t believe in the reasons given, why was I not against the invasion? Because the regime was abusive to its own population. We talk about choices and democracy and representation, but what can people do when they have such a corrupt, oppressive and violent government?

Other countries tend to say it’s not their concern. Does that mean it’s okay to let people suffer because they were unlucky enough to be born in the wrong country? I say no1. The international community has a responsibility to the world’s population, wherever they live2.

I should add that my (limited) support of the policy was about the idea of an intervention. The execution of the idea was clearly a mess, but no one marching knew that.

Anyway, the book.

As I tend to do, I second guess myself. Was my opinion, if not correct then, at least justifiable? If I didn’t know better, should I have known better? I got “How Britain Broke the World” by Arthur Snell to answer that question, and others.

It starts in 1997 with Kosovo and finishes with Brexit in 2021. I do think it strays from the title at times, which comes across as the book equivalent of click-bait. However, it largely answers my questions.

The simple chronological structure helps put the individual events into perspective. I’d forgotten some of them, and the details of many. In the end, I think my opinion on the Iraq invasion is similar to that of many of the interventions: the argument for doing something was there but the execution was poor3.

If there’s something to take away, it’s that we don’t learn.

You can see that because, weirdly, this is a very current book. By which I mean that shortly after reading various sections, I’d come across some contemporary event that was about the same thing. Russia. The Middle East. The US-UK “special relationship.” It’s all there and it’s all ongoing.

I can’t say I’m now an expert on any of these events or situations. It’s all complicated. Many of the challenges we have are from people who are trying to give simple solutions to complex problems4. But I can say that I am better informed than I was. To paraphrase, Donald Rumsfeld, I now have fewer unknown unknowns.


  1. It’s a slightly odd realisation to finally figure out that you don’t believe in the concept of a country. Not as in I deny that they exist, obviously, but in the sense that your potential shouldn’t be constrained by the place you happen to have been born. ↩︎
  2. Deciding what are universal rights has been a challenge, too. The Universal Declaration of Human Rights seems pretty good to me, though arguably it come from a liberal, western perspective so perhaps I would? ↩︎
  3. I realise this isn’t a wholly original take. I’m just slow on the uptake sometimes. ↩︎
  4. That’s Brexit in a nutshell. ↩︎

Wilt on High

Wilt on High” is another one of those books that I read because a number of people said “if you like Douglas Adams, you’ll enjoy Tom Sharpe.” This book was picked arbitrarily by virtue of being available in a second hand bookstore for 50p.

Since it’s the third book in the series staring Wilt and I’ve not read any of the others, there were some references to the backstory that I missed. I don’t think those details were absolutely critical.

Written in the early eighties, there are aspects that have not dated well. There are references that younger readers will miss or not understand. My understanding of some parts was tenuous. And the occasional description, well, let’s just say you might phrase it differently now.

But it mostly stands up. The petty politics and personalities are still relevant and the writing is good. The dialogue, the bickering and characters are all well conceived. The story is a farce, with different threads coming together towards the end. The humour wouldn’t work if the characters motivations and state of mind were not clear. It’s one of those things that looks easier to do than it is, and it appeared effortless here, which I mean as a big complement.

Having said all that, it’s not terribly like Douglas Adams. While humorous, it’s not as clever as Adams and the writing, while good, is not at the same level. The comparison peters out after “funny” and “well written.” Adams’ obsession with digital watches dates his work a little, but Wilt being so firmly set in early eighties Britain does limit its modern appeal.

What if? 2

Following on from XKCD, “What if?,” and “How to” comes Randal Munroe’s “What if? 2.” It’s another collection of silly questions with scientific, humorous answers. Examples include “Could you eat a cloud?” and “How far could you see if you had an eye as big as the earth?”

It’s as simple as this: if you liked those books, you’ll like this one.

“Incineration of organic matter within it” is a bad feature for an umbrella.

If I have a criticism, it’s that it feels like it’s playing by numbers at this point. All the same ingredients are there. I did enjoy it — I genuinely laughed out loud at parts of it — but it’s not as fresh and original as, well, the original. Is this the fate of all sequels?

Parkrun 100

Recently I laced up my Brooks Glycerin and took the Tube a couple of stops north to run my one-hundredth Parkrun. I deliberately picked Tooting Common, as that’s where I ran my first back in May 2018. I only just arrived in time – missing a milestone shout-out – but otherwise, there was no drama, only the satisfaction in achieving it.

My previous milestone run didn’t go as smoothly. I ran my 49th on the first of February 2020. Work and weather conspired against me for a few weeks. Then as I was ready for run 50, COVID hit properly, and Parkrun was cancelled until mid-20211.

As nice as the milestones are, the real achievement for me is that I’ve kept running all this time. I don’t think I’ve ever had an exercise regime that I’ve kept up for so long and so consistently.


  1. The last in 2020 was on 14 March. The next didn’t occur until 31 July 2021. Having avoided getting COVID, it took a couple of months before I was comfortable going back to running in big groups.] ↩︎

Photography, opinions and other random ramblings by Stephen Darlington