DEV Community

Sam Jarman 👨🏼‍💻
Sam Jarman 👨🏼‍💻

Posted on • Originally published at on

Resurrecting a Raspberry Pi for HomeKit Webcam

Hi There,

Recently I attended the quite excellent Wellington Home Automation Hackers meetup here in Wellington, New Zealand. Inspired by the talks, I decided I'd dig back out my raspberry Pi and get into something!

So, ignoring my other side projects, I got into it. I plugged in my Pi for the first time since 2014, fearing the worst. To my plesant surprise, it booted just fine and even connected to the wifi with relative ease. I ran apt-get update and apt-get upgrade (one fetches the latest versions of things, the other actually installs them). I tweeted about it, and then took off for a chore.

I came back to twitter with a reply saying I should probably just reflash it. After a day or so of thinking about it, I thought yeah, might as well.

So, off to the raspberry pi website I went to fetch the latest raspbian. I thought, oh, I need the GUI (mainly just wanted to see the progress in 4 years - spoilers - excellent). However, once downloaded and attempted to be flashed with Etcher as per these instructions. However, since my SD card was only 4GB, I had to opt for the Lite version of the OS, so I went with that.

From there, I could upgrade from Raspbian Lite (fresh install) to Raspbian with PIXEL GUI with a 4GB card by running these commands in order:

sudo apt-get updatesudo apt-get install --no-install-recommends xserver-xorgsudo apt-get install --no-install-recommends xinitsudo apt-get install raspberrypi-ui-mods #PIXEL GUIsudo apt-get install lightdm
Enter fullscreen mode Exit fullscreen mode

That took some time, and once a reboot was done, we had a GUI. From there, it was time to get Homebridge set up.

There was a couple of gotchas here, to say the least, so I followed this guide. I ended up running these commands for my PI. 10.9.0 was the latest at the time.

wget xJvf node-v10.9.0-linux-armv6l.tar.xzsudo mkdir -p /opt/nodesudo mv node-v10.9.0-linux-armv6l/\* /opt/node/sudo update-alternatives --install "/usr/bin/node" "node" "/opt/node/bin/node" 1sudo update-alternatives --install "/usr/bin/npm" "npm" "/opt/node/bin/npm" 1
Enter fullscreen mode Exit fullscreen mode

I then installed Avahi and other dependencies, which is required by the mdns package in HAP-NodeJS library. (Apparently, I dunno, just reading that guide...*)

sudo apt-get install libavahi-compat-libdnssd-dev
Enter fullscreen mode Exit fullscreen mode

From there, I could install HomeBridge. I ran

sudo npm install -g --unsafe-perm homebridge
Enter fullscreen mode Exit fullscreen mode

From here, I found text editing on the PI tricky (hands up if you don't know Vi...). So I created the config.json file for it on my Mac, turned on SSH (changed the default password first), and copied it over with SCP, the easiest of linux commands. (Sarcasm).

I then followed these instructions to add the webcam via ffmpeg.

It took a reboot again and a few attempts to pair with on my phone, but eventually, it just worked. I could see a 720p feed of myself. That was worth the 2 days. The mirror in here is lame anyway.

Next steps for this tinkering is to add Homebridge to system services so it starts automatically after a boot, and I'm looking into homebridge compatible wall sockets too, as I have a Lava lamp here that I think would be better controlled from my phone.

Until next time...


*Yeah, I'm just blindly following install instructions from the internet with minimal. I'm being quite cavalier and I do not recommend this approach for your daily driver computer. But this is a Pi, I can flash and start again if I break something.

Top comments (0)