Gerrit Niezen

Maker of open-source software and hardware.

In a previous post I mentioned that I would be taking part in the Stay-at-Home TH/NGS Jam today.

I decided to build a Hide & Seek game, where one person would select a room in a virtual house to hide in, and the other person would seek them out using the NFC scanner on an Android phone. I managed to get everything working in the end, resulting in two small web apps.

One webapp is for the person hiding, where they can select where they're hiding:

Hiding in the dining room

The room they select is saved to a remote database, which can be read by another web app for the seeker:

Seeking the person hiding

They press the Scan button to enable the NFC scanner, and then move their phone over a physical paper map of the house, embedded with NFC tags. When the scanner reads a tag for a room, it will display whether the person is hiding in that room or not.

The code is available on GitHub.


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day40

Following on Part 1 and Part 2, this post is about my ongoing adventures in building my own webcam.

I got the software working yesterday, but still needed to put everything in a suitable enclosure to mount on top of my monitor. I found out that I can mount my small GorillaPod tripod on top of my monitor arm with its magnetic feet, such that the camera peeks out above the monitor itself. Now I just needed a suitable enclosure.

I searched Thingiverse and PrusaPrinters and came across this design specifically made for the Raspberry Pi Zero and HQ camera. I printed the parts and everything just worked. I even had the right length M2.5 screws and nuts on hand to close everything up.

DIY Webcam made with Raspberry Pi

There are some parts that I still want to improve:

  • The Pi Zero W that I bought has a header soldered on, as the regular one was out of stock. This means that the enclosure doesn't close completely. I'd like to replace this with a regular Pi Zero without header. It also doesn't need WiFi, as I can talk to it over USB.
  • The USB connection is currently at the top. I'd like to switch it around to make it look a bit neater.

Apart from those two niggles, I'm perfectly happy with my new webcam!

DIY webcam mounted on monitor


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day39 #rpicam

In the first part I discussed why I'm not able to get a decent webcam, and deciding to make my own using a Raspberry Pi Zero and the new Raspberry Pi High Quality Camera instead.

Well, all the parts arrived from the friendly pirates at Pimoroni today, so I got to work at putting it together.

The first speed bump was discovering that the Zero W has a mini-HDMI port. I have many HDMI cables as well as a micro-HDMI adaptor for the Raspberry Pi 4, but no mini-HDMI cables or adaptors. I decided to just connect to it over WiFi instead. First up, Adafruit's Raspberry Pi Zero Headless Quick Start guide. That got me to the point where I could ssh into the Pi Zero W and update the operating system without seeing the screen or plugging in a keyboard or mouse.

The Raspberry Pi High Quality Camera Getting Started manual was also quite helpful in figuring out how to connect and adjust the lenses.

I tried a whole bunch of things, mainly on this forum thread, to try and get the Pi Zero to act as a webcam. It wasn't working, so I started wondering if the guy who showed a successful demo of it working on YouTube had a blog with instructions.

Turns out, he wrote up the instructions just four days ago! I tried it, and it works! Another turns out: He's the same guy behind the PiPhone, Drop Pi and the Lapse Pi.

One last issue was that everything was out of focus. I had a look at the Pimoroni website again and found the manual for the lens that I bought. Turns out I had to remove the CS-S adaptor, fully screw in the backfocus, and only then adjust the aperture and focus.

I compared it against my built-in webcam, and it looks so much better! Going from a 720p fixed-focus webcam to a 12MP camera running at 1080p with a manual focus is quite the difference.


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day38 #rpicam

I haven't played a computer game for more than a couple of minutes in a very long time. The last game I played seriously was World of Warcraft in the early 2000s. As a teenager I loved real-time strategy games like Starcraft and Homeworld, but as I got older they felt more like work than play.

I recently found myself looking at everyone playing Animal Crossing: New Horizons, and it reminded me of a game I bought as a Humble Bundle in 2017, but never played: Stardew Valley. After playing it for a couple of hours with a toddler on my lap over the last week or so, I realised that I do miss that sense of enjoyment that you get from playing computer/video games. I'm especially enjoying seeing my son discover virtual worlds for the first time.

I do think that play (even if it is in a virtual world) is a very important of living, and maybe I've neglecting it in favour of “productivity” for far too long.


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day37

Since I got a second monitor, I've been meaning to install a webcam so that I can look at my main screen instead of my laptop screen when on video calls. According to The Wirecutter, the Logitech C920S is the best webcam out there at the moment.

Due to the Covid-19 pandemic, the webcam is out of stock at all the usual resellers, but you can find it on eBay for £180, instead of the usual £85. Apparently drop shippers have switched from hoarding toilet paper and hand sanitiser to work-from-home tech?

Then I remembered that I actually just want a good-quality video feed, and that it doesn't necessarily have to be a webcam. A lot of people have been using point-and-shoot cameras combined with an HDMI capture card. That made me wonder if the new Raspberry Pi high-quality camera module could be used a as webcam?

Yes, it can. So I've ordered a Raspberry Pi Zero W, a HQ Camera module, 6mm wide-angle lens, camera cable and micro SD card. I'm looking forward to putting this together, with the hope that it will be a better quality video feed than what would've been possible with the Logitech webcam. DIY FTW!


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day36 #rpicam

At the beginning of the month, I mentioned that I started doing the Highlight course, an online course based on the book Make Time by Jake Knapp and John Zeratsky. I just completed the course, and part of the final module was to reflect back on the month, with some questions I answered below. If you'd like to know more about some of the specific tactics I mentioned below, get in touch @gendor@merveilles.town on Mastodon.

What did you want to make time for?

I wanted to make time for my side projects, which includes building electronics, hydroponics and growing my own food, permaculture, and getting more involved with climate action in my local community.

Were you able to make time for it?

I was able to spend an evening each week on an online permaculture course. I started growing sprouts using a mason jar strainer lid that I printed on my 3D printer. I started a garden diary, installed a rainwater harvesting system and made my own cleaning products.

I also made much faster progress than usual on a bunch of projects at work.

What is your “tactic stack”? (Your 5-7 essential tactics.)

  • Write it down
  • Schedule your highlight
  • Put your toys away
  • Might Do list
  • Make your bedroom a bed room

What’s an unexpected challenge you faced in making time?

There are some of my side projects, like hydroponics, and getting more involved with climate action, that ranked pretty high on my ideal priority during stack rank, but that I still haven't been able to make time for. Maybe I need to try and Explode my Highlight, and then combine the Might Do list with the Burner list?

What’s an unexpected success?

I drink a lot of coffee. A lot. Experimenting with caffeine use seemed like a non-starter due to my dependence, but after trying Maintaining Altitude with Green Tea, I'm more confident that I can try some of the other caffeine-related tactics.

I've tried various attempts at a distraction-free phone in the past, but finally deleting Instagram and other social media from my phone made it so much easier to also Make my Bedroom a Bed Room.

How is your life different now than it was at the beginning of the course?

I feel like I'm less anxious and more present. I'm excited to keep this going and make time for more things, although I'm a bit concerned that I will fall off the wagon again, so to speak. I'm hoping that the Make Time community will keep me on track.

How will you use the Make Time framework in the future?

I'm looking forward to trying other tactics, like the Burner List and Friendly Social Jujitsu. I've found that the Make Time app (on Android) has been really helpful in keeping me going, by providing both opportunities for writing down and scheduling my highlight, as well as reminding me to reflect at the end of the day.


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day35

This is a follow-on to Part 1 and Part 2 of my adventures in connecting to Android devices over MTP using Node.js, on Windows.

While compiling the Node.js native module, I got the following error:

Macro definition of snprintf conflicts with Standard Library function declaration

Searching StackOverflow led to this solution, which I added to the libmtp source code:

#if _MSC_VER < 1900
#define snprintf _snprintf
#endif

I also kept on getting a “Module not found” error, until I re-read my own post and used Dependency Walker to figure out that for some reason my .node file is looking for libmtp-9.dll.dll instead of libmtp-9.dll. 🤷‍♂️️ I also had to copy libusb-1.0.dll into the same folder, as it was looking for that too.

Finally, like magic, I was able to connect to a device on Windows over MTP with my own Node.js library using libmtp, instead of the Windows MTP implementation that can only be accessed through Windows Explorer or the Windows APIs.

And I just submitted a PR to get Windows builds fixed in the upstream libmtp library.

Next step: Getting it compiled for 32-bit Windows using i686-w64-mingw32 and/or i686-mingw32


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day34 #libmtp #Node.js

So even though I managed to get libmtp compiled under Windows, I can't get it to work with Node.js. I've decided to take the same approach as what I did with ffmpeg's libavutil library, and cross-compile it under Linux instead.

To do this, I needed mingw64 on my Linux machine:

sudo apt-get install mingw-w64
sudo apt-get install mingw-w64-tools

It doesn't look like libusb has been pre-compiled for mingw64 on Linux, so I had to do the following:

git clone https://github.com/libusb/libusb.git
 git checkout v1.0.23
./autogen.sh
./configure --host=x86_64-w64-mingw32
make
DESTDIR=$HOME/Code/mingw64/ make install

This installs the libusb library (compiled for Windows) under $HOME/Code/mingw64/. Then I had to configure libmtp to use our Windows libusb build:

PKG_CONFIG_PATH=$HOME/Code/mingw64/usr/local/lib/pkgconfig  ./configure --host=x86_64-w64-mingw32
make

Again I had to fix unicode.c to get it working. I should submit this work as a PR to libmtp.

Next step: Try to get this working in as a native Node.js addon.

For reference: http://www.tinc-vpn.org/examples/cross-compiling-64-bit-windows-binary/


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day33 #libmtp

In preparation for the Stay-at-home TH/NG Jam next Friday, I thought I'd at least check if I can get the basic tech, including Web NFC, working.

Web NFC is an open specification, but so far it is only supported on Chrome for Android behind a feature flag, meaning you'll have to enable experimental web platform features in chrome://flags. It has also been available as an origin trial since Chrome v81.

First, we need a basic index.html file:

<html>
  <head>
    <title>Smart Paper Maps</title>
    <script src="main.js"></script>
    <link rel="stylesheet" type="text/css" href="main.css">
  </head>
  <body>
    <button id="scan" class="buttons">Scan</button>
    <p id="p1" class="text"></p>
  </body>
</html>

All we're doing is linking to our main.js and main.css files, and setting up a button and a <p> section that we can use to display text. Our main.css just makes the button and text a bit bigger to make it easier to tap and read:

.buttons{
    height:200px;
    width:200px;
    font-size: xx-large;
}

.text{
  font-size: xx-large;
}

And finally, the actual code that reads the NFC tags:

document.addEventListener('DOMContentLoaded', event => {
  const scanButton = document.getElementById('scan');
  const reader = new NDEFReader();
  
  scanButton.addEventListener('click', async () => {
    try {
      console.log('Scanning..');
      await reader.scan();
    } catch(e) {
      console.error("Error: ", e);
    }
  });
  
  reader.onreading = event => {
    console.log('Event:', event);
    document.getElementById("p1").innerHTML = event.serialNumber;
  };
});

We wait for the page to finish loading, initialise the NFC tag reader module NDEFReader(), and wait for the “Scan” button to be clicked. When we click the button, the browser will prompt for permission the first time. Once permission is granted, it will start scanning for NFC tags, and display the serial number when a tag gets read.

Because Web NFC requires an HTTPS Server, you'll have to set up a basic one to get this working. I'm using Node.js 12, and saved the following as simple-http-server.js:

const https = require('https');
const fs = require('fs');
const express = require('express');

const options = {
  key: fs.readFileSync('newkey.key'),
  cert: fs.readFileSync('newkey.crt')
};
const app = express();
app.use(express.static(__dirname));

https.createServer(options, app).listen(8080);

Do an npm install to install the Express server module, and set up the SSL keys using:

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout newkey.key -out newkey.crt

Then run it with node simple-http-server.js. If you don't see any errors, you did it right. Go to <your computer's IP address>:8080 to access the page. You'll see some security warnings that you'll have to acknowledge, since we created our own self-signed keys.

I want to be able to view and debug my phone on my computer. Luckily, Chrom(ium) and Android makes this really easy. First, enable developer options on your Android phone and plug in your device via USB. To enable remote debugging, go to chrome://inspect/#devices in Chrom(ium) on your computer. You should be able to see your phone under Remote Target, and can then click on Inspect under the right browser tab to view your phone screen and the Chrome developer tools.

Hopefully, if everything is working, you'll see the following when you press the scan button and move over an NFC tag:


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day32

A week ago I saw this post on Instagram:

I attended and presented a workshop at Thingscon in Berlin in 2014, and it was one of the best conference experiences I've had. I haven't had a chance to attend it since, but have been keeping an eye on their Instagram feed for interesting events.

I really like the idea of this Stay-at-Home TH/NGS Jam:

Physical connection in time of virtual gathering

With most of my family and friends living overseas, I've been wanting to introduce more physicality into virtual connections for a long time. This seems like a great opportunity to both work on some ideas to make it happen, and to learn from others doing the same thing.

One idea would be to draw a map of a someone's home, and stick NFC tags on each room. You can then build a form of virtual “hide-and-seek”, where the remote person can state that they're in a specific room by linking to one of the tags, and you use a mobile phone to scan these tags and find out which “room” they're in. While too basic for adults, I think this could be fun for a toddler and their grandparents.

The same concept can be used for a company that works from home, where the video conferencing software may indicate which people are in each video chat, by linking these video chats to specific tags. To find out who is busy, or maybe hanging around the virtual water cooler, you scan a paper map of the virtual office.

One option would be to use Web NFC, a new technology available in Chrome on Android (in an origin trial since v81) that allows for the reading and writing of NDEF data from NFC tags. That simplifies the programming of this project to building a website.

I've already ordered some NFC tags from eBay to play with, and may even integrate my Espruino Pixl.js, a Bluetooth-enabled smart LCD that is NFC-capable.


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day31

Enter your email to subscribe to updates.