1. Tunneling Elixir Cluster Network Traffic Over Wireguard

    Tue 07 November 2023


    The other day I was supporting a customer with an Elixir-based platform that would make use of Elixir libcluster, so messages on one host can be passed to other hosts. This can - for example - enable live updates for all users, even if they are not communicating with the same application server.


    Elixir's libcluster does support encrypted communication using TLS certificates however I was struggling with the help of an application developer to make it work.

    "severity":"warn","message":"[libcluster:example] unable to connect to :\"app@Host-B\"

    I'm absolutely open to the idea that we did something wrong and certificate-based encryption will work, but we were time-constrained and we decided to opt for another solution that seemed simpler and easier to maintain.

    Wireguard as the encrypted transport

    I deployed a Wireguard mesh network between all application servers using Ansible, which was straight forward. We just provisioned all hosts into the /etc/hosts file to keep things simple.

    In the table below, we show a simplified example of the setup.

    Hostname IP-address Wireguard Hostname Wireguard IP-address
    Host-A Host-A-wg
    Host-B Host-B-wg

    The Elixir applications would only know about the Host-A|B-wg hostnames and thus communicate over the encrypted VPN tunnel.

    The problem with wireguard and libcluster

    The key issue with libcluster is that when Host-A connects to Host-B, it uses the DNS hostname Host-B-wg hostname. But the actual hostname of Host-B is - you guess it: 'Host-B'. This means there is a mismatch and for reasons unknown to me, the libcluster connection will fail.

    So the target hostname as configured in libcluster must match the hostname of the actual host! Since libcluster seems to make usage of domain names mandatatory, using IP-addresses was not an option.

    If we would point Host-B to it's Wireguard IP-address (, the problem would be solved. However, in that case, Wireguard doesn't know about the external IP address and also tries to connect to the non-existing address. So the Wireguard tunnel would never be created.

    The solution

    The solution is not that elegant, but it works. We still point the Host-B domain name to the wireguard IP address of but we create an additional DNS record specifically for Wireguard, pointing to, so it can setup the VPN tunnel.

    This is what /etc/hosts looks like on Host-A: Host-A Host-B Host-B-wg

    And this is what /etc/hosts looks like on Host-B: Host-B Host-A Host-A-wg


    Although all choices are a tradeoff, for us, the Wireguard-based solution makes most sense. Especially now that we have an encrypted tunnel between all hosts and any future communication between hosts can thus be encrypted without any additional effort.

    Tagged as : Uncategorized
  2. IKEA $50 VINDSTYRKA vs. $290 Dylos Air Quality Monitor

    Sun 17 September 2023

    This is a brief article in which I compare the IKEA VINDSTYRKA $50 air quality monitor (PM2.5) with a $290 air quality monitor made by Dylos to see if it's any good.


    If you care about indoor air quality, you may already own a CO2 to determine if it's time to ventilate your space a bit1.

    But a CO2 monitor doesn't tell you anything about the amount and size of particulate matter in the air.

    Of particular interest are very fine particles, in the "PM2.5" category. Those particles are 2.5 micrometers or smaller in diameter can embed themselves deep inside the lungs and cause health issues.

    Both air quality monitoring devices are specifically measuring PM2.5 particulate matter, so that's what we will focus on in this test.

    DYLOS DC1100 PRO

    I bought a Dylos DC1100 Pro in 2014 as I was quite interesting in the topic of air quality at that time. As I had to import the device, I believe I had to pay around 400 Euros for it but it's now for sale in the US for around $290.

    Dylos DC1100 Pro click on the image for a picture of the back

    I specifically chose this model because it has a serial port, which allows me to log data and maybe spot some trends. I was thinking about using this data to control my air circulation system in my home, but I never got around to building this.

    This device (without serial port) is also explored in-depth by Matthias Wandel, who many of you probably know from his 1.7M subscribers Youtube channel. Tip: he shows the inside of the device.

    Note that this video is from 10 years ago and I find it remarkable that the Dylos 1100 Pro is still sold - seemingly unmodified - over the years.


    Recently, I discovered that IKEA is now selling the VINDSTYRKA air quality monitor with support for Zigbee. The product is intended to be used with IKEAs range of air purifiers, to better finetune the behaviour of those devices.


    The device measures PM2.5 particulate matter and also monitors temperature and humidity. All data is exposed over Zigbee. I've not tested this myself but I wonder how long it would last on a battery bank as it's USB powered.

    Due to the low price tag, I decided to compare this $50 device (€40) with my Dylos. I think it's quite an interesting device because the Zigbee support allows you to integrate the device in home automation and log data, if you have a need for that.

    Data logging setup

    De Dylos device is a bit of a pain, because the measurement values are in particulates per square foot, so I had to find a proper conversion formula, which I found in this paper (page 17). The formula is:

    PM2.5 Dylos DC1100 (μg/m3) = (particles > 0.5 μm minus particles > 2.5 μm)/250.

    A Raspberry Pi 3B+ is running a Python script that reads the data from the serial port, converts it to PM2.5 values using the previous mentioned formula and transmits it into an InfluxDB + Grafana server.

    To log the VINDSTYRKA data, I used a Sonoff Zigbee receiver on a Raspberry Pi 4b+. I installed zigbee2mqtt as a docker container, Mosquitto MQTT server and Telegraf+MQTT-client to submit the data into InfluxDB, which sounds more convoluted than it actually was.

    Test method

    I just let both devices run for a few days in close proximity to each other in my living room. I kept a balcony door open 24/7. I also created a bit of smoke at some point just to observe how the devices would respond and how much they would deviate from each other. Nothing too scientific, to be frank.

    Test result

    I've plotted the data from the Dylos and the Ikea device in the same graph and I think the results are quite straightforward. The peak in the middle was my 'smoke test'.

    Original grafana graph click on the image for a larger version

    Updated grafana graph click on the image for a larger version

    After a few days I noticed a clear deviation between the VINDSTYRKA and the Dylos DC1100 Pro at certain time intervals. I have no real explanation for this deviation and I can't tell which device shows 'correct' data.

    If I try to follow the AQI PM2.5 values for my city, the VINDSTYRKA seems to under report and the Dylos seems to over-report PM2.5 particulate matter.


    Based on my test, I think the VINDSTYRKA is good enough, looking at how closely the measurements track the results of the Dylos.

    Update September 19th 2023 Based on the new graph data, it seems the Dylos and VINDSTYRKA are less in agreement over absolute PM2.5 values. I'm not sure what to make of it.

    As both devices still seem to agree on basic trend data, I would say that they still operate in the same ballpark.

    1. Maybe you are a home automation enthusiast and you've managed to automate this process. 

    Tagged as : Solar
  3. My Solar-Powered Blog Is Now on Lithium Iron Phosphate

    Fri 19 May 2023

    In my last blog post I discussed how a small solar project - to power this blog on a Raspberry Pi - escalated into a full-blown off-grid solar setup, large enough to power the computer I use at the moment to write this update1. In this update, I want to discuss my battery upgrade.

    For me, the huge lead acid battery (as pictured below) was always a relatively cheap temporary solution.

    solar contraption A 12 Volt 230 Ah lead-acid battery

    Lead-acid batteries are not ideal for solar setups for multiple reasons, but the most problematic issue is the slow charging speed. I only have a few hours of direct sunlight per day due to my particular situation and the battery just could not absorb sunlight fast enough.

    For the last 5-7 years, the go-to battery chemistry for solar is LiFePO4 or lithium iron phosphate as a replacement for lead-acid batteries. This battery chemistry is not as energy-dense as Lithium-ion, but the upside is price and safety. In particular, LiFePO4 cells aren't as volatile as Lithium-ion cells. They may start outgassing, but they don't start a fire.

    More importantly for my situation: LiFePO4 batteries can charge and discharge at much higer rates than lead-acid batteries2. It's possible to charge LiFePO4 cells with a C-rate of 1! This means that if a battery is rated for 100Ah (Ampere-hours) you can charge with a current of 100 Ampere! My solar setup will never come even close to that number, but at least it's good to have some headroom.

    lithium cell A single 3.2 volt 230Ah Lithium Iron Phosphate prismatic cell

    I did contemplate buying an off-the-shelf battery but I decided against it. You have no control over the brand and quality of the LiFePO4 cells they use and more importantly, what's the fun in that anyway?

    So I decided to order my own cells and build my own 12 Volt LiFePO4 battery consisting of four cells in series (4S) as my existing system is also based on 12 Volt. Other common configurations are 8S (24 Volt) and 16S (48 Volt3).

    box with 4 cells

    It turned out that I could just buy my cells locally in The Netherlands (instead of China) because of a company that specializes in batteries (no affiliate). As the price was right, I bought effectively 3 KWh for just shy of 500 Euros.

    I decided to buy B-grade cells as those are cheaper than A(utomotive)-grade cells. I might have gone for A-grade cells as not to risk anything if I would build a more serious battery bank for my whole home. Yet a lot of people report no significant differences between A-grade and B-grade LiFePO4 cells for solar battery banks so in the end, it's all about your particular apetite for risk.

    Just buying cells and putting them in series (in my case 4S) is not enough, a BMS or battery management system is needed, which you put in series with the battery on the negative terminal. I ordered a 100A Daly BMS from China which works fine. I'm even able to use Python to talk with the Daly BMS over bluetooth to extract data (voltages, current, State of Charge and so on).

    Daly BMS

    The BMS is critical because it protects the cells against deep discharge and overcharging. In addition, the BMS tries to keep the voltage of the cells as equal as possible, which is called 'balancing'. Charging stops entirely when just one of the cells reach their maximum voltage. If other cells have a much lower voltage, it means that they can still be charged but the one cell with the high voltage is blocking them from doing so. That's why cell balancing is critical if you want to use as much of the capacity as possible.

    The Daly BMS is quite bad at cell balancing so I've ordered a separate cell balancer for $18 to improve cell balancing (yet to be installed).

    my battery build

    ikea box

    Ikea sells a Kuggis 32cmx32cmx32cm storage box that seems to be perfect for my small battery. As it has two holes on the sides, I just routed the positive and negative cables through them.

    Now that I've put this battery in place I've seen a huge improvement regarding solar charge performance.

    Grafana Chart

    I've actually potentially created a new problem: my solar charge controller can only handle about 400 Watts of solar power at 12V and my setup is quite close to reaching this output. I may have undersized my solar charge controller and it has come back to bite me. For now, I'm going to just observe: if that peak of 400 Watts is only reached for a brief time - as it is right now - I don't think I'm going to upgrade my solar charge controller as that would not be worth it.

    As we are still in May, my best yield is 1.2 KWh per day. Although that's paltry as compared to regular residential solar setups, that 1.2 KWh is more than a third of my battery capacity and can run my computer setup for 10 hours, so for me it's good enough.

    It's funny to me that all of this started out with just a 60 Watt solar panel, a 20 Euro solar charge controller (non MPPT) and a few 12V 7Ah lead acid gel batteries in parallel.

    I think it's beyond amazing that you can now build a 15KWh battery bank complete with BMS for less than €3000. For that amount of money, you can't come even close to this kind of capacity.

    For context, it's also good to know that the longevity of LiFePO4 cells is amazing. A-grade cells are rated for 6000 cycles ( 16+ years at one cycle per day ) and my vendor rated B-grade cells at 4000 cycles (~11 years).

    Maybe my battery build may inspire you to explore building your own battery. LiFePO4 cells come in a whole range of capacities, I've seen small 22Ah cells or huge 304Ah cells so you can select something that fits your need and budget.

    If you're looking for more information: there are quite a few Youtubers that specialise in building large battery banks (48 Volt, 300Ah, ~15KWh) to power their homes and garages.

    Although Will Prowse reviewed LiFePO4 cells in the past, he currently focusses mostly on off-the-shelf products, like "rack-mount" batteries and inverter/chargers.

    I also like the off-grid-garage channel a lot, the channel as tested and explored quite a few products.

    Harrold Halewijn (Dutch) also has quite a few videos about solar setups in general and solar battery setups. He's really into automation, in combination with flexible (next-day) energy prices.

    Also in Dutch, a cool article about some people building their own large-scale home storage batteries (15KWh+)

    Another Dutch person build a solar power factory with a battery capacity of 128 KWh for professional energy production. Truely amazing.

    The Hacker News thread about this article.

    1. https://news.ycombinator.com/item?id=35596959#35597492 

    2. To fully charge a lead-acid battery, the charging process spends a lot of time in the contstant-voltage phase, the voltage is kept constant so as the battery charges further, the charging current goes down, so the charge process slows down. More info can be found here 

    3. It seems to me that most batteries build for home energy storage systems are standardising on 48 volt. 

    Tagged as : Solar

Page 1 / 72