We have moved at community.getvera.com

Author Topic: RGB(W) arduino device  (Read 25035 times)

Offline Derek Macias

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
Re: RGB(W) arduino device
« Reply #15 on: January 17, 2014, 11:52:13 am »
Is it teensy 3.0 or 3.1 cause I think the memory is 16k vs 64k.

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #16 on: February 14, 2014, 05:08:10 am »
Has anyone else made any progress on this?

I have just finished the hardware part and are using a simple sketch to test the hardware.

Now since I chose to make a 4 channel RGBW type I would need to free up the pin 9 to be used for one of them. (pin 9 is currently used for radio as the Radio Chip Enable)
So how do I change the Radio Chip Enable to use pin 4???
Any help would be appreciated.

- Tomas

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: RGB(W) arduino device
« Reply #17 on: February 14, 2014, 05:13:29 am »
So how do I change the Radio Chip Enable to use pin 4???
Any help would be appreciated.

Just change the first argument to the constructor if the MySensor library.

Instead of:
Code: [Select]
Sensor gw(9, 10);
do
Code: [Select]
Sensor gw(4, 10);

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #18 on: February 14, 2014, 05:18:01 am »
Bah, thanks hek. I newer would have thought it was that easy...

Now if anyone has an example sketch of a dimmer device it would save me a ton of time to finish the rest of the code.
- Tomas

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: RGB(W) arduino device
« Reply #19 on: February 14, 2014, 05:33:53 am »
Code: [Select]
// Present the dimmer device (one for each channel)
gw.sendSensorPresentation(<childId>, S_DIMMER);

Look at the Relay-example sketch on how to listen to values coming from Vera-side. For dimmer level check the V_DIMMER-variable of the child-device you created above.
« Last Edit: February 14, 2014, 05:38:32 am by hek »

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #20 on: February 14, 2014, 05:50:08 am »
Keep getting surprised how simple it is again and again.

Comments on the sketch please :D (so that I can learn how to make these things correctly)

EDIT: I just noticed that the variable V_DIMMER is a value between 0-100 right? This I need to take in to account also
« Last Edit: February 28, 2014, 01:45:03 am by korttoma »
- Tomas

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: RGB(W) arduino device
« Reply #21 on: February 14, 2014, 06:04:06 am »
EDIT: I just noticed that the variable V_DIMMER is a value between 0-100 right? This I need to take in to account also
Yep,

Other that that I give you green light to push the upload button and launch your new RGBW controller ;)

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #22 on: February 14, 2014, 06:13:35 am »
not yet, I found a bug in it :D

I included some code that would take in to account if the different colors have different Luminosity and you would like to harmonize them but in the analog write I just use the one dedicated for RED color

analogWrite(message.header.childId, 256*incomingDimmerStatus/100 * brightr/256);

I guess I will remove this code for now...
- Tomas

Offline cubs2b23

  • Full Member
  • ***
  • Posts: 102
  • Karma: +2/-0
Re: RGB(W) arduino device
« Reply #23 on: February 14, 2014, 09:45:37 am »

I have just finished the hardware part and are using a simple sketch to test the hardware.


Korttoma,

Would you mind giving a quick hardware rundown for this project. I've been looking at trying to add some RGBW lights recently and I'm curious if this is a better/cheaper solution.

Thanks

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #24 on: February 14, 2014, 12:32:00 pm »
Hardware is as simple as a transistor and a resistor per channel. I got the idea from here -> http://www.jerome-bernard.com/blog/2013/01/12/rgb-led-strip-controlled-by-an-arduino/

Transistors: IRLZ44N
Resistors 10kohm
- Tomas

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +30/-1
Re: RGB(W) arduino device
« Reply #25 on: February 14, 2014, 03:28:53 pm »
I've also built a simple single-channel LEDStripDimmer circuit and sketch for a Warm White LED strip that I am going to mount under my kitchen cabinets. I will share everything here once I complete it beyond the prototyping stage.   
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 cubs2b23

  • Full Member
  • ***
  • Posts: 102
  • Karma: +2/-0
Re: RGB(W) arduino device
« Reply #26 on: February 14, 2014, 04:30:16 pm »
I know this is a bit out of scope but where is everyone getting their rgbw strips from?

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #27 on: February 15, 2014, 06:49:39 am »
- Tomas

Offline Entropy512

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: RGB(W) arduino device
« Reply #28 on: February 16, 2014, 09:20:36 pm »
I'we been looking in to this RGB(W) a bit today and it seems there are not enought PWM outputs on the Pro mini for all four channels.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

Only 3,5 and 6 are free since the radio is using 9,10 and 11.

I guess the easiest solution would be to have a separate arduino for white using a normal dimmer sketch and separate arduino for RGB sketch.
Unless there is a easy way to free one more PWM from the radio side.

Any thoughts on this?
Hello all - I'm new to Vera but not new to AVRs at all here.

There are a couple of options for this:
1)  Atmel has a good app note on low-jitter efficient software PWM.  You can achieve reasonable dimming performance on any I/O pin, I've gotten up to 8 channels on a MegaXX8.  Bad news is I don't know if anyone has implemented this using the Arduino development environment - but you can most definitely achieve this using avr-gcc (FYI, it's perfectly feasible to program Arduino hardware with any other AVR development environment, I use avr-gcc all the time.)  An example of 12-bit software PWM (a bit more than that - the PWM engine ran at 8 bits but was dithered using a sigma-delta modulator) with an 8-bit-to-12-bit gamma lookup table running on an ATTinyX5 is at https://github.com/Entropy512/I2C_RGB - I have some HSV to RGB translation code somewhere, I can't remember if I did it node-side or controller-side.  The code above was never very reliable because the Tiny's USI makes implementing a reliable I2C slave a nightmare - but since you would be using some other interface than I2C-via-USI, you'd just be using the dimming stuff which was pretty solid.
2)  There are a lot of good dimmer chips out there with multichannel PWM.  The PCA9635 is really easy to work with (other than being an SOIC, but Sparkfun sells some great SOIC adapters.) - An example of driving a 9635 is at https://github.com/Entropy512/DMX_PCA9635

The above two projects are currently pretty much abandoned, I wound up too busy with other things, and the I2C-RGB thing was superseded by the far cheaper WS2801 nodes.

(offtopic question - how do you keep the forum's insistence on no less than 4 verification questions per post from driving you insane?)

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #29 on: February 28, 2014, 01:47:26 am »
Here is the finished RGBW sketch if someone wants it...



- Tomas