When Becca was born and we found out she was deaf I knew that the world was not going to adapt to her needs so I started thinking about ways that I could make the word a bit easier for her to navigate. When we found out that she would also lose her vision the importance of adapting the world to meet her needs increased exponentially. With her latest diagnosis of night blindness it became obvious that navigating in the dark would be difficult for her. It would be particularly important for her to see clearly on the stairs so I started working on a project using a Raspberry pi and Phillips hue lights to illuminate our stairwell when motion is detected. When it comes to adaptable products the internet of things (IOT) is woefully underutilized and there is a ton of untapped potential here for making the lives of people with disabilities easier. This is what I hope is the first of many projects that make use of the internet of things to help make the world a bit easier for Becca to navigate. She is far too young to benefit from this today but I figure there are others that struggle with low vision in the dark that may be able to apply this idea in their own homes. The following blog post outlines my approach to solving this problem.

First this video shows the nearly complete project

This is still very much a prototype and we are currently in the process of renovating our stairwell and when done the light strip will be embedded into the trim, in the video the light strip is temporarily mounted.

The solution uses a raspberry pi a PIR motion sensor and Phillips Hue smart lights. Phillips hue uses a wireless protocol (zigbee) to communicate to a central hub. Many Raspberry Pi and Hue projects use the popular IFTT (If This Than That) web service which allows you to perform actions based on the state of your internet connected things. i.e. lets say you wanted an E-mail notification when your internet connected thermostat turned on. IFTT allows you to create recipes to do that but the problem I ran into is that it is slow and by the time the lights turned on you were already all the way up the stairs. This project uses Hue’s API to connect directly to the Hue hub and therefore is a bit less convoluted. This results in the trigger being nearly instantaneous.

Components that are needed to build this.

Hardware

Raspberry Pi – A Raspberry pi is a single board computer that you can purchase for $35. Here is a link the explains the raspberry pi in more detail. Raspberry pi 3

– A Raspberry pi is a single board computer that you can purchase for $35. Here is a link the explains the raspberry pi in more detail. Raspberry pi 3

Phillips Hue Hub – This comes with the Hue starter kit. This hub connects to you home router and from there you can control your hue bulbs from an app.

– This comes with the Hue starter kit. This hub connects to you home router and from there you can control your hue bulbs from an app.

Phillips Hue light strip – The lights come in various forms and anyone of them can be used for this but for this project I chose the light strip as it made the most sense to use in the stairwell. The color as well as the intensity can be adjusted but I stuck with white as it would produce the most light.

– The lights come in various forms and anyone of them can be used for this but for this project I chose the light strip as it made the most sense to use in the stairwell. The color as well as the intensity can be adjusted but I stuck with white as it would produce the most light.

Passive Infrared sensor (PIR) Sensor – In this project I used a sensor that was sitting in a bin in my basement it ended up being perfect for this project. This particular one is from Panasonic part number EKMB…. This one has a 5 meter range. There are a few versions with different characteristics.

– In this project I used a sensor that was sitting in a bin in my basement it ended up being perfect for this project. This particular one is from Panasonic part number EKMB…. This one has a 5 meter range. There are a few versions with different characteristics. Resistors (2X) – I used a 100 ohm for the LED drive resistor and a 100 Kohm for the PIR output pull-down.

– I used a 100 ohm for the LED drive resistor and a 100 Kohm for the PIR output pull-down. LED – Any old LED will work for this project and it importance in the end is up to you.

Software

Hue Rest Application Protocol Interface – This allows you to control the lights from the Pi. Basically it is a list of commands that that Phillips gives their customers access to so that users can connect to Hue without using their phone app. To make good use of this we will need to install the python libraries that support the current API. You can learn more about the API here.

Python programming language – There are many options here but I chose to use Python in the examples. I used python 3 which comes pre-loaded in the Pi

That’s pretty much it for the hardware now onto the steps to make this happen.

The project is broken into three steps as I find it easier to follow that way. What I do not explain here is configuring the pi for the first time as there are many online tutorials available that outline this.

Steps:

Blink an LED

Control an LED based on motion detection

Control Hue lights

Step 1) Blink an LED

First we need to setup the hardware.

This is the diagram for the IO on the PI

The following diagram shows the wiring diagram for the LED.

I did not wire this one up instead I used a scope connected directly to the GPIO to ensure it was working. You can see the LED turning on for three seconds here.

Now the code

Insert the code shown below into a new python window check your wiring and run it. Once you select run, the LED should turn on for three seconds and then off for three and run until you stop it. The red text are comments and should give you an idea of how the code works.

Step 2) Turn LED on when motion is detected

Now we will turn on the LED based on motion being detected by the PIR sensor. The PIR sensor will output a pulse which in turn is detected by the Pi and the LED turns on for a fixed amount of time. If there is no other motion during that fixed timeout then the lights will turn off but if there is the timer will reset and the LED will remain on.

Again we need to setup the hardware. I got lazy on the diagrams but the wiring is simple.

Here is the actual implementation.

Now the code

Insert the code shown below into a new python window check your wiring and run it. Once you select run, you should see the LED react to motion. If you stay perfectly still for 5 seconds the LED will shut off.

And a quick video of it working.

I changed the timeout a bit for the demo simply because I had too much coffee and could not sit still enough to stop accidentally triggering the thing. Its pretty sensitive but that is mostly due to the proximity the sensitivity when installed on the stairs is not as high.

Step 3) Adding Hue to the project

This part was a bit more tricky as we will need to install the Python Hue libraries and get familiar with their API. I was able to get most of the information I needed to get this done here.

The Hardware

The hardware for this step is the same as the previous step but now integrated into a housing. The PCB was cut to fit inside the pi case and couple of holes were drilled for the LED and the PIR sensor. We will still need the peripherals for this step but when complete the only thing you need is the power jack.

Now the code

Before we get to the code you will need to download the python libraries to your pi. You can find the library here. You will want to download phue.py and extract it to the same directory that your python script is in. Once you do that you are ready to put the following code into your python script.

One more thing. Before this can be run the IP address of your Hue bridge will need to be entered in the yellow shaded area below. You can find your IP address at the Hue portal. You also will need to press the button on the Hue bridge. This only needs to be done one time.

Here it is running prior to putting it on the stairs. Adjusting the transition times will cause the lights to gradually come on and then turn off. Keep in mind unlike the LED timer the transition time is not specified in seconds it is specified in deci seconds.

Next steps

First renovate the stairwell, its an old house and that is the remaining space that has not yet been touched.

Embed the hue lights into the trim to hide them. Using a router table will enable me to make a recess in the back side of the trim to accommodate the lights. A few holes drilled through the trim where the LEDs line up will allow the light to shone on the stairs

Get the Python script to run automatically on bootup. I am struggling with this one I was not able to get this to run even after trying a few methods perhaps someone will see this who can tell me what I am doing wrong.

Instead of integrating the PIR sensor directly to the Pi I am going to use a wifi module so that I can free up my Pi for other things. The pi will eventually become a central hub for all of the adaptive projects that I am planning to develop. I could just use more Pis but it is unnecessary to do so.