Introduction: Internet Enabled Interactive Stair Lights

Picture of Internet Enabled Interactive Stair Lights
Ok, So this has been done before, i know.  There are even a few instructables already on how to make stair lights.  Mine are a bit different.  You see, I'm starting off on a 'Home Automation spree' and this is one of the elements in my house.  This enables web/network based control over the stairs.  All you need to do is 'publish' the settings and the Arduino will act accordingly.  I do this through a PHP/JavaScript web page that utilises TCP socket communication.  That's a little outside of the scope of this instructable though.

The basic technology being used here is an Ethernet enabled Arduino and the MQTT protocol.  MQTT for those that do not know about it stands for Message Queuing Telemetry Transport.  The name is somewhat ambiguous but it's basically a simple way to enable devices to publish small amounts of data to a 'server' (Called a Broker) in 'Topics' (Which look a lot like a folder path on your PC).  You can then have Clients that Subscribe to a topic on the Broker and/or Publish information to the broker.  It's a little like newsgroups but very dumbed down.  i.e you connect to a server, you can then Subscribe to a topic and get all the topics posted there, and you can publish/Post your own.  This is a VERY broad and simplistic description of what it does but for the moment, that will do. I do however encourage you to check out http://www.mqtt.org for some more info.

Grab an MQTT 'Broker' in your favorite OS platform - Mine is my router which runs linux so I am running Mosquitto but there are brokers for windows and Macs too - It really needs to be something that's on all the time so you could even use a Raspberry Pi or similar low power device.

The project could be modified to remove the MQTT stuff from it and it could be controlled with serial comms or buttons but I'll leave that to you if that's what you want.

The Arduino is connected to an external board that houses 2 8 bit shift registers and 2 ULN2803 chips.  These are what handle the actual switching of the lights.  It worked out conveniently for me as i have 16 steps :)

You will need:
An Ethernet enabled Arduino (Preferably the Wiznet type, I have not tested this with others)
16 X Led strip lights or other lights you might want to use. I got mine from AliExpress for ~$2.50 each.
2 X 74HC595 Shift registers
2 X ULN2803 Darlington transistor Arrays
2 X 100nf Ceramic Capacitors
1 X 100uf 16v Polarised cap

Light duty multi strand 'bell' wire - For my steps I used about 50m
Slightly heavier duty single core wire (for the power feed to the LED strips)
2 X Mini PIR Movement sensors - Ebay, AliExpress etc.
Light Sensor (optional) - I used the Light sensor from Freetronics 
Some way of producing the PCB - Photo resist, Toner transfer, CNC or PCB fab service (although I may consider selling them if needed)
Header pins and associated connectors
3 way screw terminal
Some sort of terminals for the LED strips to connect to.  I used spring loaded quick connects but feel free to use whatever you want

You will need some basic tools depending on how well you intend on concealing the wires in/on the stairs and of course a Soldering Iron, Solder, heatshrink, general electronics skills etc.

My development environment is currently Arduino IDE 1.0.2.  You'll also need the ShiftPWM library from Elco Jacobs and the Arduino pub/sub MQTT client library.



Total approximate base cost is about $100 but it really depends on where you shop.

Step 1: Building the External Board

Picture of Building the External Board
My board design was based on the ability to have a Positive and negative terminal for every LED strip.  In the end I combined the positive feed and just ran individual grounds for each strip. This has worked fine.  This was also influenced by the connectors that I got - Originally i had planned to get vertical ones, not right angle, hence the second set of pin holes.  I am happy to modify the design of the board to reflect this but it only makes it a little bigger.  If you do, ensure the 12v line is still connected to the ULN chips.  This is needed for potential flyback protection, although possibly not needed with the leds as they are a resistive load.  However, my motto is 'better safe than sorry'

The board is designed based on the schematic below from the ShiftPWM page linked to in the Intro

The Capacitor up next to screw terminal block is a 100uf 16v polarised cap.  The other 2 are the 100nf.

Attached in this step is the PCB design files with Gerber and Drills export as well as the original Layout file if you need it (In Sprint Layout 5 format - Free viewer available)

A demo in normal light:


Step 2: Getting It Together and the Sensors

Picture of Getting It Together and the Sensors

Once you have your PCB made up and components installed we need to get it connected to the arduino.  Pins 5,6 and 7 On the arduino go to the 3 labelled pins on the PCB.  You'll need to connect the VIN to the +12, +5 to +5 and Gnd to Gnd.

I toyed with the idea of a traditional break beam sensor for the trigger at the top and bottom but this posed a couple of issues:
A standard IR phototransistor was a little hard to work with - Alignment, natural light etc
A typical IR remote receiver needs ~38Khz PWM IR to sense which is awkward and needs more hardware (555 timers etc)
Both need a reasonable amount of power - The Arduino 5v Power supply struggles @ 12v input already so i would need a better/seperate 5v supply.
At the top of my stairs, there is no directly opposing spot to mount the sensors on both sides.

So, what i done was to utilize the PIR movement sensors (I happened to already have).  I removed the lenses from the sensors and installed a small opaque 'tube' (aka a bit of a pen i found lying around) over the metal sensor to severely reduce the beam width and this works perfectly (Thanks to my good mate Tim for this suggestion!)

The signal pin from the movement sensors will need to be connected to Arduino pins 8 and 9 for down and up triggers respectively,  They also need +5v and Gnd.  While you're there, adjust the two trimpots on them fully counter clockwise.  This reduces the detection length (power) and trigger duration to minimum values.

At this point, if you decided to use one, install the light sensor as well.  This stops the stair lights from working when there is enough ambient light to see where you are going anyway.  I used the 3 pin version from freetronics - It has 3 connections, +5, Gnd and Signal to Analog pin 0.  Put it in a spot that will receive light from both outside and interior lighting.

Each light/LED strip needs to have permanent 12v power and the ULN2803 will ground the other side.  How you do this is really specific to how your stairs are constructed and what physical access you have to the stairs so i'll leave that bit up to you.

Step 3: Upload the Code...

Picture of Upload the Code...

Make sure you have a recent version of the Arduino IDE - I'm currently using V 1.0.2
Install the ShiftPWM and MQTT libraries
Plug in your Arduino and upload the attached sketch,

I don't claim to be the best at writing code - It's not my bread and butter but I have been doing it for some time.  There is probably a lot of memory being wasted in various variable definitions but it works fine and leaves plenty of code space for your own mods.  Feel free to mod as you see fit.

The code I'm posting here is still a subset of the code I am actually using but is functionally the same. I have other devices attached to the arduino that publishes information via MQTT.  You could for example use this as a 'Stair alarm' that perhaps sends a notification that someone is coming up the stairs at night time without first going down - i.e an intruder.  Perhaps you have a young child you wish to make sure does not go up the stairs. The possibilities are endless.... 

You will need to modify it slightly to use your own MQTT server (IP or DNS name) and Subscription path. I have left some values in there.  That is the only changes you should need - It is enabled for DHCP.

Step 4: Play!

Picture of Play!

Ok, so you have your stairlights all installed and ready to go. Double check all your connectios for shorts and make sure everything is plugged in where it should be - Plug it in and fire it up.

You will likely see a flash of all of the lights incrementally - this is just the Shift registers settling.

If you have it connected to a PC you can open the serial port and get a little bit of status information from it. Once it's 'Connected to Broker' you're good to go.

Try triggering one of the sensors and it should report that it has been triggered and the direction.  The Lights should come on in ascending or decending order (depending on the sensor triggered).  Well done - Pat yourself on the back.  Now the fun bit!

Find yourself an MQTT client - There's ones available for linux under most of the releases - I like Mosquitto. There is also an App in the Google play store for Android phones.  Have a look around....

Next, 'publish' anything to 'stairs/x' and you will get a demo of some of the functions.  Not all are enabled in the main code however as they're not too practical.

Other commands are as follows:
Topics with Values as the message
stairs/m for mode - 0 = Inc/dec, 1 = Random, 2 = All at once
stairs/b for brightness - 1-254 (Be careful at high brightness - It's possible to overload the ULN chips)
stairs/t for fade time in milliseconds - 100+ ms (less than 100 works but it cant do it this fast anyway)
stairs/l Light threshold - value between 0 and 1024 with 0 being no ambient light at which the lights will not trigger
stairs/h Hold time - The time between all lights being on and starting to turn off again
stairs/o - Manual Override 1= disable the sensors so you can force the lights on or off, 0=sensors enabled again

Anything posted to the specified topic
stairs/n - Turns on all lights at set brightness (/b)
stairs/f - Turns all lights off
stairs/u - Triggers the up sequence
stairs/d - Triggers the down sequence
stairs/r - Triggers the random sequence
stairs/x - Demo!

Step 5: Wrapup

Picture of Wrapup

You and I now both have some cool stair lighting to prevent us from ungracefully falling up/down the stairs at night, but more importantly to impress our visitors!

It's now up to you how you interface to the system.  My Method is via PHP/Javascript with some funky NodeJS and Websockets - It's pretty technical as it's the backbone of the rest of my home automation system but I don't mind sharing some of my work on that too.

This does somewhat limit the audience that this might be useful to (if only those that have 2 story houses wasn't enough) but if there is enough requests from some slightly less geeky individuals out there that might want to do the same with just a normal arduino and serial/bluetooth I will release a second version.

I learnt some interesting things building this, one of which is a real weird anomaly where the LED strips seem to be finding a magic partial ground through inductance or something like that.  You see, I mounted my LED strips to some Aluminium strip for securing to the stairs and what I notice is that at night you can faintly see a few LEDs are on JUST.  But, If i touch the aluminium, it comes on brighter.  Even though there is no electrical connectivity between the LED strip and the Aluminium.  The solution to this is to either switch on the 12v supply only when they are active (via a FET or something like that) or, to ground the aluminium - Doable but a PITA...  For now, I'll put up with it :)

BTW - My stairs are manufactured by Stairlock - A great South Australian based company that manufactures great quality, low cost stairs as well as premium stairs for the Australian market.  Check them out - http://www.stairlock.com.au 

Comments

callhow (author)2015-08-18

Stairways are "prone" to being dark and sometimes not lighted. However, you don't

have to; " somewhat limit the audience that this might be useful to (if only those that have 2 story houses wasn't enough)...". There are many house that "also" have basement stairways - which could also benefit from this instructable.

amontassir (author)2015-01-27

nice projects

Qtronik (author)2015-01-25

Is it possible to you to tell me what is the distance between holes for wire connectors for individuals Led-strip wires ?

I'm just want this specs. for me to buy somewhere on the web...

For the moment I'm shopping everything on Ali Express

I'm working hard to buy every thing I need in double for making your great idea for me and my brother's house!

Qtronik (author)Qtronik2015-01-25

I saw 2.54mm pitch on aliexpress similar to your's, but I can't be extremely sure about it in pcb layout viewer's

Qtronik (author)2015-01-11

For sure I'll do it!

Had you think to manage it with OpenHab ? that should be really cool !

Fission Chips (author)2014-11-21

This looks awesome! Nice job.

nejo0017 (author)2014-01-20

Nice instructable! i'm also planning a project with stairs and light.
Could I have a look at your code as inspiration?
Regards, jo

About This Instructable

12,124views

66favorites

License:

More by andrew_h:Hacking an LG Ducted Split for Home AutomationIoT Enabled Coffee MachineArduino Powered Gainclone (amplifier)
Add instructable to: