This is my first Instructable, hope you like it. It is based on ideas and animations taken by another old project of mine:
From the above first version of that lamp (dating back one year ago), I took general concept and ideas, and part of the mobile app code.
For this project, I have changed the microcontroller (it's now a Wemos D1 R1 instead of an Arduino Uno + ESP8266), I have added some animations (some make sense only on the stairs), and I have added the motion detection plus alarm feature.
Then, this project gave the inspiration for the second version of the lamp:
https://www.instructables.com/id/Arduino-based-Gree... which is made with a Wemos D1 R2, has different animations, and has the improved version of the mobile app.
Part of the animation code is by Adafruit (their strandtest example
in the Neopixel library). The Larson effect code is inspired by:
Getting the outside temperature with openweather was inspired by: http://educ8s.tv/esp8266-weather-display/
Automatic connected staircase lights. I wanted to build a project having in mind three objectives:
1) it must be useful: many projects we can find on Internet are scientifically challenging, and many times they are cool&fun. But they may miss the long-term usefulness, or large audience impact. I wanted to build something me and my family would use everyday, so that readers would find it useful too.
2) it must look cool: I didn't want to end up with something which looks patchy, ugly, that nobody would like to show in his/her own house. Something as close as possible to a real product.
3) it must be fun: this is really for the builder :) something which you'd enjoy replicating and playing with, while meeting the criteria above.
I tried to fulfill the above as much as possible, you're the judges, your views, favorites, and votes will be my measure of success! :) enjoy!
I like the idea of walking through the house without having to press a button to switch on the lights. I wanted to have something like this on our staircase, also having in mind you may walk the stairs with your hands busy with something (or someone :) ). I wanted to make my own automatic switch to enable animations and effects (hence a micro-controlled solution) and I like LEDs in principle but the dots are too geeky (hence a LED strip in an aluminum profile with a glossy diffuser). Plus, I wanted to have an extra motion-detection alarm for our house (hence a wifi-enabled micro-controller, the IFTTT integration, so finally an IoT solution).
I used the following components, scroll down for the building steps:
1) 2 x 4m ws2813 rgb LED strips:
get the non waterproof version, with 60 leds/m. Also, I found a cheaper 5m version and just cut 1m from the end of both the strips. Note you can do this with ws2812 and ws2812b LEDs as well, the light will be exactly the same and these are cheaper. The ws2813 are just more reliable, as they have a redundant data connection, so if you break one LED, the rest of the strip will keep working.
These were roughly 27$ / 25€ each.
2) 4 x 2m U-line aluminum profiles, 14mm x 13mm:
These were 20€ each, roughly 22$. I have also bought the terminal caps and the fitting screws. The screws couldn't be installed on the side I needed them, they are supposed to be installed on the side opposite to the diffuser, so they were of no use for me. Instead, thanks to the slope of the stairs and some friction provided by the skirting board, some pieces of bi-adhesive scotch tape was enough to fit the profiles over the skirting boards.
3) 2 x cat-5 Ethernet cables :
I have no idea which length was used here, I guess around 2m, the electrician and the carpenter installed the cables under the floor, going from the skirting boards of the stairs, to the room with the hotpress. Note that too long cables will reduce the current and you'll need some more sophisticated setup to provide the correct current and to avoid breaking the data connection.
4) spare assorted dupont cables:
5) as wifi-enabled micro-controller, I have used the first version of the Wemos D1, now discontinued, which you can still find online:
For future readers, if you don't find it, version R2 of the Wemos D1 should work as well.
6) 2 x PIR motion sensors for Arduino:
7) one 5v, 40a, 200w power supply:
This was 21.5£, roughly 25€ or 27$. You probably need less than 40A, but this was cheaper than a 20A, and with the amperes, it's always better to oversize, so the power supply will run cool and live longer.
Step 1: Wiring
You need to realize the following connections:
1) LED strips - Wemos D1
2) LED strips - power supply
3) PIR sensors - Wemos D1
4) PIR sensors - power supply
5) Wemos D1 - power supply
6) power supply - house power network
Preparation: I had two cat 5 Ethernet cables (
https://en.wikipedia.org/wiki/Category_5_cable) installed under the floor between the skirting boards of the staricase and the hot press by the carpenter and the electrician before the carpenter installed the wooden floor. One cable per side of the staircase, popping out from the tip of the skirting board on one end, and from a hole in the wall of the hot press on the other end. A cat 5 cable has 8 small cables in it, divided into 4 twisted pairs using 4 different color bases and 2 color patterns (solid color, or dashed line). Remove 8-10 cm of rubber from each end of each of the cat 5 cables, so to access the 4 twister pairs. Un-twist each pair, so to end up with 8 indipendent tiny cables. Remove about 1cm of plastic only from each tip of each tiny cable, at both ends of each of the two cat 5 cables. This step is quite time consuming and I recommend using a proper cable peeler to do it quickly. I used scissors.
For the connection listed as 1), I picked the 4-way connector (plus the two extra power cables) from the LED strip, and connected the green cable from the LED (the data cable) to one of the 8 tiny cables from the cat 5 cable. I chose the white-orange pins of the cat 5 cable for this.
For the connection listed as 2), I picked the 4-way connector (plus the two extra power cables) from the LED strip, and connected the red cable from the LED connector (the VCC cable) to *two* of the 8 tiny cables from the cat 5 cable, re-twisted together. I chose the blue and white-blue pins of the cat 5 cable for this. Also, I connected the white cable from the LED connector (the GROUND cable) to *two* of the 8 tiny cables from the cat 5 cable, re-twisted together. I chose the brown and the green pins of the cat 5 cable for this. Lastly, to bring even more current to the strip, I connected the extra white cable from outside the LED connector (the extra GROUND cable) to one of the tiny cables from the cat 5 cable (I chose the white-green pin of the cat 5 cable for this), and the extra red cable from outside the LED connector (the extra VCC cable) to one of the tiny cables from the cat 5 cable (I chose the white-brown pin of the cat 5 cable for this). The reason for powering the LED strip with 3 cables bringing the positive, and 3 bringing the ground, is to distribute the current over more pins, to avoid over-heating and to make sure enough current reaches the LEDs. This could have been achieved by running a thicker cable just for power, but then I would have needed to run too many separate cables (a thick one for power, a thick one for ground, one data cable for the LEDs, one data cable for the PIR sensors. I preferred to pay the electrician less and have only 1 cable per side installed :)
For the connection listed as 3), I connected the "out" pin of the PIR sensor to one of the tiny cables from the cat 5 cable (I chose the orange pin of the cat 5 cable for this).
For the connection listed as 4), I connected the "vcc" pin of the PIR sensor to the white-brown tiny cable of the cat 5 cable which was already connected to the red cable from the LED strip, and the "ground" pin of the PIR sensor to the white-green tiny cable of the cat 5 cable which was already connected to the white cable from the LED strip.
All the above connections could be made more tidy by using heat-shrinkable tubes. I'm not using them, as I plan to cover everything with a white MDF board placed on top of the aluminum profile, so to embed the profile into the skirting board. This will hide all the cables and will leave me access in case repairs or further developments are needed.
These first 4 connections were replicated exactly on the other side of the staircase, where the other PIR sensor is.
Note also that the blue cable from the LED connector is left without a connection, as that's the redundant data from the ws2813 strip.
To realize the other sides of the connections (i.e. in the hot press), I have:
a) twisted back together the blue, white-blue, and white-brown pins of the cat 5 cables and I have inserted the result into one of the three "+V" ports of the power supply.
b) twisted back together the green, white-green, and brown pins of the cat 5 cables and I have inserted the result into one of the three "COM" ports of the puwer supply.
a) and b) were replicated for the other cat 5 cable corresponding to the other side of the staircase. I have used another "+V" and "COM" port(s) of the power supply.
c) the two orange pins of the two cat 5 cables were insrted into pins 4 and 5 of the Wemos D1
d) the two white-orange pins of the two cat 5 cables were twisted back together and inserted into pin 1 of the Wemos D1. Now, if I had used a regular Arduino Uno with a wifi shield or external esp8266 module, I could have left the two strips independent, not twisting the two cables, and connecting the two pins to pins 1 and 2 of the Arduino. This way, I could have controlled the animation of the two sides of the stairs separately. I decided to simplify, though, and kept them joined. This is a limitation of the Wemos D1 R1, that can drive a Neopixel-compatible LED strip only from pin 1. I'm not sure if they fixed this into R2, that's possible, if you end up trying with an R2 let me know if this works.
For the connection listed as 5), I had many possible options (like using a spare usb power supply for a phone and using directly the microusb port in the Wemos D1), but, since I had the last (third) pair of +V and COM ports from my 40A power supply unused, I decided to connect the 5v pin of the Wemos to the +V port of the power supply, and the GND pin of the Wemos to the COM port of the power supply. Please note this bypasses the internal voltage regulator of the Wemos and will only work if the power supply has a pretty constant voltage, which was my case. If not, you risk to burn the Wemos D1. Note that in the picture you'll see a microusb cable connected to the Wemos D1. Well, it's not connected to anything on the other side, I just left it there for when I have to plug the Wemos to the laptop to program it. As you'll discover in the later step, I am programming the Wemos wirelessly OTA (Over The Air) now, so that cable can be removed for good.
For the connection listed as 6), the electrictian left a white cable plugged to a fused switch, carrying 220v, popping out from the wall. So all I had to do was to take some of the rubber out at the end of the white cable, remove about 1 cm of rubber from each of the three contacts, then connect the brown into the "L" port of the power supply, the blue into the "N" port, and the yellow-green into the "earth" port.
This was by far the most time consuming step, also because I didn't use the proper tools for peeling off the cable rubber, I just used some kitchen scissors. I have always done it that way so my error rate was only 3/35 (where 35 is 8 pins from each cat 5 cable and each end of them, plus the 3 pins from the house network cable), i.e. I only had to re-cut 3 pins in total out of 35 connections. However, you can do it probably faster with a proper cable stripper.
Step 2: Fitting the LEDs and the Aluminum Profiles
This is rather easy once you figure out the best sequence of steps. I recommend the following:
1) with the help of another person, take both the profiles to install on one side, put them over the skirting board with the diffuser pointing towards the other side of the stairs, decide which area of the stairs you want to cover (our stairs were 4.4m long and we only had 4m of aluminum profiles) and mark it with a pencil.
2) place 3 or 4 chunks of bi-adhesive scotch tape along the length of each of the two aluminum profiles (or on the skirting board directly). Ok, I lied, I didn't have bi-adhesive scotch tape so I just ended up using regular scotch tape roled over itself to form a bi-adhesive patch. It works.
3) gently remove the diffuser from the aluminum profiles (watch your fingers!)
4) place the profiles onto the skirting board (i.e. onto the scotch tape), making sure the scotch tape is hidden between the profile and the skirting board. Make also sure that the diffuser is pointing towards the other side of the stairs, not pointing up, otherwise you won't get the desired effect. In other words, the attached picture here is just for reference, don't follow the image with the measurements as that installs the diffuser pointing up.
Now you need to take some confidence in doing the next steps, my advise is to get help from a second person, and get the person with the smaller fingers to do these:
5) unroll the LED strip, place it next (but outside) of the aluminum profile and make sureall the LEDs will properyl end up inside the U-line. at the top end of the strip, you have the connector, which is thicker than the aluminum profile. Take note of where that will end up once the strip will be inside the U-line.
6) remove the cover of the bi-adhesive tape that you find behind the LED reel (if you don't have a bi-adhesive tape here, get one and fit it along the whole length of the reel. No sporadic patches, you need the full lenght covered by tape). I had 3M quality bi-adhesive so there was very little room for error. If you don't pay enough attention, the tape will stick to either the profile, or the skirting board, or to another piece of the strip itself, or to the steps, and it's not too easy to remove it.
7) insert the top connector of the LED strip by sliding it together with the first 2-3 pixels into the end of the profile. Make sure you match the level that you took note of in step 5)
8) now have the person with the smaller fingers gently press each pixel against the end of the U-line. Take your time while doing this.
If you took note of all the lengths correctly, you'll end up with the last LED just 2-3 mm inside the U-line on the other end. :)
Step 3: Programming the Wemos D1 Microcontroller
Load the attached "instructables.ino" file into the Arduino IDE, connect your Wemos D1 via usb (make sure you have followed the Wemos installation guide first:
https://www.wemos.cc/tutorial/get-started-arduino.... and upload the sketch.
You'll need to configure three things in the sketch:
note that the sketch is not really optimized, as the various blocks are copy-paste from other projects I had in my library.
Also, you'll notice there is more than just "switch on the light automatically and send a trigger to IFTTT". For example, you can control the lights from the web by sending a command in JSON format and turn on the lights with different glowing colors. I have developed a simply mobile app to interface with the stairs, it's shown in the videos in the next steps, though the app itself is out of scope for this instructable. Also, the mobile app is developed reusing another project of mine here:
The "glowing" effects of the lights on the stairs is provided by the combination of the following:
1) I have chosen the 60 led / m version of the strip. With 30 led / m it wouldn't have been the same, as you would have seen the dots of the LEDs.
2) I have chosen the U-line as opposed to the mini-U-line, which is much narrower, so the LEDs are closer to the diffuser and you see the dots
3) I have chosen the opal diffuser. With a frosted or semi-transparent diffuser, the effect wouldn't have been the same.
4) I hope it's visible in the video, the effect when the lights turn on or off is that of a glowing light switching on, rather then a mere, raw, switch on altogether.
5) the other colors I have embedded as other possible choices to light the stairs are all "pop-electric" colors that give a modern look to the stairs.
To give you some hints for the mobile app and the web interface, I have:
1) made sure that my router assigns always the same ip to the Wemos D1 (check for the "reserve address" feature in the DNS page of your router)
2) specified a simple protocol to send commands: via web, you can send the "c" parameter from 1 to 13, will set the lights to 13 different colors (13 will set them off), according to their RGB values specified in the sketch.
To do this, simple access via web "http://192.168.YOUR_IP_HERE/?c=4" to set, for example color 4, which is
0xFF00FF, i.e. purple. The mobile app does exactly this, just with a nicer interface than a web url.
The embedded video here shows the result so far (without IFTTT).
Step 4: Interfacing With IFTTT
IFTT (If This Than That) is an online platform enabling actions in response to certain conditions (e.g. weather conditions, other actions, sensors, etc):
All you have to do is to specify the "This" and "That" in what's called a "recipe".
In order to create a custom recipe, you need to create a "Maker" account and get a maker key.
then sign up, and get a maker key, which is a long alphanumerical string.
Place that string in the sketch from the step before, in place of "YOUR_IFTTT_MAKER_KEY_HERE".
Then create a "trigger", for simplicity create two triggers, one called "downstairs", one called "upstairs", they are already setup in the sketch for the Wemos. If you prefer to have only one trigger, just scroll the sketch and change "upstairs" and "downstairs" with something like "stairs" only.
Make sure you oriented the two PIR sensors one pointing downstairs, one pointing upstairs, and to match their pins so you trigger the "downstairs" event when someone is downstairs and climbing upstairs, and the other way around.
As "That", choose your preferred action. I chose Anroid notification. In this way, I get my IFTTT app installed on Android to notify me of the events. You can setup a notification string, I chose "OCCHIO SOTTO!" (it means: "watch downstairs!" in Italian) and "OCCHIO SOPRA!" ("watch upstairs!").
As a final touch, if you have a 24/7 connected linux system, install a cron job that forces the triggers to be checked every minute. In this way you will get notified within a minute when somebody walks the stairs. Otherwise, it's left up to the IFTTT timeout for that specific trigger. Usually this is 15 mins.
See this embedded video for the final result (there was a small delay before the downstairs sensor got me this time).
Step 5: Enhancements
When I first wrote this Instructable, I had a series of next steps which I planned do implement.
Now I have implemented most of them, so here they are (see the video for their final effect):1) a "clock" animation, i.e. telling the stairs to display the current time by switching on different pixels
2) a "Larson" (aka Knight Rider) animation
3) an outside and inside temperature display, telling the stairs to light from the bottom up to the level of the current temperatures. Outside temperature could be taken by
http://openweathermap.org/ making the stairs even more IoT.
4) step-by-step animation when motion is detected
5) several other animations not motion based: 4m of Neopixel strandtest, a modified version of the strandtest that changes all the pixels colors at once, etc
See the updated Arduino sketch
Still left to do:
6) adding a light sensor, that would control the light switch to work only when the house is dark
Hope you enjoyed my first Instructable!
Step 6: Conclusions
I had fun building this project, hope you'll have too if you're going to replicate it.
1) I believe it's useful. I walk the stairs at night for a glass of water, and I don't have to even remember where the light switch is while I'm asleep :)
2) The use of the Arduino-based micro-controller is not limited to just sending a signal, or switch on the lights. So far it handles the motion sensors, it implements the animations, it serves an http-based interface to control the lights, and it interfaces with IFTTT to implement the home alarm. Plus, it works as a clock and thermometer thanks to IoT :)
3) Its glowing effect looks really cool on our steps. It probably wouldn't be the same if we had carpet on the steps. The picture and the videos don't really show how they look live, I hope you'll enjoy replicating this project to see its real effect! :)
Final line: all of this is only possible thanks to the versatility of the genuine Arduino (originally started by Italian designer and enterpreneur Massimo Banzi, co-founder), Arduino clones, Arduino-based boards, and ESP8266-based Arduino-based boards. They really enable tons of applications and their limits is just your creativity!
Second Prize in the
Green Electronics Contest 2016