RGBW Example


  • Hardware Contributor

    Hi,

    I have read in the last patchnotes that rgb(w) leds are now officially supported. How do I use this type of sensor (or actor?!)? Are there any examples or texts about this?
    Thanks for the help!



  • Hi,
    +1
    Especially because numbers of PWM outputs on arduino is limited with NRF24 connections.


  • Hardware Contributor

    The "hardware" part isn't really a problem for me (once I am done with my current project I might write a tutorial for that). Also @Gefkuz: you can use software pwm in most cases if you don't have enough PWM pins. In this case only 3 are left, so I guess you would need one more on the arduino pro mini.

    My problem is more on the software/protocol side. What kind of messages do I need to send, so that mySensors (and domoticz 😉 ) does understand my message. Does it work like the dimmer example, only with 3/4 dimmers?


  • Admin

    Not sure Homeseer-plugin supports the new RGB(W) device types introduced in 1.5. If so the dimmer values is sent to the node using a ASCII hex value FF0000 (== red).

    Here is an sketch which presents 3-dimmer devices for the controller and handles the incoming messages from controller.
    https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/examples/RGB-3D/RGB-3D.ino


  • Hardware Contributor

    Thanks for that example. Looks like domoticz also supports it. I will have to try that soon.



  • I hope you will like it, dimoticz not fully support S_RGB_LIGHT yet but this sketch use three dimmers and one on/off for start/stop rgb color cycle. Work just perfect. 🙂 thanks hek to share it.


  • Hardware Contributor

    Which sketch do you mean? The one hek posted? The one in the post you linked is only displaying the values it gets...



  • I was mean mine 😄 RGB-3D.ino.

    howto, sry for french thread but screenshots are useful..

    you can try gizmocuz test sketch like I done, but as you can read (link posted) it's not usable yet

    ps: why posting in homeseer controler section, if you use domoticz ?


  • Hardware Contributor

    Guess I will have to see how good my french still is^^

    Good question actually... I don't know why this is in the homeseer section. I defenitly intended it to bin the the domoticz section. Could someone move this?

    Anyways, I got it to work with domoticz only partially. It shows up as an RGBW switch but you can only select RGB colors (where do you get the white part from?) and it seems like only on and off commands reach the sensor. No new color values.
    I will keep trying though.


  • Hardware Contributor

    V_RGBW seems to be working. I will post my code once one more problem is solved:
    I do get a new hex string from the server on the arduino side... how do I break that up into 4x 0..255 values to control the pwm pins? I found some hints to use bit shifting, but I am unsure how to use that. Any ideas?

    Example:

    void incomingMessage(const MyMessage &message) {
    
    // h = hex value
    // message = e.g. (h) #112233AB
    redval = ?; // h11 => 17
    greenval = ?; // h22 => 34
    blueval = ?; // h33 = 51
    whiteval = ?; //AB = 171
    
    analogWrite(RED_PIN, redval);     
    analogWrite(GREEN_PIN, greenval);
    analogWrite(BLUE_PIN, blueval);
    analogWrite(WHITE_PIN, whiteval);
    
    }
    


  • i just built an rgb led light last weekend, so i would like to see get the code working as rgb vs 3 dimmers.

    i did a quick google i found this http://stackoverflow.com/questions/23576827/arduino-convert-a-sting-hex-ffffff-into-3-int which seems to be what your looking for with 3 values, i havent had a chance to test it or expand it to 4 values.

    @LastSamurai anychance you would be willing to share what you have so far?


  • Hardware Contributor

    I surely would, but I sadly haven't had the time to do more testing. Perhaps this weekend. I posted my own question on stackoverflow and it seems like I have found a solution (although not tested by me yet).
    Domoticz with V_RGBW worked though when I first tried it. With that part of the code you should be able to get it up and running.



  • To convert a hex string to elementary colors, you have to do, something like that :

    1- convert your string to unsigned 32 bit integer

       unsigned long value = strtol( hexstring, NULL, 16);
    

    2- assuming your integer is coded : 0xrrggbbww

       uint8_t redval = (value >> 24) & 0xFF ;
       uint8_t greenval = (value >> 16) & 0xFF ;
       uint8_t blueval = (value >> 8) & 0xFF ;
       uint8_t whiteval = value & 0xFF ;
    

  • Hardware Contributor

    Thanks for the help. I got it to work. I posted a link to the code over here.


Log in to reply
 

Suggested Topics

28
Online

11.2k
Users

11.1k
Topics

112.5k
Posts