Shelf Accent Lighting With Arduino, Smartthings and LED Strips
by FarmingGeeks in Circuits > Arduino
5996 Views, 65 Favorites, 0 Comments
Shelf Accent Lighting With Arduino, Smartthings and LED Strips
This instructable is based on my previous instructable https://www.instructables.com/id/Arduino-and-SmartThings-LED-Strip-Lighting/ . During the previous instructable I learned a lot and it had to change pretty substantially. The purpose of this instructable is to fix the mistakes I made and combine what I learned in order to finish the accent lighting for my spouse and daughter's desk shelf. We are going to completely start over in this instructable highlighting the differences between the previous, so please follow along step by step.
Tools Needed
For the LED/Arduino portion here is what we are going to need
- Soldering Iron
- Solder
- Solid Core wire or pack of jumper wire
- #1 phillips screw driver
- Drill with #1 phillips bit.
- Multi-meter with ability to check for continuity and voltage.
- Shrik Wrap
- Small torch or lighter for shrink wrap.
The Materials.
We have changed some things in the instructable so we will highlight on the material differences. The green rows are are new to the instructable and the red rows are no longer needed in this version of the project.
Qty | Item | Source | Price | Notes |
---|---|---|---|---|
1 | Arduino Uno R3 | Amazon / Radio Shack | $16.06 / $24.99 | Purchased on store closing at Radio Shack but now their price is high |
1 | Arduino Case | Amazon / SainSmart | $14.99 / $4.53 | You can get it direct from SainSmart but you have to wait longer. |
1 | SmartThings Shield | SmartThings | Current Price Unknown | For some reason the option to add this to cart is not there right now. Maybe they are out of stock. |
3 | RGB LED Strips | Radio Shack | No Longer available | I got these on clearance at Radio Shack when they were closing down for like a dollar. You can use any 12v LED strip with three pins. |
1 | Seed Studio Relay Shield | Radio Shack | $19.99 | Again Obtained when they were closing down. Yes I stocked up. This was removed from the project for two reasons: It kept shutting off the relays at random intervals and because it helps simplify the project. |
1 | 6 amp 12v Switching Power Supply | Amazon | $6.97 | What ever you do make sure that you get a 2.1mm barrel jack with center pin positive. These are so cheap, might want to buy a few while you are at it. |
1 | Pack of Male/Female Barrel Jacks | Amazon | $8.99 | This is a pack of 10 each male and female. will give you some extras for later. |
1 | Simple PCB Breadboard | Radio Shack | $2.49 | Although the are not the best quality, these are handy to have around, pick up a few. |
7 | PCB 2 Screw Terminals | Amazon | $4.99 | pack comes with 30 pieces |
1 | 1000uF Capacitor At least 13v | Amazon | $3.56 | I had these on hand from fixing a Samsung TV about a year ago. Pack comes with 50 / Will discuss why this was added later. |
3 colors | 22 ga hook up wire | Amazon | $20.0 | Stranded wire works the best for the LED strips. |
6 | 3 Pin JST Connector | Amazon | $9.88 | We use these to connect the LED strips together. |
4 | Breadboard Jumper or Solid Core Wire | Amazon | $7.10 | These are what I used / Again you can use some 22ga solid core wire and cut to length as needed. |
1 | SmartThings Hub | Amazon | $49.99 - $99.00 | Currently on sale for $49.99 |
50 | Led Strip Silicon Clip | Amazon | $5.30 | These come in a 50 pack |
100 | #6 1/2 " to 5/8" Pan Head Screws | Amazon | $6.46 | These are for sheet metal but will work for wood as well. |
Powering the Arduino and LED Strips
This is the step that took a major change from the last project. In reading and learning about neo pixels I learned that rapid addition or removal of power to the LED Strips could end up damaging the first pixel and burn it out. AdaFruit recommends placing a capacitor in the circuit before the strips to prevent damage. They also recommend putting a resistor before the arduino on the data line.
So the first thing we are going to do is build or after main power power supply for the project.
Again I kind of lucked out with what I had laying around but the mounting holes on this breadboard ended up lining up perfectly with the holes on my arduino case. You can watch the video or follow along below for how to build this piece. The only thing the video doesnt cover is the resistor.
- First lets gather the materials. The breadboard, screw terminals, wire, and capacitor.
- Next we need to connect the a few wires from the common power rail in the center to the outside. Keep in mind these wires should be inserted from the bottom for clearance.
- Make sure that the wire on the outside is cut off just enough so it doesnt go all the way through. Enough to be in the hole but not enought to fully protrude.
- Now we need to do the same thing for the ground common rail. Keep in mind these wires should be inserted from the bottom for clearance.
- Make sure that the wire on the outside is cut off just enough so it doesnt go all the way through. Enough to be in the hole but not enought to fully protrude.
- Next we can bring over our small screw terminal
- Notice how both the Postive and Negative Rails will light up to show they are connected when you click on either of them.
- Now we can bring over the large section of the screw terminals to the positive rail.
- Again notice how everything lights up to show connection when you click on the terminal
- Now bring over the smaller screw terminal and put it in the negative/ground rail.
- Same thing occurs when clicking on one of the terminals to show connection
- Now we can bring over our capacitor, make sure the negative lead goes into the negative spot.
- Again we can check connection on both the positive and negative rail.
- Additonally Adafruit recommends a resistor on the data line, so we took another screw terminal and a 330ohm resistor and jumped between the two pins on the terminal.
- First the resistor
- Now the screw terminal.
"
- First the resistor
- Now that everything is on the board we need to flip it over and start soldering everything on. Once this is done. We can move on to the next step.
Putting Electronics Together.
Now we need to build our arduino case, install the arduino into the case and put the SmartThings Shield onto the arduino. My case was not the best for this as it leaves too much space at the top and does not allow the shield to connect. I made some modifications by putting some taller standoffs under the arduino so that my shield would fit. This kind made the top of the case not sit flat but at least its somewhat covered. Again luckily my PCB breadboard perfectly fits on the arduino case so stuff isn't floating around.
Also we split our LED Strips in half so that I can put two smaller LED sections in each shelf section. then we removed the very end sections of each LED strip and soldered 3 pin JST connectors so that we can plug them together.
Now we need to move onto connecting everything. Check out the full schematic image to see how everything is connected. See the difference? We removed all of the relays and connected the LED strips in a line. With this we only need one pin to control the LEDs and we can still turn off sections if we want to through the code
UPDATE: Looking at the schematic view, I put the data wire to pin 13 on the Schematic, It should be going to pin 12 on the arduino
Also note how we run an additional power and ground to the very end of the LED Strip. Why? Well this ensures that we don't get dim LEDs at the end of the strip.
Great everything is connected, but nothing will work.Onward...
Need to Download Some Libraries for Arduino.
We need to download two libraries for the Arduino for the SmartThings Shield and for the LED Strips.
For the SmartThings Shield go to http://docs.smartthings.com/en/latest/arduino/ to download and install the library, don't forget to download and install of their examples as well. Instructions are on the link provided
For the LED strip RadioShack did have a library but in all honesty it isn't the greatest. Last time we went and got the Pololu LED strip library. This time we switched over the the library from AdaFruit https://github.com/adafruit/Adafruit_NeoPixel because it seems to be a bit better and easier to code. Again instructions are on the link provided.
Another helpful program for the SmartThings side of things is Notepad++. With some modifications you can make the syntax highlighting work for the .groovy file we need to create for SmartThings. Or you can just use the SmartThings website which does the highlighting as well. To make it work with .groovy do a google search for ".groovy and notepad++"
Arduino Sketch and Connecting to SmartThings.
In the last instructable we combined a few too many steps into one and I think it may have been confusing so in this step we are just going to focus on the current code and connections. You can also take a look at the
- First lets connect the arduino to the USB cable and to the PC.
- Now download my arduino sketch attached to this step.
- Open it in the arduino IDE
- Make sure that Arduino Uno is selected
- Along with the proper port for the connection.
- Upload the sketch to the arduino.
Now that we have our sketch uploaded to the arduino we need to connect the Arduino as a "Thing" to the SmartThings Hub.
- Open the SmartThings App on your phone or Tablet.
- Click the tab that says "My Home"
- Make sure you are on the "Things" tab and click "Add a Thing"
- You can let it find it automatically or Manually. Personally I find it faster for manual.
- Click the manual button.
- Scroll to the bottom and click on "Other"
- Now select the "SmartThings Shield for Arduino"
- Then "Connect Now"
- SmartThings should find the Arduino and add it.
- Create a name for your device.
- Click "Done"
The Arduino will have no functionality at this point. Tally-ho....
Downloads
SmartThings Device Handler
Now we need to dive into the device handler on SmartThings. I'm new to this part so this was the most difficult part for me. Some of the code might be able to be a bit cleaner but it works none the less.
Another change we made in this version starts here. Instead of having the tiles of all the colors always be the appropriate color, I wanted to be able to open the App and tell what color was currently on so we made some state changes for every color. Again you can step through the code with me on the video. Or just follow the steps below to use my code.
- Open www.graph.api.smartthings.com
- login with the same user name and password that you use in the app and when you set up your account.
- Click on "Device Handlers"
- Click on "Create new Device Handler"
- Click on the tab that says "From Code"
- Open my groovy file attached to this instructable in a text editor or if you downloaded notepad++ use that.
- Copy all of the code from my file
- Paste it into the code editor on smartthings.
- You can edit the name here as noted below, then click create
- Click on "Save"
- Click on "Publish" then "For Me"
Now our code is in SmartThings but the Arduino still will not do anything.
We need to change the device type of the Arduino to our new device handler.
- Click on "My Devices"
- Click on "YourDeviceName" for SmartThings Shield
- Once it opens click on "edit" towards the bottom.
- In the "Device Type" drop down select the new device type we created.
- You can also update the room from here by clicking on Group
- "Click on Update"
Hence Forth good gentle people.
Downloads
Testing Everything on the Desk
Now we need to run some tests on the bench and make sure everything works.
Yay it works!
Ahead full steam.
Time to Mount Everything in the Shelf.
Now that everything is working we need to go ahead and mount these LED Strips and the arduino into the shelf.
I took some little rubber brackets made for LED Strips and some #6 screws to mount them into the shelf. We install one strip that has been divided into two pieces into each section of the shelf.
Since the shelf is already somewhat divided it gave me a place to rest the arduino.
Now we made an extra long power wire to run from the shelf to behind the desk and hid it with a cable hider on the white wall so it blends a little better.
Now that everything is mounted we need to hide it and make it pretty.
Conclusion and Future - Finishing Touches on the Shelf
Our lights are now in the shelf and we need to run some tests. Take a look at the pictures and video to see how it all went.
I thank you all for taking a look at this instructable. It took a lot of time and effort and many "do overs" in order to get the documentation the way I wanted it and hopefully where it makes sense. Let me know what you think and if you made it.
Next Steps:
Now we need to add the finishing touches on the shelf. I debated a long time about how to do this and what to use. I debated about making these things myself but trying to match the color with lumber available to me was going to be near impossible. The next best thing was Michael's store and picture frames due to color matching and honestly my time constraints.
So I took some measurements of what I needed, went to Michael's and found a thick picture frame material and am having them made. I also bought some "Cracked Ice" plastic for florescent lighting fixtures from lowes and will cut it to fit the frames rather than using glass. After the frames come in I will add some hinges and magnetic catches to seal the thing off and hide any unsightly wires.
I will post some updates when the frames come in.