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. livolo Glass Panel Touch Light Wall Switch + arduino 433Mhz

livolo Glass Panel Touch Light Wall Switch + arduino 433Mhz

Scheduled Pinned Locked Moved My Project
135 Posts 31 Posters 106.1k Views 44 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.
  • scalzS Offline
    scalzS Offline
    scalz
    Hardware Contributor
    wrote on last edited by scalz
    #19

    @Nca78 that's what I'm planning to do ;) you can't find cheaper for already cutted glass plate imho. I'm redesigning the box for 3d printing, and maybe sand and repeint the plate, I'm note sure yet as I don't really care about the button layout (I will use gesture).

    Nca78N 1 Reply Last reply
    0
    • Nca78N Nca78

      Hello, I just found out that Livolo is selling the glass plates (EU standard only, too bad for me :( ) alone on it's aliexpress shop. 3.72€ for square plate (1 or 2 switches), 6.24€ for double sized plate (up to 4 switches) and 8.77€ for triple size (up to 6 switches !).

      I have US(AU) sized switches here so I'm a bit screwed up, but I think I will try to order a double plate and put on top of one of my switches boxes which are a bit smaller.
      Check the "EU DIY Parts" category in the Livolo shop.

      http://www.aliexpress.com/item/Livolo-Luxury-White-Pearl-Crystal-Glass-80mm-80mm-EU-standard-Single-Glass-Panel-For-1-Gang/32484221458.html

      S Offline
      S Offline
      Samuel235
      Hardware Contributor
      wrote on last edited by
      #20

      @Nca78 - Very interesting, thank you for linking that! So any sort of capacitive touch sensor behind the button on this glass panel should be good to go. I think o.O I will have to see about ordering one to try out.

      @scalz - Fill us in with some more info and images regarding your gesture design ;)

      MySensors 2.1.1
      Controller - OpenHAB (Virtual Machine)
      Gateway - Arduino Mega MQTT Gateway W5100

      1 Reply Last reply
      0
      • scalzS scalz

        @Nca78 that's what I'm planning to do ;) you can't find cheaper for already cutted glass plate imho. I'm redesigning the box for 3d printing, and maybe sand and repeint the plate, I'm note sure yet as I don't really care about the button layout (I will use gesture).

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

        @scalz said:

        @Nca78 that's wat I'm planning to do ;) you can't find cheaper for already cutted glass plate imho. I'm redesigning the box for 3d printing, and maybe sand and repeint the plate, I'm note sure yet as I don't really care about the button layout (I will use gesture).

        It depends for the price, if there is a local maker here it can end up cheaper than on aliexpress.
        What sensor are you planning to use for the touch ? TTP22x for relative ease of soldering, or an hardcode 3x3mm MPR121 ?

        [edit] Just found cheaper panels here (for simple EU size, bigger sizes are more expensive), but maybe a bit less sexy
        http://www.aliexpress.com/store/product/3gang-white-small-glass-switch-panel-match-with-Bingo-Elec-frame-glass-or-aluminum-and-3gang/1157683_32394538766.html

        1 Reply Last reply
        1
        • scalzS Offline
          scalzS Offline
          scalz
          Hardware Contributor
          wrote on last edited by scalz
          #22

          @Nca78 yep. sure I thought about this. it depends also of the quantity, as locals are not always the cheaper, at least where I live lol. about the sensor, I use gesture (more hygienic and cool) so it's more complicated than common sensor. and no cheap eval board so I made mine and variant for those interested. but you will see, I will show sure ;)

          S 1 Reply Last reply
          3
          • scalzS scalz

            @Nca78 yep. sure I thought about this. it depends also of the quantity, as locals are not always the cheaper, at least where I live lol. about the sensor, I use gesture (more hygienic and cool) so it's more complicated than common sensor. and no cheap eval board so I made mine and variant for those interested. but you will see, I will show sure ;)

            S Offline
            S Offline
            Samuel235
            Hardware Contributor
            wrote on last edited by
            #23

            @scalz - Very very interested, might even make a purchase ;)

            @Nca78 - Thank you for that link for a price comparison, looks tempting.

            MySensors 2.1.1
            Controller - OpenHAB (Virtual Machine)
            Gateway - Arduino Mega MQTT Gateway W5100

            Nca78N 1 Reply Last reply
            0
            • S Samuel235

              @scalz - Very very interested, might even make a purchase ;)

              @Nca78 - Thank you for that link for a price comparison, looks tempting.

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

              @Samuel235 said:

              @Nca78 - Thank you for that link for a price comparison, looks tempting.

              You're welcome. I ordered the three size of plates to see how I can use them in my home. I will test with TTP and MPR121 and give a feedback.

              @scalz made me look for gesture sensors and I discovered the ADPS 9960, it was too tempting not to order one, can't wait to receive and play with it !

              S 1 Reply Last reply
              1
              • Nca78N Nca78

                @Samuel235 said:

                @Nca78 - Thank you for that link for a price comparison, looks tempting.

                You're welcome. I ordered the three size of plates to see how I can use them in my home. I will test with TTP and MPR121 and give a feedback.

                @scalz made me look for gesture sensors and I discovered the ADPS 9960, it was too tempting not to order one, can't wait to receive and play with it !

                S Offline
                S Offline
                Samuel235
                Hardware Contributor
                wrote on last edited by
                #25

                @Nca78 said:

                @scalz made me look for gesture sensors and I discovered the ADPS 9960, it was too tempting not to order one, can't wait to receive and play with it !

                I'm also now looking up these. Times like this i wished i had a workshop to manufacture things like a switch plate myself out of plexi with a gesture sensor behind with leds lighting the frosted plate up as you signal movements to the sensor.

                MySensors 2.1.1
                Controller - OpenHAB (Virtual Machine)
                Gateway - Arduino Mega MQTT Gateway W5100

                1 Reply Last reply
                0
                • scalzS Offline
                  scalzS Offline
                  scalz
                  Hardware Contributor
                  wrote on last edited by scalz
                  #26

                  @Samuel235 stop looking in my mind :) I have already some working proto though for the plate pcb ;) but I'm waiting a bit for posting vids, I have others projects to show running in vid before this one. or maybe I will show everything at same time. i don't know yet :) I miss a bit of time..

                  S 1 Reply Last reply
                  1
                  • scalzS scalz

                    @Samuel235 stop looking in my mind :) I have already some working proto though for the plate pcb ;) but I'm waiting a bit for posting vids, I have others projects to show running in vid before this one. or maybe I will show everything at same time. i don't know yet :) I miss a bit of time..

                    S Offline
                    S Offline
                    Samuel235
                    Hardware Contributor
                    wrote on last edited by
                    #27

                    @scalz said:

                    @Samuel235 stop looking in my mind :) I have already some working proto though for the plate pcb ;) but I'm waiting a bit for posting vids, I have others projects to show running in vid before this one. or maybe I will show everything at same time. i don't know yet :) I miss a bit of time..

                    Damn you! Stop stealing my aspirations! Please, just make sure you share the products with us!

                    MySensors 2.1.1
                    Controller - OpenHAB (Virtual Machine)
                    Gateway - Arduino Mega MQTT Gateway W5100

                    1 Reply Last reply
                    0
                    • scalzS scalz

                      I think if you want to reuse the livolo that won't be easy. I have one livolo, without radio and no dimmer. So it uses relay. I know about the mosfet version. I think mosfet is nice too.

                      I have already unpacked it and checked some electricals connection because I was thinking to hack it. But I think this is too much pain for maybe not great results.

                      On mine, the brain mcu is on the capacitive plate (a microchip mcu). I have not tried to access/change fw of the mcu though but I thought, well, I could do another plate and reuse relay board, easy!..but then there is the radio. Reuse the livolo one? some work, not the best perf, no state back.. Use my rfm69 radio (I prefer 868 than 433) ? I'm not sure the livolo can provide power I need etc... so it could put me on a tricky road for not great results, looking not good inside the box..

                      Too bad! Because my livolo is well built and I like the glass plate. I want the glass plate!! It's cheap and you have the whole enclosure.
                      So finally, I have a project in progress where I do everything from scratch, with glass plate and gesture, yep ;) but I don't know yet when it will be finished as I have a few other things to finish.

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

                      @scalz said:

                      On mine, the brain mcu is on the capacitive plate (a microchip mcu). I have not tried to access/change fw of the mcu though but I thought, well, I could do another plate and reuse relay board, easy!..but then there is the radio. Reuse the livolo one? some work, not the best perf, no state back.. Use my rfm69 radio (I prefer 868 than 433) ? I'm not sure the livolo can provide power I need etc... so it could put me on a tricky road for not great results, looking not good inside the box..

                      Hello, I have ordered one full livolo switch, single button with no radio.
                      And I think I will disagree with you on this :)

                      I've soldered some pins on the available headers (next to the 2*7 connector) and plugged a sensor on the GND and 3V pins.
                      The switch is still running fine, led on and I can switch the lights on and off. The sensor is running and sending data very reliably at the moment meaning even on the non-radio version of the switch the power is clean enough for NRF24 radio. This is true for both lights on and off.

                      It might not be true when using the 4 switches version with all relays on, but this is making me very confident about the 2/3 switches version which would fill my needs.
                      I'm using US sized switches also, so maybe (probably) the power supply is not the same on the EU sized switches that has a maximum of 2 relays.

                      0_1477888490554_IMAG1046.jpg

                      1 Reply Last reply
                      1
                      • Cristian ToneC Offline
                        Cristian ToneC Offline
                        Cristian Tone
                        wrote on last edited by
                        #29

                        this guy did some work on this:
                        https://www.youtube.com/watch?v=ykqv4bZ9zb0

                        Nca78N 1 Reply Last reply
                        0
                        • Cristian ToneC Cristian Tone

                          this guy did some work on this:
                          https://www.youtube.com/watch?v=ykqv4bZ9zb0

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

                          @Cristian-Tone said:

                          this guy did some work on this:
                          https://www.youtube.com/watch?v=ykqv4bZ9zb0

                          Yes I have seen it but it's a completely different concept. They reprogram the PIC on the sensor board so it will send data to a computer over serial. And last time I saw it they had to change the relays also to put 5V relays instead of 12V.
                          It's much cleaner to just replace the sensor board and communicate through radio...

                          Cristian ToneC 1 Reply Last reply
                          0
                          • Nca78N Nca78

                            @Cristian-Tone said:

                            this guy did some work on this:
                            https://www.youtube.com/watch?v=ykqv4bZ9zb0

                            Yes I have seen it but it's a completely different concept. They reprogram the PIC on the sensor board so it will send data to a computer over serial. And last time I saw it they had to change the relays also to put 5V relays instead of 12V.
                            It's much cleaner to just replace the sensor board and communicate through radio...

                            Cristian ToneC Offline
                            Cristian ToneC Offline
                            Cristian Tone
                            wrote on last edited by
                            #31

                            @Nca78 Indeed, I've done some more research on this too and I agree with you, it would have been nice though. :)

                            1 Reply Last reply
                            0
                            • DJONvlD Offline
                              DJONvlD Offline
                              DJONvl
                              wrote on last edited by
                              #32

                              это моя переделка китайского Livolo arduino+nrf24, красным на фото отмечено куда ставить перемычки на плату для повышения мощности блока питания в режиме ожидания,
                              3_1481003871578_IMG-20161127-WA0005.jpg 2_1481003871577_IMG-20161127-WA0003.jpg 1_1481003871577_IMG-20161127-WA0002.jpg 0_1481003871575_IMG-20161127-WA0001.jpg

                              1 Reply Last reply
                              1
                              • Nca78N Offline
                                Nca78N Offline
                                Nca78
                                Hardware Contributor
                                wrote on last edited by
                                #33

                                Hello @DJONvl could you post in English please ? :)
                                It looks interesting, are you hacking the touch pad signal to simulate user touch ? And the led voltage to know the current status ?

                                1 Reply Last reply
                                0
                                • DJONvlD Offline
                                  DJONvlD Offline
                                  DJONvl
                                  wrote on last edited by
                                  #34

                                  к сожалению не говорю по английски, вот код для ясности :smiley:

                                  #include <SPI.h>
                                  #include <MySensor.h>
                                  
                                  #include <Bounce2.h>
                                  #define sensor_PIN  6
                                  #define RELAY_PIN  A3  // Arduino Digital I/O pin number for relay 
                                  #define BUTTON_PIN  5  // Arduino Digital I/O pin number for button 
                                  #define CHILD_ID 1   // Id of the sensor child
                                  #define RELAY_ON 1
                                  #define RELAY_OFF 0
                                  
                                  Bounce debouncer = Bounce(); 
                                  int oldValue=0;
                                  bool state;
                                  bool sens;
                                  
                                  MySensor gw;
                                  MyMessage msg(CHILD_ID,V_LIGHT);
                                  
                                  void setup()  
                                  {  
                                    delay(2400);
                                    
                                    gw.begin(incomingMessage, AUTO, true);
                                  
                                    // Send the sketch version information to the gateway and Controller
                                   // gw.sendSketchInfo("Livolo", "1.0");
                                  
                                   // Setup the button
                                    pinMode(BUTTON_PIN,INPUT);
                                    pinMode(sensor_PIN,INPUT);
                                    // Activate internal pull-up
                                    digitalWrite(BUTTON_PIN,HIGH);
                                    
                                    // After setting up the button, setup debouncer
                                    debouncer.attach(BUTTON_PIN);
                                    debouncer.interval(5);
                                  
                                    // Register all sensors to gw (they will be created as child devices)
                                    gw.present(CHILD_ID, S_LIGHT);
                                    delay(1400);
                                    // Make sure relays are off when starting up
                                    digitalWrite(RELAY_PIN, RELAY_OFF);
                                    // Then set relay pins in output mode
                                    pinMode(RELAY_PIN, OUTPUT);   
                                        
                                    // Set relay to last known state (using eeprom storage) 
                                   // state = gw.loadState(CHILD_ID);
                                    //digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                                  state=false;
                                  }
                                  
                                  
                                  /*
                                  *  Example on how to asynchronously check for new messages from gw
                                  */
                                  void loop() 
                                  {
                                    gw.process();
                                    //debouncer.update();
                                    // Get the update value
                                    
                                   int value =digitalRead(sensor_PIN);
                                      if (value==1){
                                        state=true;
                                      }else{
                                        state=false;
                                      }
                                  
                                    if (value != oldValue) {
                                        gw.send(msg.set(state), true); // Send new state and request ack back
                                    }
                                    oldValue = value;
                                  } 
                                   
                                  void incomingMessage(const MyMessage &message) {
                                  
                                  
                                    if (message.type == V_LIGHT) {
                                       // Change relay state
                                      bool instate = message.getBool();
                                  
                                   while(instate!=state){
                                       digitalWrite(RELAY_PIN, RELAY_ON); 
                                       delay(60);
                                       digitalWrite(RELAY_PIN, RELAY_OFF);  
                                       delay(60);     
                                      int value =digitalRead(sensor_PIN);
                                      if (value==1){
                                        state=true;
                                      }else{
                                        state=false;
                                      }
                                   }    
                                      
                                  
                                     } 
                                  }
                                  
                                  1 Reply Last reply
                                  0
                                  • Cliff KarlssonC Offline
                                    Cliff KarlssonC Offline
                                    Cliff Karlsson
                                    wrote on last edited by
                                    #35

                                    Sorry if this already has been covered in the thread but I can't find the info. When looking at ebay it looks like the connectors are L = in, L1, = out (for one way). But how are the radio/touch etc powered? is there also a battery inside or can you power the switch without neutral wire?

                                    Nca78N 1 Reply Last reply
                                    0
                                    • Cliff KarlssonC Cliff Karlsson

                                      Sorry if this already has been covered in the thread but I can't find the info. When looking at ebay it looks like the connectors are L = in, L1, = out (for one way). But how are the radio/touch etc powered? is there also a battery inside or can you power the switch without neutral wire?

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

                                      @Cliff-Karlsson it takes the voltage from live wire only. It generates a light voltage drop and from there gets enough power to run the circuit.
                                      The downside is it constantly have to leak a bit of current through the live wire, so if you have a small light connected to it it might flicker. Livolo sells some small unit you can connect to your load and that will let the current pass and save your lights from premature death because of flickering. But it all depends on the light bulbs and also on the quality/efficiency of the switches.

                                      1 Reply Last reply
                                      1
                                      • TigroenotT Offline
                                        TigroenotT Offline
                                        Tigroenot
                                        wrote on last edited by Tigroenot
                                        #37

                                        There really is an opportunity to draw enough power from livolo internal circuits for atmega328 and a radio. With the great help of @DJONvl I managed to power up an arduino with nrf24 radio directly from the switch.
                                        But...
                                        I have a two button switch, and i tried to adopt the above scetch for my purpose (and the development version of the library) but got stuck... Can anyone please have a glance at my scetch and push me towards the right way? :)

                                        /**
                                         * The MySensors Arduino library handles the wireless radio link and protocol
                                         * between your home built sensors/actuators and HA controller of choice.
                                         * The sensors forms a self healing radio network with optional repeaters. Each
                                         * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                         * network topology allowing messages to be routed to nodes.
                                         *
                                         * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                         * Copyright (C) 2013-2015 Sensnology AB
                                         * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                         *
                                         * Documentation: http://www.mysensors.org
                                         * Support Forum: http://forum.mysensors.org
                                         *
                                         * This program is free software; you can redistribute it and/or
                                         * modify it under the terms of the GNU General Public License
                                         * version 2 as published by the Free Software Foundation.
                                         *
                                         *******************************
                                        */
                                        
                                        
                                        #define MY_RADIO_NRF24
                                        #define MY_REPEATER_FEATURE
                                        #include <MySensors.h>
                                        
                                        #define sensor1_PIN 5
                                        #define sensor2_PIN 6
                                        #define RELAY1_PIN 3  // Arduino Digital I/O pin number for relay 
                                        #define RELAY2_PIN 4 
                                        #define CHILD_ID_LIGHT1 1   // Id of the sensor child
                                        #define CHILD_ID_LIGHT2 2
                                        #define RELAY_ON 1
                                        #define RELAY_OFF 0
                                         
                                        int oldValue1=0;
                                        bool state1;
                                        bool sens1;
                                        int oldValue2=0;
                                        bool state2;
                                        bool sens2;
                                        
                                        //MySensor gw;
                                        MyMessage msg(CHILD_ID_LIGHT1,V_LIGHT);
                                        MyMessage msg2(CHILD_ID_LIGHT2,V_LIGHT);
                                        
                                        void setup()  
                                        {  
                                          delay(2400);
                                           pinMode(sensor1_PIN,INPUT);
                                           pinMode(sensor2_PIN,INPUT);
                                           digitalWrite(RELAY1_PIN, RELAY_OFF); // Make sure relays are off when starting up
                                           digitalWrite(RELAY2_PIN, RELAY_OFF); // Make sure relays are off when starting up
                                           pinMode(RELAY1_PIN, OUTPUT);         // Then set relay pins in output mode
                                           pinMode(RELAY2_PIN, OUTPUT);         // Then set relay pins in output mode
                                           state1=false;
                                           state2=false;
                                        }
                                         
                                        void presentation()  
                                        { 
                                          // Register all sensors to gw (they will be created as child devices)
                                          sendSketchInfo("Livolo", "1.2");
                                          present(CHILD_ID_LIGHT1, S_LIGHT);
                                          present(CHILD_ID_LIGHT2, S_LIGHT);
                                          delay(1400);
                                        }
                                        
                                        void loop() 
                                        {
                                        
                                         int value1 = digitalRead(sensor1_PIN);
                                            if (value1==1){
                                              state1=true;
                                            }else{
                                              state1=false;
                                            }
                                        
                                          if (value1 != oldValue1) {
                                              send(msg.set(state1), true); // Send new state and request ack back
                                          }
                                          oldValue1 = value1;
                                        
                                          int value2 = digitalRead(sensor2_PIN);
                                          if (value2==1){
                                              state2=true;
                                            }else{
                                              state2=false;
                                            }
                                        
                                          if (value2 != oldValue2) {
                                              send(msg2.set(state2), true); // Send new state and request ack back
                                          }
                                          oldValue2 = value2;
                                        } 
                                         
                                        void receive(const MyMessage &message) {
                                        
                                          if (message.type == V_LIGHT) {
                                             // Change relay state
                                            bool instate = message.getBool();
                                        
                                         while(instate!=state1){
                                             digitalWrite(message.sensor, RELAY_ON); 
                                             delay(30);
                                             digitalWrite(message.sensor, RELAY_OFF);  
                                             delay(30);     
                                            int value1 =digitalRead(sensor1_PIN);
                                            if (value1==1){
                                              state1=true;
                                            }else{
                                              state1=false;
                                            }
                                            int value2 =digitalRead(sensor2_PIN);
                                            if (value2==1){
                                              state2=true;
                                            }else{
                                              state2=false;
                                            }
                                         }    
                                            
                                        
                                           } 
                                        }
                                        
                                        

                                        The problem is in the receive()
                                        I need to destinguish the incoming state for each sensor child and set the instate value accordigly.

                                        Please, help, I didn't sleep for so long :)

                                        1 Reply Last reply
                                        0
                                        • TigroenotT Offline
                                          TigroenotT Offline
                                          Tigroenot
                                          wrote on last edited by
                                          #38

                                          Well, somehow I got over it :)

                                          Here is a working sketch for livolo two button switch:

                                          /**
                                           * The MySensors Arduino library handles the wireless radio link and protocol
                                           * between your home built sensors/actuators and HA controller of choice.
                                           * The sensors forms a self healing radio network with optional repeaters. Each
                                           * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                           * network topology allowing messages to be routed to nodes.
                                           *
                                           * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                           * Copyright (C) 2013-2015 Sensnology AB
                                           * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                           *
                                           * Documentation: http://www.mysensors.org
                                           * Support Forum: http://forum.mysensors.org
                                           *
                                           * This program is free software; you can redistribute it and/or
                                           * modify it under the terms of the GNU General Public License
                                           * version 2 as published by the Free Software Foundation.
                                           *
                                           *******************************
                                          */
                                          
                                          
                                          #define MY_RADIO_NRF24
                                          #define MY_REPEATER_FEATURE
                                          #include <MySensors.h>
                                          
                                          #define sensor1_PIN 5  //Pin to attach the indicator LED1
                                          #define sensor2_PIN 6   // LED2
                                          #define RELAY1_PIN 3  // Arduino Digital I/O pin number for relay 
                                          #define RELAY2_PIN 4 
                                          #define CHILD_ID_LIGHT1 1   // Id of the sensor child
                                          #define CHILD_ID_LIGHT2 2
                                          #define RELAY_ON 1
                                          #define RELAY_OFF 0
                                           
                                          int oldValue1=0;
                                          bool state1;
                                          int oldValue2=0;
                                          bool state2;
                                          
                                          MyMessage msg(CHILD_ID_LIGHT1,V_LIGHT);
                                          MyMessage msg2(CHILD_ID_LIGHT2,V_LIGHT);
                                          
                                          void setup()  
                                          {  
                                            delay(2400);
                                             pinMode(sensor1_PIN,INPUT);
                                             pinMode(sensor2_PIN,INPUT);
                                             digitalWrite(RELAY1_PIN, RELAY_OFF); // Make sure relays are off when starting up
                                             digitalWrite(RELAY2_PIN, RELAY_OFF); // Make sure relays are off when starting up
                                             pinMode(RELAY1_PIN, OUTPUT);         // Then set relay pins in output mode
                                             pinMode(RELAY2_PIN, OUTPUT);         // Then set relay pins in output mode
                                             state1=false;
                                          state2=false;
                                          }
                                           
                                          void presentation()  
                                          { 
                                            // Register all sensors to gw (they will be created as child devices)
                                            sendSketchInfo("Livolo", "2.0");
                                            present(CHILD_ID_LIGHT1, S_LIGHT);
                                            present(CHILD_ID_LIGHT2, S_LIGHT);
                                            delay(1400);
                                          }
                                          
                                          void loop() 
                                          {
                                          
                                           int value1 = digitalRead(sensor1_PIN);
                                              if (value1==1){
                                                state1=true;
                                              }else{
                                                state1=false;
                                              }
                                          
                                            if (value1 != oldValue1) {
                                                send(msg.set(state1), true); // Send new state and request ack back
                                            }
                                            oldValue1 = value1;
                                          
                                            int value2 = digitalRead(sensor2_PIN);
                                            if (value2==1){
                                                state2=true;
                                              }else{
                                                state2=false;
                                              }
                                            if (value2 != oldValue2) {
                                                send(msg2.set(state2), true); // Send new state and request ack back
                                            }
                                            oldValue2 = value2;
                                          } 
                                           
                                          void receive(const MyMessage &message) {
                                          
                                            if (message.type == V_LIGHT) {
                                               // Change relay state
                                          switch (message.sensor) {
                                                case 1:
                                                  state1=message.getBool();
                                                  digitalWrite(message.sensor+2, RELAY_ON);
                                                  delay(30);
                                                  digitalWrite(message.sensor+2, RELAY_OFF);  
                                                  delay(30); 
                                                  break;
                                                case 2:
                                                  state2 = message.getBool();
                                                  digitalWrite(message.sensor+2, RELAY_ON);
                                                  delay(30);
                                                  digitalWrite(message.sensor+2, RELAY_OFF);  
                                                  delay(30);     
                                                  break;
                                                }
                                             }
                                          }
                                          
                                          frankieF 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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