Author Topic: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)  (Read 31978 times)

Offline waynehead99

  • Sr. Member
  • ****
  • Posts: 296
  • Karma: +16/-1
Re: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)
« Reply #15 on: February 24, 2014, 09:06:01 am »

I decided to continue the fun by mounting three 1-watt LED lights above the fireplace mantel for accent lighting using the same circuit and sketch above...

How does the wiring look? You are giving me lots of ideas. This one would really make the wife happy.

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
Re: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)
« Reply #16 on: February 25, 2014, 01:03:46 am »

How does the wiring look? You are giving me lots of ideas. This one would really make the wife happy.

Very simple.  Three, one-watt LEDs wired in parallel and controlled by the same single DimmableLED MOSFET circuit and sketch at the beginning of this thread and powered by a 12VDC 4A power supply.  Parts used below:

LEDs - http://www.amazon.com/gp/product/B004BCVM4Q/ref=oh_details_o06_s03_i00?ie=UTF8&psc=1
Power Supply - http://www.amazon.com/gp/product/B0034GUEY4/ref=oh_details_o06_s00_i02?ie=UTF8&psc=1

These small lighting projects have exceeded the "wife-factor" goals.  Happy wife == happy life.
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline waynehead99

  • Sr. Member
  • ****
  • Posts: 296
  • Karma: +16/-1
Re: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)
« Reply #17 on: February 25, 2014, 07:45:23 am »
Thanks for the links. I also wanted to know how you did the wiring for the lights in the wall. Is the arduino and power supply in the wall?


Sent from my iPad using Tapatalk HD

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
Re: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)
« Reply #18 on: February 25, 2014, 11:45:28 am »
I also wanted to know how you did the wiring for the lights in the wall. Is the arduino and power supply in the wall?

There is a storage closet behind the wall where the fireplace flue exits the structure.  I drilled 2.5" holes using a hole saw up through the supports over the mantel, drilled a 3/8" hole through the insulated wall in the closet behind the mantel and just above the 2.5" hole for the LED fixture.  I fed the LED wire up through the 2.5" hold and then fished the wires out using a clothes hanger.  I sealed the holes using insulated sealer and wired everything up in the closet behind the mantel.
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
Re: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)
« Reply #19 on: February 27, 2014, 11:09:22 pm »
I have attached the circuit layout to the first post in this thread so others can give it a shot.  Also, per Hek's suggestion, I plan to develop a multi-channel dimmer for RGB LED strips if anyone is interested.
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)
« Reply #20 on: February 28, 2014, 01:49:58 am »
There is another thread about RGB(W) control maybe you can find something you can reuse there.

http://forum.micasaverde.com/index.php/topic,18103.0.html
- Tomas

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
There is another thread about RGB(W) control maybe you can find something you can reuse there.

Thanks Tomas.  Freeing up another PWM pin is certainly helpful ;) 

I found that in order to make ON/OFF function properly, the V_LIGHT variable must be managed in addition to the V_DIMMER variable - check out the DimmableLED sketch above for an example; I also included a method to gently fade the strip up and down that you might find useful...

The goal for extending the DimmableLED sensor beyond one channel is to provide a general purpose PWM dimmer for up to 4 independent channels to allow users to control 1-4 white strips or 1 RGBW strip, or 1 white strip and 1 RGB strip,  or 1 white strip, 1 red strip, 1 green strip and 1 blue strip, etc.  I am also going to add current measurement and reporting and am considering HSV control in addition to RGB (not sure about the UI design for the latter given the current limits of the M_PRESENTATION message - will probably need to leverage V_VAR1-5 somehow). 

Below is the straw-man circuit design - this maybe a bit of overkill but it is a fun little project and hopefully others will find it useful ;) 

Let me know if you want to collaborate on this...

Best,
Bruce
« Last Edit: March 02, 2014, 10:15:35 am by blacey »
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
I'm really looking forward to your version of the RGBW controller. I have noticed that the on/off is not working as expected and taking the dimmer to 100% in vera seems to turn off the output channel. I'm quite surprised that I got the thing working at all since coding is quite new to me. If hek had not helped me I would get nowhere.
- Tomas

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
I'm quite surprised that I got the thing working at all since coding is quite new to me. If hek had not helped me I would get nowhere.

Wow, for being relatively new to coding, you did a great job Tomas! 

If you have a perspective or any ideas on the UI side of things then please let me know. 

Current design / approach:
  • To maximize 3rd party compatibility (as discussed in the RGBW thread you referred me to) there will be a device for each channel that the user "declares" in the sketch - not the best user experience but I figure this is OK because users have to physically wire the LED strips and upload a sketch so they should be capable of modifying a few lines of declarative code for their configuration.
  • Declaring an LED channel will include specifying an attribute for type/color that may be used by the sketch - as a convenience to the user, this information will be be reported back to the gateway in VAR_0 for each channel to facilitate the device management activities (e.g. renaming their Arduino Dim Light devices based upon color/name)
  • Energy usage reporting - my current thinking is to compute the total watts and divide it by the number of channels and report that value for each channel.  Thoughts?  Following Hek's design pattern, I think Energy sensing is supposed to be a separate sensor but energy usage seems to be more of an attribute of the channels/node than another distinct device - akin to what is done for Smart Switches.
  • RGB vs. HSV - It might be nice for users to be able to configure the ability to control the colors by RGB, HSV or both, again with simple declarative statements.  For example, they could declare 3 channels (Red, Green, Blue) and declare HSV control.  By default and for 3rd party compatibility, this would result in six devices but the node would convert between RGB and HSV.  To reduce the device clutter, I can include an option to not present the RGB devices when HSV is enabled by the user.
  • Dealing with luminance variance between channels - haven't totally figured this out but it is probably another attribute of the channel that a user can declare to calibrate their strips. It would default to equal luminance - let me know if you have any thoughts here.

Because sensor sketches will evolve, version management might become a challenge for users so it would be nice to extend the Arduino node to allow the sketch to report variables that are global to the node for display on the Arduino Node device - for example, I have several DimmableLEDs deployed and it would be nice to view the sketch name and version in addition to the library version and parent node that are displayed today.  Hek, any thoughts on this?

I don't have a much spare time to devote to this hobby these days; i.e. this is a background project so it may take a while to see the light of day (pun intended).

Finally DimmableLED really is meant to be a n-channel general-purpose PWM dimmer that can be used for many applications besides color control but should I move this discussion to the RGBW thread?

Cheers,
Bruce
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Wow Bruce, seems like you have really big plans for the RGBW sketch I guess it would be a good idea to move your thoughts in to the other thread so you can hopefully get some feedback from garrettwp, a-lurker and RichardTSchaefer about all this.

Thanks for the encouraging words about my coding skills. You could say I'm a copy/paste coder. I understand code (if it is not to complicated) and I can take bits and peaces and puzzle them together and change code but I could never write code from scratch.

About the hardware I have just copied Jerome Bernard -> http://www.jerome-bernard.com/blog/2013/01/12/rgb-led-strip-controlled-by-an-arduino/
You probably have a different transistor then the IRLZ44N and you did not add the 10kΩ resistors, between each control/gate pins and ground in order to force the signal to LOW until the Arduino kicks in.

BTW, Jerome Bernard also has a solution for the HSV to RGB translation and luminance variance between channels in his blog.

One thing I would like to add to my setup is some way of turning it on/off from one device in vera. I guess once I have set it to a specific color all I will do is turn it on or off most of the time. I guess I can do this using a scene in vera.

Regards,
Tomas
- Tomas

Offline Vodden

  • Sr. Member
  • ****
  • Posts: 323
  • Karma: +20/-14
@blacey

Nice work on this project!  Looks pro.  I am hoping to use this to add a dimmer to my 12V LED MR16 cable lighting I am unable to dim from the switch via z-wave due to the 120VAC-12DC transformer.  This definitely makes it possible now!

I was wondering what this node looks like on the 'DEVICES' screen of the controller.  Is there a dimmer slider for control?  I don't plan on ever using it to control my LED's but I was curious. 

I was also wondering if you have associated it with a Z-wave in wall scene controller and been successful controlling the dimmer?  I would like to incorporate it into a scene with other lighting that would include the option of functioning with an in wall controller but was unsure if this was supported.

Thanks!

V
Vera 3 v1.5.622, Sharp Aquos, DSC 1864, EVL-3, (2) iPhone 6, Kwikset 912, Kwikset 910, (2) Linear WT00Z-1, (2) Linear WS15Z-1, (2) Linear WD500Z-1, (2) Evolve LTM-5, (8.) Aeotec micro-dimmer,  (3) Aeotec micro-switch, (1) Cooper Aspire RF9500

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
Nice work on this project!  Looks pro.  I am hoping to use this to add a dimmer to my 12V LED MR16 cable lighting I am unable to dim from the switch via z-wave due to the 120VAC-12DC transformer.  This definitely makes it possible now!

I was wondering what this node looks like on the 'DEVICES' screen of the controller.  Is there a dimmer slider for control?  I don't plan on ever using it to control my LED's but I was curious. 

See image below - to the Vera it looks just like any other dimmable light...

I was also wondering if you have associated it with a Z-wave in wall scene controller and been successful controlling the dimmer?  I would like to incorporate it into a scene with other lighting that would include the option of functioning with an in wall controller but was unsure if this was supported.

No, I have not but because it is indistinguishable from any other dimmable light on the Vera, all remotes such as iVera, control it perfectly.
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline Vodden

  • Sr. Member
  • ****
  • Posts: 323
  • Karma: +20/-14
@blacey

Awesome! 

I officially have no clue what I am doing with Arduino, but I'm going to give this a shot with my 12V Ikea Termosfar cable lighting.  I have ordered LED replacements for all the remaining 40W halogen bulbs and I am sure the Arduino, radio, and MOSFET will fit inside the wall mounted transformer case and your wiring diagram is very clear. 

I have been searching for a way to dim these puppies since the day I bought them, but I live in a log home, so running additional wiring is a bit of a challenge, which heavily contributed to the use of these lights in the first place. 

I did find a remote control option that works on 433.92 MHz, so using an Arduino transmitter would also work and would be easier to wire, but I'm a little skeptical of my signal sniffing capabilities and building another set-up for that function when I have never even seen an Arduino yet.  I do think I could wire up a few of these to my transformers no problem.  My electrical capabilities are far superior to my programming capabilities.  Baby steps.

I'm sure I will be picking your brain far before I will be posting pictures of a successful project, but I will keep you posted.  At least 14 days until I have all my gateway and dimmer parts....

Vera 3 v1.5.622, Sharp Aquos, DSC 1864, EVL-3, (2) iPhone 6, Kwikset 912, Kwikset 910, (2) Linear WT00Z-1, (2) Linear WS15Z-1, (2) Linear WD500Z-1, (2) Evolve LTM-5, (8.) Aeotec micro-dimmer,  (3) Aeotec micro-switch, (1) Cooper Aspire RF9500

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
@Vodden

Sounds good - I will be happy to help you though the Adruino journey that I am sure you will find fun and rewarding.  The MySensors integration really uncorks the potential for the Vera beyond its already open and extensible form.  You can get up and running with a prototype gateway built on a breadboard or go for a clean compact packaging.  Below are two different gateways that I have built. 

For the compact gateway, here is a short write-up.

http://forum.micasaverde.com/index.php/topic,16170.msg153470.html#msg153470
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline Vodden

  • Sr. Member
  • ****
  • Posts: 323
  • Karma: +20/-14
Thanks for the support, I will probably need it lol.

Glad you posted the gateway pic, otherwise I would have forgotten to get a step down module. 

I was looking at this enclosure for my gateway

https://www.sparkfun.com/products/10088

I was planning on an Ethernet gateway instead of a USB, but I don't know if @hek's sketch will support the shield that I want to buy.  I don't want to have to do a bunch of messing around with the enclosure but want it to look tidy, but I can't find a 'board ready' enclosure for the Nano, and it appears that it is the only board that supports the USB gateway, and this is the only 'board ready' enclosure I can find for the UNO, and it works with a shield that I am unsure the sketch will support.   ???

Is the button for inclusion?
Vera 3 v1.5.622, Sharp Aquos, DSC 1864, EVL-3, (2) iPhone 6, Kwikset 912, Kwikset 910, (2) Linear WT00Z-1, (2) Linear WS15Z-1, (2) Linear WD500Z-1, (2) Evolve LTM-5, (8.) Aeotec micro-dimmer,  (3) Aeotec micro-switch, (1) Cooper Aspire RF9500