DimmableLED light circuit and sketch (used for Kitchen Cabinet Lighting)

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

Thanks Tomas. Freeing up another PWM pin is certainly helpful :wink:

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 :wink:

Let me know if you want to collaborate on this…

Best,
Bruce

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.

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:

[ul][li]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.[/li]
[li]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)[/li]
[li]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.[/li]
[li]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. [/li]
[li]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.[/li][/ul]

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

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 → Jerome Bernard: 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

@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

[quote=“Vodden, post:26, topic:179597”]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. [/quote]

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

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.

@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…

@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

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?

[quote=“Vodden, post:30, topic:179597”]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?[/quote]

MySensors currently supports two Ethernet shields - you can find more information here - http://www.mysensors.org/build/vera#building-an-ethernet-connected-gateway

I have a Vera 3 so I opted for a USB gateway because that was all we originally supported. Thanks to the community help, we can now support two Ethernet shields. If you build an Ethernet gateway, you can use an Arduino Mini because you won’t need the built-in USB that the Nano provides.

You should checkout the MySensors Store Store | MySensors - Create your own Connected Home Experience - contains a number of useful links and if you click through, it helps to fund our community-sponsored operation.

Yes, the button is for inclusion.

Thanks,
Bruce

I am purchasing everything thru the mysensors.org store, with the single exception of the enclosure. I am going to make the one Ethernet shield work for me in that enclosure just to be sure I am 100% supported.

I’ve probably spent 8 hours between the Arduino threads on MCV and the mysensors.org website in the past 2 days, the support is incredible!

Kudos

THANKS! We appreciate any help we can get.

UPDATE:

I have finally purchased everything I need for this little adventure. Plus a bunch of surplus that I’m sure I will use up on future projects, all for under $100! Easily enough kit to build 6 child boards and one gateway. I changed my mind on a few things, I decided to use the Nano for a gateway after looking at your post. It looks pro as well. I may have pulled the trigger a little too soon on the radio voltage regulator, purchasing 5-AMS1117 units, but after checking the spec sheet may not work too well with a 12V input, so I spent another $6 on the LE33ACZ units you opted for. I’m guessing I won’t have everything until mid May, but I’ve got plenty of installing to do until then.

Will keep you posted!

I’m waiting for the fabrication and delivery of some circuits I put together for Nano and Mini Pro based sensors…one of which is a RGBW board…which with the sketches on here could be used as RGBW or 4 dimmer channels for any single color strips.

I’ll post pics of the boards, both raw form and with components soldered on. They should be done at the fab around Apr 20, then shipped to me. Then I’ll put them to a test with my system.

I made a power board that will take 12VDC in and has the 12V pass through for the LED strips and also has 5V and 3.3V outputs too.

The RGBW board also breaks out the remaining two digital pins (D7 and D8) so you could add sensors like motion or magnetic switches to control the lights.

the RGB strip and the White strip are screw terminals…

Ross, that PCB design is wweet! :slight_smile: :slight_smile: :slight_smile:

Awesome!

Here’s a 4-channel LED control board layout for existing setups…this one doesn’t house the Arduino + WiFi nor does it have the power regulators…

6 pins for input: 4 channels (RGBW) and 2 power (12V and GND)

Compact board taking 4 MOSFETS, 4 of the 2-screw terminals, 8 resistors and 6 header pins (group of 4 and 2)

I haven’t ordered any prototypes of these yet…will cost $8 to get 3 boards made, then the cost of the parts.

Approx 1.35" x 1.35" (34mm x 34mm)

Really nice Ross!

This forum never ceases to amaze me!

Custom PCB for this project alone? WOW!

I’m guessing that Ross should have ordered more than 4, he could probably be taking orders for them right now…

They would also be effective for one color LED applications too, so I would take 6 of them right now if they were for sale ;D

Uber cool.

Nice work @rosskinard