Ricky Moorhouse

Raspberrypi

Status Light

Whilst working from home it's useful for the family to know when I am on a video call or just a voice call. I was first looking at Busy bar which I came across via Hiro Report, but couldn't justify the cost of it and as I had a raspberry pi zero and a Blink! sitting around, I decided to build something simple myself. Maybe one day I could make it more complex and build a version using the Pico 2 W Unicorn Galactic?

Robot with Pi Zero

Hardware

Software Part 1 - LED Control Server

This is the application that runs on the Raspberry Pi and controls the lights based on a simple API call. I deploy this to my Raspberry Pi through Balena for ease of management and updates - then I can just push a new copy of the code into git and balena will automatically deploy it to my Raspberry Pi.

The API Call is very simple and currently accepts a GET request with parameters for the red, green and blue values (between 0 and 255) - really this should probably be a PUT request but using GET made testing with a browser simpler. The light is switched off with a DELETE call (or another GET with 0 for each parameter).

You can see the code for this in the light directory.

Software Part 2 - Webcam detection tool

This part runs on my laptop and detects when the webcam is in use through monitoring the system log - if a change in state is detected, it then sends an API call to the Raspberry Pi to switch the light on or off as appropriate.

The tricky part here was the detection of the webcam - I found a few different samples and a useful reddit thread (which I can't find now - will add the link later!) on ways to detect the webcam being operational on MacOS and it seems it is liable to change between MacOS versions - looking for eventMessages containing AVCaptureSessionDidStartRunningNotification, AVCaptureSessionDidStopRunningNotification or stopRunning seems to work for the things I've tested on Sequoia.

The alternative route I was considering was to use OverSight to trigger a CLI app and leave the detection to them - but having the CLI detect it was more interesting to build.

You can see the code for this part in the cli directory.

The code for this project lives at github.com/rickymoorhouse/status-light.

Raspberry Pi Weather Station

For a while I've been meaning to write up the details of the Raspberry Pi weather station that I have built with my eldest daughter. This project builds on a number of examples I've seen across the internet, particularly sensing the weather. This details how our system is put together.

Temperature monitoring

We took two temperature sensors and mounted them in a garden post with one pushed down to the bottom for soil temperature and one in the cap for the air temperature. The one-wire sensors can share the same three wires, so are both connected to a wire leading back to the Raspberry Pi through a hole drilled into the side of the post. For waterproofing we surrounded the whole with hot glue. The post is situated in a shady spot and pushed about 30 centimeters deep in the soil.

Wind speed

You can see my graphs of the data, and the code is on github.

Pi Zero as a desklight

When we set up our office earlier in the year I decided on a standing desk which I put together using the Ikea Algot system.
In order to avoid using up desk space with a light I originally planned on a clip on light but then saw my Pi Zero and Unicorn pHat and thought they could make a good alternative.

Hardware

The Raspberry Pi Zero is in a simple case, mounted onto the underside of the shelf above my working space. Attached is it's power cable, a PiHut wireless adapter connected via USB and of course the Unicorn pHat. The power cable is routed down the side of the shelf to my PowerCube, which will eventually be mounted under my work surface but it's sticky pad wasn't strong enough to hold it on the underside of the desk!

Software

As I've not yet added any switch for my light, it all has to be controllable remotely, so I set up an API to set the colour of the light which I initially controlled via a web browser with urls like:

http://192.168.0.15:8009/colour/<red>/<green>/<blue>

As you can imagine that got a bit tedious - especially to turn off after I'd shut down my laptop! The next step was to add a simpler way to control the light through my phone so I set up iControl Web with buttons to adjust the light settings. Then when I saw the Home app on iOS 10, I researched ways to get my custom light controllable through that and came across Homebridge which I could point to my API via it's Better HTTP RGB plugin, a bit of config and a couple of changes to my API.

All the code for my API is on github and is very much a work in progress!

Traffic Pi

Using my Raspberry Pi, Piglow and the traffic API feeds I have created a script to give me a visual representation of the journey time to work. This gives me an idea of the traffic before I leave the house in the morning, or so that when I'm working at home I can look at it and see how glad I am that I'm not sitting in traffic on the way to work :)

https://github.com/rickymoorhouse/trafficpi