Sensor wall switch based on Livolo glass
Make a thin and beautiful battery powered wall switch based on cheap Livolo glasses and Z-Uno.- Z-Uno board
- Livolo glas
- Livolo frame
- 2 TTP223 touch pad detector
- 2 schottky diodes
- 2 resistors 220 Ω
- 2 resistors 10 kΩ
- 2 capacities 10 nF
- 1 tantalum capacitor 100 μF (or 2 by 47 μF as on the photo)
- 2 tune capacities 0-50 pF
- 2 LEDs
Here is how it looks like once assembled:
Original Livolo frame can be used to mount the wall switch and to fix the CR2032 battery. It is recommended to use 4 batteries in parallel to have sufficient lifetime. A tantalum capacitor C3 allows to mitigate spikes of current during Z-Wave transmission and enhance battery life.
#define BTN_INT_PIN 18 // INT pin
#define BTN_PIN1 0 // button pin
#define BTN_PIN2 20 // button pin
#define CONTROL_GROUP 1 // number of Association Group
#define SWITCH_ON 0xff
#define SWITCH_OFF 0
ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE); // Send Turn On/Off command to associated devices
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_SLEEPING); // Sleeping mode
byte lastValue1 = HIGH;
byte lastValue2 = HIGH;
// the setup routine runs once when you press reset:
void setup() {
pinMode(BTN_PIN1, INPUT_PULLUP);
pinMode(BTN_PIN2, INPUT_PULLUP);
}
// the loop routine runs over and over again forever:
void loop() {
byte currentValue1 = digitalRead(BTN_PIN1);
byte currentValue2 = digitalRead(BTN_PIN2);
// Button Down
if (currentValue1 != lastValue1) { // if state changes
lastValue1 = currentValue1; // save new state
if (lastValue1 == LOW) {
zunoSendToGroupSetValueCommand(CONTROL_GROUP, SWITCH_OFF); // if button pressed - send switch OFF command
}
}
// Button Up
if (currentValue2 != lastValue2) { // if state changes
lastValue2 = currentValue2; // save new state
if (lastValue2 == LOW) {
zunoSendToGroupSetValueCommand(CONTROL_GROUP, SWITCH_ON); // if button pressed - send switch ON command
}
}
// Go to sleep after release the button
if (digitalRead(BTN_INT_PIN)){
zunoSendDeviceToSleep();
}
}
Download this sketch
This is how it looks on the wall
Link to detailed project description (in Russian, use Google to translate)