Adapting the World to Her -Jake

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
  • raspberry_pi_3_large

 

  • 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.
  • hue-bridge
  • 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.
  • light-strip
  • 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.
  • Resistors (2X) – 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

pi3_gpio

The following diagram shows the wiring diagram for the LED.

led

It does not show well but the long lead of the LED goes to the resistor.

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.

3 second.png

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.

blink-led

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.papir

Here is the actual implementation.20161112_132627

 

 

 

 

 

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.

pir-input

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.

20161113_112314

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.

2016-11-13-162546_1680x1050_scrot

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.

19 comments

  1. Jody Ramsay · · Reply

    Will there be an emergency set up in case of a power outage? Is that doable?

    Like

    1. Yes, A battery backup could be added and as soon as power is lost the lights would turn on. They would still only come on when there was motion to conserve battery life.

      Like

  2. thank you so much for sharing in such detail. Our oldest is deaf and going blind, this is very helpful

    Like

    1. Your welcome. If there are challenges that you face with your son I would love to hear them. We are very new to this and are still learning some of the things that may be difficult for her as she gets older.

      Liked by 1 person

      1. I certainly will, all the best to you and yours

        Like

  3. Melissa Boyd · · Reply

    Amazing!!!

    Like

  4. jacob lunde · · Reply

    Look into cron and make it load the script like 1 min after bootup and then check to make sure the script is running, you can even make it time based if you only want the stair light while its night time, or add a light sensor to the mix and get a value and only have it trigger if the light is below said value. Feel free to email me on any questions I know my way around a PI and linux. jacob (dot) lunde (at) gmail (dot) com

    Like

    1. Thanks appreciate the help. I tried cron but was unable to get it to run. I just looked back into it however and think I found my mistake. Ill give it another try. Thanks again!!

      Like

      1. jacob lunde · ·

        Absolutely, I have a similar project I think I will be doing for this winter, wife willing. But if you cross any other hurdles let me know more than glad to help.

        Like

  5. Hey, if you send me a message, I can walk you through using systemd to start the python code as a service, and even help detect if there are failures so the service will restart if there is a crash or a network issue.

    Feel free to reach out on twitter, or email me at james (dot) munns [at] gmail (dot) com

    Like

    1. Thanks will do! Going to be tied up for a few days but will connect with you soon.

      Like

  6. This is fun project, but I fear it’s a little over-engineered for what you need.

    A simple PIR module (search eBay, they’re about $1 each) can do the motion sensing. The 3.3V output from this can be used to switch a power MOSFET to turn lights on and off. Just a bit of soldering, and you have a perfectly functional motion sensing light. I’ve used this in many situations (closets, hallways, etc.) and they work very well. You can adjust sensitivity, duration, and whether the device retriggers. The quiescent current of the PIR is very low, so this is an ideal solution for battery power, as well.

    This avoids any issues with a RPi or microcontroller failing, and it will dramatically lower your power usage. You can see that those lights are dimly lit even when ‘off’, and thus are drawing significant current. LED striking voltage is quite close to full brightness, so they’re effectively on all the time.

    If you wanted to add many more motion-sensing lights, this approach would be significantly more economical.

    Like

  7. I wonder if one could do a similar project using neopixel strips and Flora. It may be simpler and even less expensive.

    Like

  8. Marshall Flax · · Reply

    Lights are great, but as soon as she’s standing, please get a white cane in her hands. Excellent introduction at https://www.youtube.com/watch?v=CHEd3ZMhK8I , https://nfb.org/Images/nfb/Publications/fr/fr27/2/fr270217.htm , https://www.amazon.com/dp/B01FNA1VYK/ .

    Also, please get Braille into her hands … http://www.seedlings.org/browse.php?cat=11 is a good site. You should start with uncontracted Braille, until she’s mastered that.

    Good luck!

    Marshall

    Like

  9. […] better for the child, even if we can’t offer a cure. In that case even a simple hack, like a rapid response stairwell light to help deal with night-blindness, can make a real […]

    Liked by 1 person

  10. […] things better for the child, even if we can’t offer a cure. In that case even a simple hack, like a rapid response stairwell light to help deal with night-blindness, can make a real […]

    Liked by 1 person

  11. […] and Phillips Hue smart lights.  This is an extension of that work, for getting started with the Pi this link is a good resource and vectors off to other useful information about the […]

    Like

  12. colette gorra · · Reply

    Stairs are terrifying, He cant much go down them unassisted anyway. I try to block them, I wouldnt want him trying to go down especially in dim light! But I like the idea!

    Like

  13. […] Adapting the World to Her -Jake […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: