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. AC diming

AC diming

Scheduled Pinned Locked Moved My Project
16 Posts 6 Posters 7.2k Views 4 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.
  • C Offline
    C Offline
    csa02221862
    wrote on last edited by
    #3

    Yes, they show the diagram for the Arduino and the script on the site.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thomasdc
      wrote on last edited by
      #4

      https://www.domoticz.com/forum/viewtopic.php?f=38&t=8033

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thomasdc
        wrote on last edited by thomasdc
        #5

        hi!

        after long searching and trying i managed to Build an 'MySensors' AC dimming node.
        I bought this:
        http://www.ebay.com/itm/4CH-AC-Dimmer-Module-Controller-Board-ARDUINO-RASPBERRY-Compatible-50-60Hz-/121752461158?ssPageName=ADME:X:RTQ:US:1123
        and i use it to control my lightning.

        regards, Thomas

        It was working for 1 dimmer but now im am updating the code for '4' dimmers but i am having trouble with understanding...
        this is the code so far:

        
        /*
        this is based on the sketch from Quocanhcgd 
        link: http://forum.mysensors.org/topic/1316/ac-dimmer-with-openhab
        
        Tested With Domoticz, working fine 220V 50Hz
        
        AC Light Control
        Uses up and down buttons to set levels
        makes use of a timer interrupt to set the level of dimming
        */
        #include <SPI.h>
        #include <MySensor.h>  
        #include <TimerOne.h>
        
        #define SN "AC Dimmer control"
        #define SV "1.0"
        #define NODE_ID 30  //change to a number to assign a specific ID
        #define FADE_DELAY 18  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
        #define FADE_PERCENTAGE 5 //The percentage the fade level will be changed when a button is pressed
        volatile int i=0;               // Variable to use as a counter of dimming steps. It is volatile since it is passed between interrupts
        volatile int j=0;  
        volatile int k=0;  
        volatile int l=0;  
        volatile boolean zero_cross=0;  // Flag to indicate we have crossed zero
        int AC_pin1 = 4;                 // Output to Opto Triac
        int AC_pin2 = 5;  
        int AC_pin3 = 6;  
        int AC_pin4 = 7;  
        
        int freqStep = 75;              // This is the delay-per-brightness step in microseconds. It allows for 128 steps
                                        // If using 60 Hz grid frequency set this to 65
        MySensor gw;
        //Tuy chinh lai
        static int currentLevel1 = 128;  // Current dim level...
        static int currentLevel2 = 128;  // Current dim level...
        static int currentLevel3 = 128;  // Current dim level...
        static int currentLevel4 = 128;  // Current dim level...
        
        uint8_t fadeLevel1 = 128; //used to store the fade level when using the buttons
        uint8_t fadeLevel2 = 128:
        uint8_t fadeLevel3 = 128;
        uint8_t fadeLevel4 = 128:
        
        MyMessage dimmer1Msg(AC_pin1, V_DIMMER);
        MyMessage light1Msg(AC_pin1, V_LIGHT);
        MyMessage dimmer2Msg(AC_pin2, V_DIMMER);
        MyMessage light2Msg(AC_pin2, V_LIGHT);
        MyMessage dimmer3Msg(AC_pin2, V_DIMMER);
        MyMessage light3Msg(AC_pin3, V_LIGHT);
        MyMessage dimmer4Msg(AC_pin4, V_DIMMER);
        MyMessage light4Msg(AC_pin4, V_LIGHT);
        
        void setup() {  // Begin setup
          Serial.begin(115200);
          /// - Setup Mysensors
          Serial.println( SN ); 
          gw.begin( incomingMessage,  NODE_ID, true);
          // Register the LED Dimmable Light with the gateway
            gw.present( AC_pin1, S_DIMMER );
            gw.present( AC_pin2, S_DIMMER );
            gw.present( AC_pin3, S_DIMMER );
            gw.present( AC_pin4, S_DIMMER );
             
          gw.sendSketchInfo(SN, SV);
          
          // Pull the gateway's current dim level - restore light level upon sendor node power-up
          gw.request( AC_pin1, V_DIMMER );
          gw.request( AC_pin2, V_DIMMER );
          gw.request( AC_pin3, V_DIMMER );
          gw.request( AC_pin4, V_DIMMER );
          
          //Setup AC PIN  // Set the Triac pin as output
           pinMode(AC_pin1, OUTPUT);  
           pinMode(AC_pin2, OUTPUT);
           pinMode(AC_pin3, OUTPUT);
           pinMode(AC_pin4, OUTPUT);
             
         // Set the Triac pin as output
         
          attachInterrupt(1, zero_cross_detect, RISING);    // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
          Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
          Timer1.attachInterrupt(dim_check, freqStep);      // Go to dim_check procedure every 75 uS (50Hz)  or 65 uS (60Hz)
          // Use the TimerOne Library to attach an interrupt
          
        }
        
        void zero_cross_detect() {    
          zero_cross = true;               // set flag for dim_check function that a zero cross has occured
          i=0;                             // stepcounter to 0.... as we start a new cycle
          digitalWrite(AC_pin1, LOW);
          digitalWrite(AC_pin2, LOW);
          digitalWrite(AC_pin3, LOW);
          digitalWrite(AC_pin4, LOW);
        }                                 
        
        // Turn on the TRIAC at the appropriate time
        // We arrive here every 75 (65) uS
        // First check if a flag has been set
        // Then check if the counter 'i' has reached the dimming level
        // if so.... switch on the TRIAC and reset the counter
        
        
        
        void dim_check1() {                   
          if(zero_cross == true) {              
            if(i>=fadeLevel1) {                     
              digitalWrite(AC_pin1, HIGH);  // turn on light       
              i=0;  // reset time step counter                         
              zero_cross=false;    // reset zero cross detection flag
            } 
            else {
              i++;  // increment time step counter                     
            }                                
          }    
        }
        
        void dim_check2() {                   
          if(zero_cross == true) {              
            if(j>=fadeLevel2) {                     
              digitalWrite(AC_pin2, HIGH);  // turn on light       
              j=0;  // reset time step counter                         
              zero_cross=false;    // reset zero cross detection flag
            } 
            else {
              j++;  // increment time step counter                     
            }                                
          }    
        }
        
        
        void dim_check3() {                   
          if(zero_cross == true) {              
            if(k>=fadeLevel3) {                     
              digitalWrite(AC_pin3, HIGH);  // turn on light       
              k=0;  // reset time step counter                         
              zero_cross=false;    // reset zero cross detection flag
            } 
            else {
              k++;  // increment time step counter                     
            }                                
          }    
        }
        
        void dim_check4() {                   
          if(zero_cross == true) {              
            if(l>=fadeLevel4) {                     
              digitalWrite(AC_pin4, HIGH);  // turn on light       
              l=0;  // reset time step counter                         
              zero_cross=false;    // reset zero cross detection flag
            } 
            else {
              l++;  // increment time step counter                     
            }                                
          }    
        }
        
                                    
        
        void loop() {  
            gw.process();
        }
        
        void incomingMessage(const MyMessage &message) {
          if (message.type == V_LIGHT || message.type == V_DIMMER) {
            
            //  Retrieve the power or dim level from the incoming request message
            int requestedLevel = atoi( message.data );
            
            // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
            requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
            
            // Clip incoming level to valid range of 0 to 100
            requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
            requestedLevel = requestedLevel < 0   ? 0   : requestedLevel;
            
           
            float percent_level;
            percent_level = 128 - (requestedLevel * 1.28);
            fadeToLevel( percent_level );
             Serial.print( "Changing level to " );
            Serial.print( requestedLevel );
            Serial.print( ", from " ); 
            Serial.println( currentLevel );
            // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
           //  gw.send(lightMsg.set(currentLevel > 0 ? 1 : 0));
             // gw.send( dimmerMsg.set(currentLevel) );
              }
        }
        
        /***
         *  This method provides a graceful fade up/down effect
         */
        void fadeToLevel( int toLevel ) {
          Serial.print("toLevel Value: ");
         Serial.println(toLevel);
          
          int delta = ( currentLevel - toLevel ) < 0 ? 1 : -1;
          Serial.print("delta Value: ");
         Serial.println(delta);
          while ( currentLevel != toLevel ) {
            currentLevel += delta;
        
         fadeLevel= ((int)currentLevel);
            delay( FADE_DELAY );
        
          }
          
        }
        
        
        

        I have trouble understanding this part:
        void incomingMessage(const MyMessage &message) {
        if (message.type == V_LIGHT || message.type == V_DIMMER)

        all 4 dimmers are type V_LIGHT and V_DIMMER
        how do i get the right dimmer value from the controller from each different dimmer?

        someone who can help me with the rest of the code?

        thanks!

        rvendrameR 1 Reply Last reply
        0
        • T thomasdc

          hi!

          after long searching and trying i managed to Build an 'MySensors' AC dimming node.
          I bought this:
          http://www.ebay.com/itm/4CH-AC-Dimmer-Module-Controller-Board-ARDUINO-RASPBERRY-Compatible-50-60Hz-/121752461158?ssPageName=ADME:X:RTQ:US:1123
          and i use it to control my lightning.

          regards, Thomas

          It was working for 1 dimmer but now im am updating the code for '4' dimmers but i am having trouble with understanding...
          this is the code so far:

          
          /*
          this is based on the sketch from Quocanhcgd 
          link: http://forum.mysensors.org/topic/1316/ac-dimmer-with-openhab
          
          Tested With Domoticz, working fine 220V 50Hz
          
          AC Light Control
          Uses up and down buttons to set levels
          makes use of a timer interrupt to set the level of dimming
          */
          #include <SPI.h>
          #include <MySensor.h>  
          #include <TimerOne.h>
          
          #define SN "AC Dimmer control"
          #define SV "1.0"
          #define NODE_ID 30  //change to a number to assign a specific ID
          #define FADE_DELAY 18  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
          #define FADE_PERCENTAGE 5 //The percentage the fade level will be changed when a button is pressed
          volatile int i=0;               // Variable to use as a counter of dimming steps. It is volatile since it is passed between interrupts
          volatile int j=0;  
          volatile int k=0;  
          volatile int l=0;  
          volatile boolean zero_cross=0;  // Flag to indicate we have crossed zero
          int AC_pin1 = 4;                 // Output to Opto Triac
          int AC_pin2 = 5;  
          int AC_pin3 = 6;  
          int AC_pin4 = 7;  
          
          int freqStep = 75;              // This is the delay-per-brightness step in microseconds. It allows for 128 steps
                                          // If using 60 Hz grid frequency set this to 65
          MySensor gw;
          //Tuy chinh lai
          static int currentLevel1 = 128;  // Current dim level...
          static int currentLevel2 = 128;  // Current dim level...
          static int currentLevel3 = 128;  // Current dim level...
          static int currentLevel4 = 128;  // Current dim level...
          
          uint8_t fadeLevel1 = 128; //used to store the fade level when using the buttons
          uint8_t fadeLevel2 = 128:
          uint8_t fadeLevel3 = 128;
          uint8_t fadeLevel4 = 128:
          
          MyMessage dimmer1Msg(AC_pin1, V_DIMMER);
          MyMessage light1Msg(AC_pin1, V_LIGHT);
          MyMessage dimmer2Msg(AC_pin2, V_DIMMER);
          MyMessage light2Msg(AC_pin2, V_LIGHT);
          MyMessage dimmer3Msg(AC_pin2, V_DIMMER);
          MyMessage light3Msg(AC_pin3, V_LIGHT);
          MyMessage dimmer4Msg(AC_pin4, V_DIMMER);
          MyMessage light4Msg(AC_pin4, V_LIGHT);
          
          void setup() {  // Begin setup
            Serial.begin(115200);
            /// - Setup Mysensors
            Serial.println( SN ); 
            gw.begin( incomingMessage,  NODE_ID, true);
            // Register the LED Dimmable Light with the gateway
              gw.present( AC_pin1, S_DIMMER );
              gw.present( AC_pin2, S_DIMMER );
              gw.present( AC_pin3, S_DIMMER );
              gw.present( AC_pin4, S_DIMMER );
               
            gw.sendSketchInfo(SN, SV);
            
            // Pull the gateway's current dim level - restore light level upon sendor node power-up
            gw.request( AC_pin1, V_DIMMER );
            gw.request( AC_pin2, V_DIMMER );
            gw.request( AC_pin3, V_DIMMER );
            gw.request( AC_pin4, V_DIMMER );
            
            //Setup AC PIN  // Set the Triac pin as output
             pinMode(AC_pin1, OUTPUT);  
             pinMode(AC_pin2, OUTPUT);
             pinMode(AC_pin3, OUTPUT);
             pinMode(AC_pin4, OUTPUT);
               
           // Set the Triac pin as output
           
            attachInterrupt(1, zero_cross_detect, RISING);    // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
            Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
            Timer1.attachInterrupt(dim_check, freqStep);      // Go to dim_check procedure every 75 uS (50Hz)  or 65 uS (60Hz)
            // Use the TimerOne Library to attach an interrupt
            
          }
          
          void zero_cross_detect() {    
            zero_cross = true;               // set flag for dim_check function that a zero cross has occured
            i=0;                             // stepcounter to 0.... as we start a new cycle
            digitalWrite(AC_pin1, LOW);
            digitalWrite(AC_pin2, LOW);
            digitalWrite(AC_pin3, LOW);
            digitalWrite(AC_pin4, LOW);
          }                                 
          
          // Turn on the TRIAC at the appropriate time
          // We arrive here every 75 (65) uS
          // First check if a flag has been set
          // Then check if the counter 'i' has reached the dimming level
          // if so.... switch on the TRIAC and reset the counter
          
          
          
          void dim_check1() {                   
            if(zero_cross == true) {              
              if(i>=fadeLevel1) {                     
                digitalWrite(AC_pin1, HIGH);  // turn on light       
                i=0;  // reset time step counter                         
                zero_cross=false;    // reset zero cross detection flag
              } 
              else {
                i++;  // increment time step counter                     
              }                                
            }    
          }
          
          void dim_check2() {                   
            if(zero_cross == true) {              
              if(j>=fadeLevel2) {                     
                digitalWrite(AC_pin2, HIGH);  // turn on light       
                j=0;  // reset time step counter                         
                zero_cross=false;    // reset zero cross detection flag
              } 
              else {
                j++;  // increment time step counter                     
              }                                
            }    
          }
          
          
          void dim_check3() {                   
            if(zero_cross == true) {              
              if(k>=fadeLevel3) {                     
                digitalWrite(AC_pin3, HIGH);  // turn on light       
                k=0;  // reset time step counter                         
                zero_cross=false;    // reset zero cross detection flag
              } 
              else {
                k++;  // increment time step counter                     
              }                                
            }    
          }
          
          void dim_check4() {                   
            if(zero_cross == true) {              
              if(l>=fadeLevel4) {                     
                digitalWrite(AC_pin4, HIGH);  // turn on light       
                l=0;  // reset time step counter                         
                zero_cross=false;    // reset zero cross detection flag
              } 
              else {
                l++;  // increment time step counter                     
              }                                
            }    
          }
          
                                      
          
          void loop() {  
              gw.process();
          }
          
          void incomingMessage(const MyMessage &message) {
            if (message.type == V_LIGHT || message.type == V_DIMMER) {
              
              //  Retrieve the power or dim level from the incoming request message
              int requestedLevel = atoi( message.data );
              
              // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
              requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
              
              // Clip incoming level to valid range of 0 to 100
              requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
              requestedLevel = requestedLevel < 0   ? 0   : requestedLevel;
              
             
              float percent_level;
              percent_level = 128 - (requestedLevel * 1.28);
              fadeToLevel( percent_level );
               Serial.print( "Changing level to " );
              Serial.print( requestedLevel );
              Serial.print( ", from " ); 
              Serial.println( currentLevel );
              // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
             //  gw.send(lightMsg.set(currentLevel > 0 ? 1 : 0));
               // gw.send( dimmerMsg.set(currentLevel) );
                }
          }
          
          /***
           *  This method provides a graceful fade up/down effect
           */
          void fadeToLevel( int toLevel ) {
            Serial.print("toLevel Value: ");
           Serial.println(toLevel);
            
            int delta = ( currentLevel - toLevel ) < 0 ? 1 : -1;
            Serial.print("delta Value: ");
           Serial.println(delta);
            while ( currentLevel != toLevel ) {
              currentLevel += delta;
          
           fadeLevel= ((int)currentLevel);
              delay( FADE_DELAY );
          
            }
            
          }
          
          
          

          I have trouble understanding this part:
          void incomingMessage(const MyMessage &message) {
          if (message.type == V_LIGHT || message.type == V_DIMMER)

          all 4 dimmers are type V_LIGHT and V_DIMMER
          how do i get the right dimmer value from the controller from each different dimmer?

          someone who can help me with the rest of the code?

          thanks!

          rvendrameR Offline
          rvendrameR Offline
          rvendrame
          Hero Member
          wrote on last edited by
          #6

          @thomasdc , as simple as

           // Channel Number
            int i = message.sensor;
          

          Home Assistant / Vera Plus UI7
          ESP8266 GW + mySensors 2.3.2
          Alexa / Google Home

          T 1 Reply Last reply
          0
          • rvendrameR rvendrame

            @thomasdc , as simple as

             // Channel Number
              int i = message.sensor;
            
            T Offline
            T Offline
            thomasdc
            wrote on last edited by thomasdc
            #7

            @rvendrame said:

            @thomasdc , as simple as

             // Channel Number
              int i = message.sensor;
            

            Thank you very much for the reply!
            can you expain it a litle more?

            so i have 4 dimmers:

            MyMessage dimmer1Msg(AC_pin1, V_DIMMER);
            MyMessage light1Msg(AC_pin1, V_LIGHT);
            MyMessage dimmer2Msg(AC_pin2, V_DIMMER);
            MyMessage light2Msg(AC_pin2, V_LIGHT);
            MyMessage dimmer3Msg(AC_pin2, V_DIMMER);
            MyMessage light3Msg(AC_pin3, V_LIGHT);
            MyMessage dimmer4Msg(AC_pin4, V_DIMMER);
            MyMessage light4Msg(AC_pin4, V_LIGHT);
            

            how do i get the vallue for each dimmer?
            so how do i get an 'int i' for channel one, an 'int j' for channel two, and so on ?
            where do i put the code? is it just behind the:

            void incomingMessage(const MyMessage &message) {
              if (message.type == V_LIGHT || message.type == V_DIMMER) {
            

            ? do i have to change something in the 'void incomming message' (see above)

            big thanks!

            1 Reply Last reply
            0
            • korttomaK Offline
              korttomaK Offline
              korttoma
              Hero Member
              wrote on last edited by korttoma
              #8

              My RGBW sketch is basically 4 dimmers also, take a look in this thread:

              http://forum.mysensors.org/topic/1939/scripting-scenes-for-rgb-strip-best-way-to-control-mysensors-rgbw-node-from-vera/6

              • Tomas
              T 1 Reply Last reply
              0
              • korttomaK korttoma

                My RGBW sketch is basically 4 dimmers also, take a look in this thread:

                http://forum.mysensors.org/topic/1939/scripting-scenes-for-rgb-strip-best-way-to-control-mysensors-rgbw-node-from-vera/6

                T Offline
                T Offline
                thomasdc
                wrote on last edited by
                #9

                @korttoma said:

                My RGBW sketch is basically 4 dimmers also, take a look in this thread:

                http://forum.mysensors.org/topic/1939/scripting-scenes-for-rgb-strip-best-way-to-control-mysensors-rgbw-node-from-vera/6

                thanks for the reply!

                I dont really get your code... you receive a byte from the controller? / you use a 'mode' to set your dimmers? my dimmers are 4 induvidual dimmers and dont have to work together ..

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  csa02221862
                  wrote on last edited by
                  #10

                  Another way to go is to use something like this and just convert everything to 12/24v dc. You can upgrade your lighting as you go and much easier and safer than AC dimming. If coarse there is still the ceiling fan to deal with. I will probably do that with an IR blaster.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    csa02221862
                    wrote on last edited by
                    #11

                    Forgot the link.....

                    http://www.12vmonster.com/products/ac-dc-12-volt-to-24-volt-12w-60x-5050-cluster-led-light-bulb-e26-e27-screw-fitting-lamp?variant=379155053

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      thomasdc
                      wrote on last edited by
                      #12

                      but anyway how to get the different dimmer value's from the controller stays the same ;) and i am still troubling on that :s

                      1 Reply Last reply
                      0
                      • korttomaK Offline
                        korttomaK Offline
                        korttoma
                        Hero Member
                        wrote on last edited by
                        #13

                        Just ignor the mode related code, you probably dont need that. I allso have 4 individual dimmers they just happen to be connected to a RGBW Led strip. Same same but different.

                        • Tomas
                        1 Reply Last reply
                        0
                        • korttomaK Offline
                          korttomaK Offline
                          korttoma
                          Hero Member
                          wrote on last edited by
                          #14

                          Simplified the sketch code a bit. Here is an example how you can control 4 individual dimmers:

                          // Example sketch showing how to control RGBW LED Strip.
                          
                          //IMPORTANTE NOTE!!! one of the "radio" pins has been moved from pin 9 to pin 4 because the White is connected to pin 9 because only 3,5,6 and 9 are PWM outputs!!!!
                          
                          // This code should generate 4 Dimmer devices in Vera so you can control the RED, GREEN, BLUE and WHITE individualy
                          
                          #define SN "RGBW"
                          #define SV "1.2"
                          
                          #include <MySensor.h>
                          #include <SPI.h>
                          
                          
                          #define NODE_ID AUTO
                          
                          #define RED       3 // pin for red LED
                          #define GREEN     5 // pin for green 
                          #define BLUE      6 // pin for blue
                          #define WHITE     9 // pin for white 
                          
                          #define RF24_CE_PIN		4	//<-- NOTE!!! (4,10) and NOT (9,10)
                          #define RF24_CS_PIN		10
                          #define RF24_PA_LEVEL	RF24_PA_MAX
                          
                          MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL);
                          
                          MySensor gw(transport);
                          
                          void setup()
                          {
                          	
                          	gw.begin(setDimmerStatus, NODE_ID);
                          	
                          	// Send the Sketch Version Information to the Gateway
                          	gw.sendSketchInfo(SN, SV);
                          	// Register all sensors to gw (they will be created as child devices)
                          	gw.present(RED, S_DIMMER);
                          	gw.present(GREEN, S_DIMMER);
                          	gw.present(BLUE, S_DIMMER);
                          	gw.present(WHITE, S_DIMMER);
                          
                          
                          	pinMode(RED, OUTPUT);
                          	pinMode(GREEN, OUTPUT);
                          	pinMode(BLUE, OUTPUT);
                          	pinMode(WHITE, OUTPUT);
                          	
                          	
                          
                          	//Get values from RAM and write to outputs
                          	analogWrite(RED, 255 * gw.loadState(RED) / 100);
                          	analogWrite(GREEN, 255 * gw.loadState(GREEN) / 100);
                          	analogWrite(BLUE, 255 * gw.loadState(BLUE) / 100);
                          	analogWrite(WHITE, 255 * gw.loadState(WHITE) / 100);
                          
                          }
                          
                          void loop()
                          {
                          	gw.process();
                          	
                          	
                          }
                          
                          void setDimmerStatus(const MyMessage &message)
                          {
                          		
                          	if (message.type == V_DIMMER)
                          	{
                          		uint8_t incomingDimmerStatus = message.getByte();
                          
                          		analogWrite(message.sensor, 255 * incomingDimmerStatus / 100);
                          		gw.saveState(message.sensor, message.getByte()); //Save value to RAM
                          
                          	}
                          		
                          }```
                          • Tomas
                          1 Reply Last reply
                          0
                          • FotoFieberF Offline
                            FotoFieberF Offline
                            FotoFieber
                            Hardware Contributor
                            wrote on last edited by
                            #15

                            Today I played with my AC dimmer
                            http://forum.mysensors.org/topic/1316/ac-dimmer-with-openhab/3

                            It is very similar to the one reference above (but maybe a little bit cheaper :) ).

                            Good news: it is working fine with normal light bulbs and halogen tubes.

                            Bad news: it doesn't work with the high voltage LED tubes I testetd.

                            Has anybody a recommendation for a dimmable LED tube (E27/E17 230 V) working with the setup from this thread?

                            1 Reply Last reply
                            0
                            • rvendrameR Offline
                              rvendrameR Offline
                              rvendrame
                              Hero Member
                              wrote on last edited by
                              #16

                              @FotoFieber , I use some 230V dimmable leds that I bought from IKEA in Germany about 1 year ago and and they work good. Some are Philips and some are IKEA-branded.
                              Most important is the 'dimmable' word on them. Most of current led drivers are not designed for AC dimming, as this increase the unit costs (usually the driver is more expensive than the leds itself)...

                              Home Assistant / Vera Plus UI7
                              ESP8266 GW + mySensors 2.3.2
                              Alexa / Google Home

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


                              13

                              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