Key organizer from old shoes

I have a drawer cabinet near my front door. It’s top drawer has become my “messy drawer” and holds keys, bags for grocery shopping and face masks. And also, tens of (found) bicycle lights, a TomTom one I have not used (nor updated) since 2009, and a garbage pass for a municipality I don’t live in for almost 10 years.

I could never quickly find my keys.

Continue reading “Key organizer from old shoes”

A pouch for my passport

Since I lived in Belgium (from 2002), I have always carried my passport with me; it was mandatory there and it stuck. I never owned an ID Card. I have this in a pouch that originally belonged to my Rand McNally Streetfinder III Navman GPS unit. This was a GPS receiver that clicked onto the back of a Palm III (see ebay for example, as long as it’s available). I have long thrown away the Navman, but the pouch has been doing passport duty for 20 years, but it started to fray and tear apart. It was good, but I missed two things:

  • A little pocket for a SD card and a camera battery (I lost an empty SD card once because it had become lodged in my passport’s paged, then I dropped in when I opened the passport above a grating)
  • An outside pocket so you could have tickets ready instead of having to pull out 20 sheets of folded A4 paper and search for the right ones.
Old passport bag with contents
The Rand McNally bag, it usually carries my passport, a SwissCard, a metre of ducktape on a credit card and a few metres of toilet paper. In this case, it also carried my printed-out COVID vaccination passes and a multi USB charge cable.
Continue reading “A pouch for my passport”

Making a NAS out of my Raspberry Pi 4

I used to have a Raspberry Pi B (model 1) act as my NAS.
The PI (or probably it’s memory card) died on me, and I’ve always been appalled by it’s slow, slow data throughput, so I ordered a new Raspberry Pi 3B+. Literally two days after it ordered, the Pi 4B+ was announced. So I ordered that one too.

Finally, I have some time to put it together.

What I want is basically the same as the old:

  • Have a fixed IP on my network
  • Have SSH to be able to remotely manage it
  • Serve as a NAS, available over SMB, for a KODI media player somewhere on the same network
  • Serve as a NAS, available over NFS, to make backups of my music and photos
  • Serve as a KODI database library server.
  • Be available over Ethernet (and not WIFI, as it’s right next to the router)
  • In the future: have a physical “clean shutdown” button.

For this I chose the useful tutorial from Desertbot: Headless Raspberry Pi 4 SSH WiFi Setup (Mac + Windows). It is for Mac+Windows, but I guess I can manage with Linux as a host system as well.

Basic Raspberry Pi Headless Wired install

I like to install raspberry pi’s headless, that way you don’t need to lug out a monitor just for the initial install.
I have my Raspberry connected with only power and an ethernet cable, no keyboards, mice, monitors.

  1. Get Raspbian Buster Lite from https://www.raspberrypi.org/downloads/raspbian/ and download the latest image.
  2. Write the image to the SD card using the following commands (replace sdX with the right partition, use lsblk to check which partition is your SD card.):
    sudo dd bs=4M if=2021-03-04-raspios-buster-armhf-lite.img of=/dev/sdX conv=fsync status=progress
    … aaand wait a minute or 5
  3. To enable SSH, create an empty file “ssh” in the /boot folder
    touch ssh
  4. Per How to disable wifi in Raspberry Pi 4, I disabled wifi by adding
    dtoverlay=pi3-disable-wifi
    to /boot/config.txt – the pi3 works for the Pi 4, and the claimed also-working disable-wifi does not work.
  5. Enable a static IP address:
    in /etc/dhcpcd.conf, uncomment the lines under the static IP configuration: (found in How to set up a static IP using Raspbian Buster)
    #Example static IP configuration:
    interface eth0
    static ip_address=192.168.15.2/24
    static routers=192.168.15.1
    static domain_name_servers=192.168.15.1 8.8.8.
    8 fd51:42f8:caae:d92e::1
  6. Also, I changed /etc/hostname to the desired hostname, in this case “asteriskpi” (for historical reasons)
  7. I already downloaded log2ram, which is a solution that should greatly reduce SD card wear.
    cd /mnt/rootfs/home/pi (or wherever your SD card is mounted)
    git clone https://github.com/azlux/log2ram.git
    cd log2ram
    chmod +x install.sh
  8. Then I unmount the SD card, put it in the raspberry Pi and hooked it up to ethernet and power. After about a minute, I could log in (with some first-time SSH error messages)
    ssh pi@192.168.15.2 (with default password “raspberry”)
  9. First, do some mandatory maintenance:
    1. Change the password
      sudo passwd pi (and change the password to something to your liking)
    2. Install log2ram
      cd /home/pi/log2ram
      sudo ./install.sh
    3. Then reboot
      sudo reboot
      ssh pi@192.168.15.2
    4. and do an update:
      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get dist-upgrade
      sudo apt-get autoremove

Install an external harddrive, automount

  1. The external hard drive I got was a WD My Passport 5TB. It came with a preformatted NTFS partition. I changed this to EXT4 with fdisk:
    lsblk to see which device I just plugged in
    sudo fdisk /dev/sdX (change to the drive lsblk gave you)
    Then in fdisk:
    m (print menu)
    d (delete existing partition)
    g (create a new empty GPT partition table)
    n (add a new partition), then accept the default suggestions a few times
    w (write table to disk and exit)
    sudo mkfs.ext5 /dev/sdX1 (again, change to the partition lsblk gave you)
  2. Next step was to connect the external hard drive to the Raspberry and make it auto-mount.
    sudo mkdir /media/exthd
    touch /media/exthd/ "EXTERNAL DRIVE NOT MOUNTED"
    This is an empty file. If you see this file later, you know the problem is not in the network file system but in the drive not being mounted. If a drive gets mounted on /media/exthd, this file “disappears”.
    Then, add to /etc/fstab
    /dev/sda1 /media/exthd auto defaults,nofail,x-systemd.device-timeout=30 0 2
    The “nofail” makes the booting not fail when the external hard drive is not present, after 30 seconds. This will show up trough the file name EXTERNAL DRIVE NOT MOUNTED in the shared file.
    A quick reboot showed that indeed, the drive was automatically mounted.
    Then change the permissions on the drive
    sudo chmod 755 /media/exthd
    sudo chown pi:pi /media/exthd/

Install Network File System

Now to install NFS (serverside) – I mostly followed the Raspberry Pi NFS article.

  1. sudo apt-get install nfs-kernel-server
    sudo mkdir /exports /exports/exthd
    sudo chmod 777 /exports /exports/exthd

    To mount-bind /exports/exthd to /media/exthd:
    One-time (for testing purposes): mount --bind /home/users /export/users
    Permanently: add to /etc/fstab:
    /media/exthd    /exports/exthd  none    bind,nofail    0       0
  2. Add to /etc/exports
    /exports/exthd 192.168.15.0/24(rw,fsid=root,insecure,async,no_subtree_check)
    The fsid=root means that this directory (/exports/exthd) is the “root” of all exported NFS file systems.

    Then do a
    sudo exportfs -ra
    sudo systemctl restart nfs-kernel-server
  3. To install on your Linux computer (in my case, Kubuntu):
    apt-get install nfs-common
    To test: sudo mount -t nfs -o proto=tcp,port=2049 192.168.15.2:/ /mnt/nfshd/
    To do this permanently, add to /etc/fstab (this way, any user can mount)
    192.168.15.2:/ /mnt/nfshd nfs rw,relatime,user,noauto 0 0

Power management

The raspberry pi will be on 24/7, but I want the hard drive to spin down after a while. My usage scenario is a backup every few weeks, a movie maybe once or twice a week, and music for a few hours per day but sometimes not for days.
Luckily, a
sudo hdparm -I /dev/sda1
told me
Capabilities:
       Standby timer values: spec'd by Standard, with device specific minimum

I couldn’t find any specs what this Standard was, but then I left for lunch, found the disk still spinning after 20 minutes and not spinning after just over an hour. So I guess the drive spins down after either 30 or 60 minutes.

Conclusion

I started this article a long time ago, then got really busy at work with covid etcetera, and didn’t find the time+energy to work on this again. I finally did try this and this 3/4 written article really helped with the setup. Especially the “Basic install” section is useful if you want to do this more often and not spend much time in researching how to set everything up.

Regarding NFS: I found a lot of online guides, and a lot of them had unnecessary or even false steps (such as needing to change permissions on all files on the external hard drive – not necessary)

I skipped two elements of my goals here. I didn’t install Samba, as in my use case, I don’t need it. I have only linux/android devices and it seems they all work with NFS. The other is adding a physical power button, which I did add, but that’s a separate article.

Downloading tile maps

I love the website Cartesius, which has a trove of old topographic maps of Belgium.
One of the maps that I consult the most is a stitch of all topographic maps of Belgium of 1969, zoomable and pannable like openstreetmaps.

The Cartesius map viewer

However, lately, the site has been acting strangely. The front portal continuously reloads, so it is hard to select anything. This has been going on for months and has not been fixed — so I guess it is no longer actively maintained, with bears the risk it might go offline soon.
Therefore, I wanted to download these maps for backup, if possible.

Continue reading “Downloading tile maps”

My railway edits on Openstreetmap

A list of all things railway-related I put on openstreetmap (since october 2021)

700mm Chreosoting railway, Vilvoorde
500mm Coal railway
700-750mm track, this was used for a loco that has since moved to Katwijk

Reasons for the housing shortage in the Netherlands

Sadly, there is not one single reason for the housing crisis in the Netherlands, or we could — with effort — fix that problem. There are reasons that have been building since the 1980’s.

In a recent discussion I came up with the following reasons for the housing crisis that each for themselves would not be too bad of a problem, but combined they form this cluster bomb:

  • Financial and policies:
    • Mortgage interest deduction which makes owning a house cheaper than renting one.
    • Low interest rates, people who have wealth can easily invest in housing (“buy to let”) and get a fair return on it. The low interest also makes this one of the few high return-low risk investment possibilities.
    • Social housing estates who had many dubious investments in the ’90’s-’00’s, had to be bailed out, and the government imposing a tax on them in the ’08 crisis means they can not really invest in new social housing, but have been selling off their inventory for the last two decades (I live in an ex-social-housing apartment), a supply that has now dried out.
    • New regulations on house financing (good) which make it so that people new on the housing market can no longer easily afford a house above a certain threshold (NHG-garantie) while the average is now far above that threshold, meaning even more pressure on the renting market.
    • The “Jubelton”, where parents can give their children a tax-free gift of €100.000 for buying a house. This has not made housing more accessible, but instead drove prices up.
    • Social rent gap: The social rent is pegged at about €700, but because there is a huge segment of people who can’t rent social (just too much income or too long a waiting list), and can’t buy (not eligible for mortgage because no wealth and too few income with current insane housing prices) there is a huge pressure on the underside of the “liberal housing market”, meaning there are basically no houses for rent between €700 and say €1100 (depending on the location).
    • “Wet Doorstroming Huurmarkt”, a law that increased the options for temporary rent contracts, hoping to improve the flow of renters to a more suitable house, but only having the effect of increasing rent, making investors richer and leaving renters unable to either live a stable live or build up any personal wealth.
    • Too much money and lending capacity available to both investors and genuine buyers (who want to live in their home).
    • House buying tax (Overdrachtsbelasting) went from 6% to 8% for investors and 2% for first-time-buyers under 35 last year (2020). Which meant a rush on houses from investors wanting to have the last cheap houses last year, then a rush on houses from first-time-buyers now (2021).
  • Social:
    • Race to the top, fear of missing out on a house so people overbid enormously for fear of not getting something else
    • A decade-long underconstruction of new housing, combined with a near-total stop of housing construction in the ’08-’10 financial crisis, which meant many (good) construction labour either retired or found other jobs, so there is still an immense shortage in skilled workforce.
    • Covid-19 which increased demands on houses with more space (inside and gardens), instead of the inner-city-studios of the “millennials”. These inside studios are still coveted (by investors) so still priced high, freeing them up don’t free up affordable space to renters.
  • Environmental
    • The nitrogen crisis is fairly recent and has not really added up to the housing crisis, but it won’t help either.
    • Pressure on greenfield building by competition from nature preservation, energy production (solar), industry (distribution parks) and agriculture

Repairing my fridge

I have a fridge I bought in 2009. In the door, there is a tray that holds heavy items like yoghurt cartons. That tray was held up with two tiny tabs on each side, which fall in a slot in the side of the tray. In 2013, those tabs broke off, which rendered the tray unusable. This means I had to put those cartons in the fridge proper, blocking access to the vegetable drawer (I had to remove all the cartons to access it) and making access to the bottom shelf more cumbersome.

This is annoying.

Ik heb in 2009 een koelkast gekocht. In de deur zit een rekje waar de zware dingen zoals yoghurtpakken op staan. Dat rekje werd vastgehouden met twee kleine tabjes aan elke kant, die in een sleuf aan de zijkant van het rekje passen. In 2013 zijn deze tabjes afgebroken, waardoor ik het rekje niet meer kon gebruiken. Dit betekende dat ik de yoghurtpakken in de koelkast zelf moest plaatsen, waardoor ik niet meer bij de groentela kon (ik moet alle pakken uit de koelkast halen voor ik hem open kan maken) en ook niet meer makkelijk bij de dingen op de onderste plank.

Dit is vervelend.

Continue reading “Repairing my fridge”

Using the LCD

I found an old beaten-up CD player a while back, and decided to take out the human interface card, with the LCD and buttons on it.

In a previous episode, I managed to get the LCD to do something. Now, I will try to let it do exactly what I want it to do!

The first task is to find out what segments is controlled by what segment to the chip(s). In Controlling the card, I found out how to send the chips data — basically I have to send an 80-bit sequence to the two chips, of which 2*4 bits are chip control data. This leaves 72 bits of data to control 57 segments, so some of the chip’s capacity was unused.

My first plan of attack is simple: in the previous episode I learnt how to listen for keypresses, so my idea was to make a simple keypress-driven loop trough all the 72 data bits, to see which segment will light up.

Continue reading “Using the LCD”

Scanning keys

Now that I deciphered where everything goes and how everything works, it was time to make sure I build a foundation to make the I/O a little more usable, instead of fetching raw data. Fist stop: make the input buttons accessible.

Working with keypresses is actually not as simple as I intuitively thought. If you have one button attached to one input pin and do a simple digitalRead(pin);, then you know your button is pressed. But if you want to do an action only once on every key press? You could have a little variable that keeps track of whether the key was not pressed last time and is now — basically working on the leading edge. But then you still have the problem of key bounce to take care of.

And what if you want to detect long presses (e.g. to go into a settings menu) or held presses (press once to increase a counter, keep pressing to keep increasing it)?

But first, the basics, how to detect a simple keypress with the scan matrix used in this board?

Continue reading “Scanning keys”

Controlling the card

I found an old beaten-up CD player a while back, and decided to take out the human interface card, with the LCD and buttons on it.

In a previous post, I found out where all the connections on the PCB go and how they connect the buttons, LCD and chips together and what they do. Now, I will try to see whether I can control them.

Continue reading “Controlling the card”