livolo Glass Panel Touch Light Wall Switch + arduino 433Mhz
-
к сожалению не говорю по английски, вот код для ясности :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; } } } } -
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?
-
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?
@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. -
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 :)
-
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; } } } -
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; } } }@Tigroenot said:
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; } } }I am also playing around with the livolo dubble switch, but I am still figuring out how to control the switch via the header on the Switch board (thus without the base unit).
Can you share also your hardware setup, this will be very helpfull for me.
Thanks in advance. -
Hello, for those who have it, can you please confirm if it contains a CD74HC238 like I have in the US(AU) sized switch ? (same PCB for 1 and 3 switches). Chip marking on my chip is HJ238. It then feeds a darlington array chip (marking UN2003A on mine) to trigger the relays.
These would be the 2 ICs in the middle of the last picture from @DJONvl
Would be interesting to know as it would mean the touch PCB for both types of switches would be very similar. -
Hello, for those who have it, can you please confirm if it contains a CD74HC238 like I have in the US(AU) sized switch ? (same PCB for 1 and 3 switches). Chip marking on my chip is HJ238. It then feeds a darlington array chip (marking UN2003A on mine) to trigger the relays.
These would be the 2 ICs in the middle of the last picture from @DJONvl
Would be interesting to know as it would mean the touch PCB for both types of switches would be very similar. -
@Nca78 The euro version doesn't. Just the ULN2003A.
Unfortunately, I can't attach images for some unknown reason.
Finally :)
That's a single button switch.@Tigroenot this is a picture of the EU dubble switch version.
image url)
But what I am looking for is how to connect the arduino to this PCB
The picture of DJONvI is a good start, but I want to know if the SMD components which where added are resistors or a before I blow up the PCB ;-) -
@frankie This diagram shows how a guy fixed his switch that didn't change the rele. But it is quite right. You need to add an optocoupler to connect to the sensor pin with 5,1 pF con to ground and connect the LED to the arduino sensor pin through resistor for the status read. I'll try to find the diagram later.
-
Thank you very much for the pictures @frankie and @Tigroenot !
No 74HC238 on the single switch which can be understood as it's not necessary, with one switch there are enough pins to drive the relay. But it's nicer in the US(AU) world as they are using the same PCB for both and just mounting one relay and one sensor.
On the Russian schematic it is not matching the board you have photographed @frankie as it has a 12 pins connector (2x6) instead of 14 (2x7) on yours (and mine, too). From what I see your board is very similar similar to mine with the 74HC238 and the pins are different than on the schematic. I'm a bit confused with this as this schematic seems to manage 2 buttons/relays.
HC238 will decode value sent by 3 pins on the connector, and set HIGH one of it's 8 outputs based on the binary value. For example, if input is 000 then output 0 is high, if input is 010 then output 2 is high, etc. All other outputs of the 74HC238 are low.
This is done because they are using bistable relays. For each relay there is a SET latch to switch on, and RESET latch to switch off. When it's not switching, the relays stays in it's state without consuming any power. This is a smart way of doing the board to keep it low power, but you need 2 pins for each relay which the PIC controller on the sensor board doesn't have. As they use the 74HC238 they can command up to 4 relays.I used my multimeter and datasheets for the 2ICs to find out how they were connected and this is what I found out for my switch, US(AU) with 1 or 3 buttons/relays. I'm not saying you have the same mapping, you should check the datasheets to find out the input pins on the 74HC238 and verify with your multimeter to which pin of the connector they are connected.
Pinout (only for the pins I'm interested in...). Big squares at the top are the mains connectors.

Pinout of the 74HC238 :

Values on the connector pins to switch on/off the relays:

-
https://geektimes.ru/post/258366/ здесь описание библиотеки для эмуляции радио протокола, если получится ее использовать то можно будет подключиться к светодиодам для получения статуса, а управлять с ее помощью
-
Too I´m start working to provide a universal way to feedback status (for HA) to all my Livolo switches. My main concern is how can get enought supply current to my radio circuit (actually im thinking on ESP8266) from a standard connected switch (only the live AC wire avaible for supply on switch wall case) because needed about 3/5 V with 300 ma (peak when wi-fi are at full work) and I cannot see how the supply circuit in the livolo switch can provide that enough amount of power to supply this element.
I cannot see nothing clear how can draw that amount of current trough "any" load connected over the switch...@DJONvl or anyone had well tested what amount of power supply (3V or 5V,) can "secure" draw trough standard connected Livolo switch ?
Can any confirm if that circuit arduino+nrf24 have self power supply (additional) and how need connected and mainly how much current drawn arduino+nrf24 when they are full working ?
That guys https://www.youtube.com/watch?v=Ny8Rt75he0A had working a circuit (comercial purposes) but seems use aditional power supply for that.
Regards
-
Those guys have an additional 12 v power wire in the switch mounting, the wire fore 12v power has been put there during the construction.
The power supply in livolo switches is capable to make up to 250mA current. So I suppose it is not possible to feed the esp8266, but more than enough to power the 328p and Nrf24 radio. Currently I have one double button livolo switch running for a week or so with no issues whatsoever. But you have to change the BOD fuses to 1,8 v. Running at 2,7 bod causes reboot at sending data.
Drawing more power from livolo power supply is not hard, but your load has to be at least 40w light bulbs. -
Those guys have an additional 12 v power wire in the switch mounting, the wire fore 12v power has been put there during the construction.
The power supply in livolo switches is capable to make up to 250mA current. So I suppose it is not possible to feed the esp8266, but more than enough to power the 328p and Nrf24 radio. Currently I have one double button livolo switch running for a week or so with no issues whatsoever. But you have to change the BOD fuses to 1,8 v. Running at 2,7 bod causes reboot at sending data.
Drawing more power from livolo power supply is not hard, but your load has to be at least 40w light bulbs.@Tigroenot Thank you for your quick reply.
I think additional power supply is not the right path for that, because needed modify all house wiring is a real pain and most costly solution.If 250ma drawn current is avaiable from livolo switch I think is really so close for the "calculate" needs for a esp8266, so maybe is time to real test it and see what happends but If esp cannot not work properly it does not matter because you say have stable working arduino+nrf24 that is equal good solution or in some cases maybe better than an alone esp.
Maybe we always easily can add one parallel capacitor at loads (any 0,47nf X2 400V rated or livolo can provide someone too) to increase load current drawn if we find that some switch cannot drawn enough power from his load?
Regards
-
Hello Tigroenot, you have the EU version of livolo correct?
Can you please post a schematic on how you performed the Boost to the power supply? I'm using mysensors+nrf24 so I just need arround 20ma power.
Thank you.


