Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Mi-Light controller for Mysensors

Mi-Light controller for Mysensors

Scheduled Pinned Locked Moved My Project
69 Posts 15 Posters 38.0k Views 27 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Iraklis KourtisI Offline
    Iraklis KourtisI Offline
    Iraklis Kourtis
    wrote on last edited by
    #39

    Hi Ted,

    Your project looks really amazing and I think it is exactly what I was looking for.
    I want to change my lighting at home. I am thinking of adding 8 LED strips that will be controlled by 2 x 4 Mi-Light remote controls and 2 x wifi bridges. As I would like to still be able to use the wall switches to turn them on/off I was thinking of using your solution. Do you think it will be feasible with your project? Also is there a way to reduce the wifi bridges to 1 instead of having 2?

    Thank you for this great project!

    Iraklis

    T 1 Reply Last reply
    0
    • Łukasz KostrzewaŁ Łukasz Kostrzewa

      I have new problem.
      I paired wrong bulb and now I can't unpair it.
      How to do that?
      Best regards

      T Offline
      T Offline
      ted
      wrote on last edited by
      #40

      @Łukasz-Kostrzewa
      sorry for the delay. you need to send the unpair command right after turning on the light. see https://hackaday.io/project/5888-reverse-engineering-the-milight-on-air-protocol

      1 Reply Last reply
      0
      • Iraklis KourtisI Iraklis Kourtis

        Hi Ted,

        Your project looks really amazing and I think it is exactly what I was looking for.
        I want to change my lighting at home. I am thinking of adding 8 LED strips that will be controlled by 2 x 4 Mi-Light remote controls and 2 x wifi bridges. As I would like to still be able to use the wall switches to turn them on/off I was thinking of using your solution. Do you think it will be feasible with your project? Also is there a way to reduce the wifi bridges to 1 instead of having 2?

        Thank you for this great project!

        Iraklis

        T Offline
        T Offline
        ted
        wrote on last edited by
        #41

        @Iraklis-Kourtis
        The controller is all you need to control the lights. It does not need wifi bridge

        1 Reply Last reply
        0
        • CrankyCoderC Offline
          CrankyCoderC Offline
          CrankyCoder
          wrote on last edited by
          #42

          Has this been converted to 2.0?

          Also, to build the controller for this i don't need anything special other than the arduino + nrf24l01 correct? I am VERY interested in this

          Home Automation Tinkerer
          www.CrankyCoder.net

          Controller: HomeAssistant in Kubernetes
          Gateway: MQTTClientGateway
          MySensors: 2.3

          1 Reply Last reply
          0
          • CrankyCoderC Offline
            CrankyCoderC Offline
            CrankyCoder
            wrote on last edited by
            #43

            i got 2 of my milight bulbs in today. Just wondering if anyone is still using this?

            Home Automation Tinkerer
            www.CrankyCoder.net

            Controller: HomeAssistant in Kubernetes
            Gateway: MQTTClientGateway
            MySensors: 2.3

            1 Reply Last reply
            0
            • Cliff KarlssonC Offline
              Cliff KarlssonC Offline
              Cliff Karlsson
              wrote on last edited by
              #44

              @Jason-Brunk said:

              n today. Just wondering if anyone is still using this?

              I would like to use this solution as it seams to be really great to have both a NRF/Mi-light-Repeater for every "node". But my skils are not enough to make this work with RGB-strips/bulbs and to have it working with domoticz. I am using the standard Domoticz way of controllign them using the original mi-light gateways and have also experimented with RF-link mi-light control.

              But my dream-scenario is that some nice coding-wiz will post a complete solution that even newbies can integrate this in this forum-thread. But I would not count on it.

              1 Reply Last reply
              0
              • CrankyCoderC Offline
                CrankyCoderC Offline
                CrankyCoder
                wrote on last edited by
                #45

                I have done a little bit of tinkering with it today. i have not cleaned up the code yet, but I have been able to get my arduino repeater to pair with one of the lights, and turn it on and off. My progress so far.

                • Convert to using the mysensor 2.0 framework
                • setup a bulb and paired
                • can turn bulb on and off

                My next step is to see if i can change colors on the bulb. The only thing I noticed is there is a small delay when switching the radio between the mysensors rf and the milight rf protocol. I may later see if it's possible to do 2 radios. But for now progress is being made with a repeater node.

                Once it's working, Ill see if i can post some samples of how I controlled it via mqtt. (I use openhab)

                If the original author of this sketch is interested I will provide him current code progress. Or I can throw it on github if anyone is interested in tinkering with it. I definitely want to get some documentation together for how to get multiple bulbs working on it.

                Home Automation Tinkerer
                www.CrankyCoder.net

                Controller: HomeAssistant in Kubernetes
                Gateway: MQTTClientGateway
                MySensors: 2.3

                1 Reply Last reply
                0
                • CrankyCoderC Offline
                  CrankyCoderC Offline
                  CrankyCoder
                  wrote on last edited by
                  #46

                  I have put my mods on github.

                  https://github.com/brunkj/MySensorsMiLight/

                  I have not been able to mess with it since the weekend. Still trying to get some info on the RGB part. If anyone wants to take a shot at it let me know if you make any progress :)

                  Home Automation Tinkerer
                  www.CrankyCoder.net

                  Controller: HomeAssistant in Kubernetes
                  Gateway: MQTTClientGateway
                  MySensors: 2.3

                  1 Reply Last reply
                  1
                  • CrankyCoderC Offline
                    CrankyCoderC Offline
                    CrankyCoder
                    wrote on last edited by
                    #47

                    spent some more time working on this. Still not having luck figuring out a what to send to the V_VAR1 to get the bulb to do anything

                    I can send simple on off for S_LIGHT V_STATUS

                    if (message.type == V_STATUS)
                      {
                        //Serial.println("triggered V_STATUS");
                        mlr.begin();
                    
                        // Change light status
                        Serial.println(message.getBool());
                        if ( message.getBool())
                        {
                          Serial.println("here");
                          // Serial.println("triggered ON");
                          sendCommand (outgoingPacket_on, sizeof(outgoingPacket_on));
                        }
                    
                    
                        else {
                          //  Serial.println("triggered off");
                          sendCommand(outgoingPacket_off, sizeof(outgoingPacket_off));
                        }
                        _begin();
                      }
                    

                    Easy. But the V_VAR1 on S_CUSTOM I can't figure out what to put in the payload

                    if (message.type == V_VAR1)
                      {
                        // Serial.println("triggered V_VAR1");
                        
                        incomingCommand = (char *)message.getCustom();
                        Serial.println((char *)message.getCustom());
                         mlr.begin();
                         Serial.println("#############");
                        for (int i=0; i<sizeof(outgoingPacket); i++)
                        { outgoingPacket[i] = 16*char_to_uint8_t(incomingCommand[i*2]) + char_to_uint8_t(incomingCommand[i*2+1]);
                          Serial.println(outgoingPacket[i]);
                          }
                        Serial.println("#############");
                        Serial.write(outgoingPacket, 7);
                        sendCommand(outgoingPacket, sizeof(outgoingPacket));
                        _begin();
                      }
                    
                    

                    I have referenced the hacking milight protocol pages and many other, I just can't seem to get it right to get my bulb to do anything.

                    Anyone want to take a shot at it? or have payload data I could try?

                    full sketch

                    #define MY_DEBUG 
                    #define MY_RADIO_NRF24
                    #define MY_REPEATER_FEATURE
                    #include <MyConfig.h>
                    #include <MySensors.h>
                    
                    #include <SPI.h>
                    #define CE_PIN 9     //CE and CSN pin for nrf24 radio
                    #define CSN_PIN 10
                    #include <nRF_24L01.h>
                    #include <avr/power.h>
                    #include <printf.h>
                    
                    #include "PL1167_nRF24.h"
                    #include "MiLightRadio.h"
                    
                    
                    #define NODE_ID 100
                    #define mi_command_repeat 30   //# of times to resend the command to bulb
                    
                    
                    
                    
                    RF_24 mi_radio(CE_PIN, CSN_PIN);
                    PL1167_nRF24 prf(mi_radio);
                    MiLightRadio mlr(prf);
                                                           // B0-176   F2-242    EA-234    6D    B0    02    f0
                    static uint8_t outgoingPacket_on[7] = { 0xB0, 0xF2, 0xEA, 0x6D, 0x91, 0x03, 0x00};  //the first three #s are remote ID, replace with yours
                    static uint8_t outgoingPacket_off[7] = { 0xB0, 0xF2, 0xEA, 0x04, 0x91, 0x04, 0x00};
                    uint8_t outgoingPacket[7];
                    
                    #define sizeofincomingCommand 15 //command comes in text form of 7 uint8_t, with an additional NULL at end
                    
                    char *incomingCommand;    //array for incoming command
                    
                     
                    boolean mi_radio_state = false;
                    void presentation()  
                    {  
                      //Send the sensor node sketch version information to the gateway
                      sendSketchInfo("Milight controller", "1.0");
                    }
                    
                    void setup()
                    {  
                      
                       //clock_prescale_set(clock_div_2);     //for a barebone atmega328p, this  will make the CPU running at 4MHz.
                      //Serial.begin(115200);
                      // The third argument enables repeater mode.
                    
                      //Send the sensor node sketch version information to the gateway
                      present(0, S_LIGHT);
                      present(1, S_CUSTOM);
                    
                    
                    
                    }
                    
                    
                    
                    
                    void receive(const MyMessage &message) {
                      // The command will be transmitted in V_VAR1 type, in the following 7 byte format: ID1 ID2 ID3 COLOR BRIGHTNESS COMMAND.
                      // see https://hackaday.io/project/5888-reverse-engineering-the-milight-on-air-protocol
                      Serial.println(message.type);
                      if (message.type == V_STATUS)
                      {
                        //Serial.println("triggered V_STATUS");
                        mlr.begin();
                    
                        // Change light status
                        Serial.println(message.getBool());
                        if ( message.getBool())
                        {
                          Serial.println("here");
                          // Serial.println("triggered ON");
                          sendCommand (outgoingPacket_on, sizeof(outgoingPacket_on));
                        }
                    
                    
                        else {
                          //  Serial.println("triggered off");
                          sendCommand(outgoingPacket_off, sizeof(outgoingPacket_off));
                        }
                        _begin();
                      }
                    
                    
                      if (message.type == V_VAR1)
                      {
                        // Serial.println("triggered V_VAR1");
                        
                        incomingCommand = (char *)message.getCustom();
                        Serial.println((char *)message.getCustom());
                         mlr.begin();
                         Serial.println("#############");
                        for (int i=0; i<sizeof(outgoingPacket); i++)
                        { outgoingPacket[i] = 16*char_to_uint8_t(incomingCommand[i*2]) + char_to_uint8_t(incomingCommand[i*2+1]);
                          Serial.println(outgoingPacket[i]);
                          }
                        Serial.println("#############");
                        Serial.write(outgoingPacket, 7);
                        sendCommand(outgoingPacket, sizeof(outgoingPacket));
                        _begin();
                      }
                    
                    //gw.begin(incomingMessage, NODE_ID, true);
                    
                    
                    
                    
                    }
                    
                    void sendCommand(uint8_t mi_Command[7], int sizeofcommand)
                    { for (int i = 0; i < mi_command_repeat; i++)
                      { mlr.write(mi_Command, sizeofcommand);
                      }
                    }
                    
                    uint8_t char_to_uint8_t(char c) 
                    {
                    	uint8_t i;
                    	if (c <= '9')
                    		i = c - '0';
                    	else if (c >= 'a')
                    		i = c - 'a' + 10;
                    	else
                    		i = c - 'A' + 10;
                    	return i;
                    }
                    

                    Home Automation Tinkerer
                    www.CrankyCoder.net

                    Controller: HomeAssistant in Kubernetes
                    Gateway: MQTTClientGateway
                    MySensors: 2.3

                    1 Reply Last reply
                    0
                    • n1ck1355N Offline
                      n1ck1355N Offline
                      n1ck1355
                      wrote on last edited by n1ck1355
                      #48

                      @Jason-Brunk
                      unfortunately i havnt got my own milight bulbs but for what i've seen on the
                      reverse engineered protocol page the payload must be something like
                      "07B0F2EA359001B9ACF9" for all on or
                      "07B0F2EA7D910FD4EC72" for green

                      or the part "07B0F2EA" must be the ID so the payload
                      is somethink like "359001B9ACF9" for all on and
                      "7D910FD4EC72" for green

                      1 Reply Last reply
                      0
                      • n1ck1355N Offline
                        n1ck1355N Offline
                        n1ck1355
                        wrote on last edited by
                        #49

                        @ted are you there and can get a hint please? :)

                        T 1 Reply Last reply
                        0
                        • n1ck1355N n1ck1355

                          @ted are you there and can get a hint please? :)

                          T Offline
                          T Offline
                          ted
                          wrote on last edited by
                          #50

                          @n1ck1355 @Jason-Brunk
                          sorry i'm been really busy with job recently. I used openhab to send the payload to V_VAR1 and S_CUSTOM. When I get home tonight, I'll post the openhab rule file so people can get some sense how to control color.

                          1 Reply Last reply
                          0
                          • n1ck1355N Offline
                            n1ck1355N Offline
                            n1ck1355
                            wrote on last edited by
                            #51

                            that's really great :) Thanks!

                            T 1 Reply Last reply
                            0
                            • n1ck1355N n1ck1355

                              that's really great :) Thanks!

                              T Offline
                              T Offline
                              ted
                              wrote on last edited by
                              #52

                              @n1ck1355
                              sorry for the delay. Here is what I learned from https://hackaday.io/project/5888-reverse-engineering-the-milight-on-air-protocol

                              Basically, the mi controller will receive text string and convert them into HEX format and send it to the bulb. The text string should be formatted as the following (+ added for easy of reading, no '+' in the actual command):

                              ID + color + brightness + button code + seq

                              The ID is the ID of the bulb to be controlled, it is six byte in ASCII but will be converted into 3 byte HEX before sending to the bulb.
                              color, brightness and button code are each 2 byte in ASCII and will be converted into 1 byte HEX and send to bulb.
                              Seq is 2 byte in ASCII but it appears that you can just use "00".

                              To change color, you need to send a color code (e.g.: "00"=purple, "1B"=red, "40"=yellow,e tc) and using button code "OF".
                              To change back to white, you use "04" as color code and "13" as button code.

                              The detailed button code definition can be found here:
                              https://cdn.hackaday.io/images/1224221432724803073.jpg

                              Hope this helps.

                              1 Reply Last reply
                              0
                              • n1ck1355N Offline
                                n1ck1355N Offline
                                n1ck1355
                                wrote on last edited by
                                #53

                                Thank you @ted :)
                                i already played with it and can turn the bulbs on/off. i will play around with your
                                information to make the other funktions work.

                                But what i see is that you cannot e.g. dim the bulbs softly from say 100% to 20% cause
                                that would be more commands behind each other. But the node must reset itself after
                                each command by calling _Begin() and that takes some time..
                                any suggestions to resolve that?

                                T 1 Reply Last reply
                                0
                                • n1ck1355N n1ck1355

                                  Thank you @ted :)
                                  i already played with it and can turn the bulbs on/off. i will play around with your
                                  information to make the other funktions work.

                                  But what i see is that you cannot e.g. dim the bulbs softly from say 100% to 20% cause
                                  that would be more commands behind each other. But the node must reset itself after
                                  each command by calling _Begin() and that takes some time..
                                  any suggestions to resolve that?

                                  T Offline
                                  T Offline
                                  ted
                                  wrote on last edited by
                                  #54

                                  @n1ck1355
                                  my only solution is to use two radios, one receives command from the gateway and the other sending command to the bulbs. it might be doable with just 1 arduino by using softSPI.

                                  Nca78N 1 Reply Last reply
                                  0
                                  • T ted

                                    @n1ck1355
                                    my only solution is to use two radios, one receives command from the gateway and the other sending command to the bulbs. it might be doable with just 1 arduino by using softSPI.

                                    Nca78N Offline
                                    Nca78N Offline
                                    Nca78
                                    Hardware Contributor
                                    wrote on last edited by
                                    #55

                                    @ted said:

                                    @n1ck1355
                                    my only solution is to use two radios, one receives command from the gateway and the other sending command to the bulbs. it might be doable with just 1 arduino by using softSPI.

                                    I don't see why you would need SoftSPI for that ? It should just need some change for CE and CSN pins for the NRF that is used to send data to the milights. I will try to find time to check that this week.

                                    1 Reply Last reply
                                    0
                                    • n1ck1355N Offline
                                      n1ck1355N Offline
                                      n1ck1355
                                      wrote on last edited by
                                      #56

                                      @Nca78 :

                                      did you have success with thw NRF boards connecting?

                                      Nca78N 1 Reply Last reply
                                      0
                                      • n1ck1355N n1ck1355

                                        @Nca78 :

                                        did you have success with thw NRF boards connecting?

                                        Nca78N Offline
                                        Nca78N Offline
                                        Nca78
                                        Hardware Contributor
                                        wrote on last edited by
                                        #57

                                        @n1ck1355 said:

                                        @Nca78 :

                                        did you have success with thw NRF boards connecting?

                                        Hello, unfortunately I had no time to test it, I was busy with my Livolo switch :P

                                        1 Reply Last reply
                                        0
                                        • Cliff KarlssonC Offline
                                          Cliff KarlssonC Offline
                                          Cliff Karlsson
                                          wrote on last edited by
                                          #58

                                          I just tried out openhab2, would it be easier controling the bulbs from openhab2 or do I still to do alot of "coding" on my own?

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          17

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular