Hi and Happy new year!Thanks for all who made titanic work with intagration of Livolo and Arduino. Library is very nice - special thanks to topic starter.But there is one problem. There is not full description how Arduino make to send commands only ON and only OFF. Joevpt try to do it but... I wrote simple code for programming Livolo Switches. If you want - "Code for dummies" (And now i'm dummie in Arduino coding too )Code: [Select]#include <livolo.h>byte trport =12; // port of 433-transmitterLivolo livolo(trport); // transmitter connected to pin trportint onoff = 10; // data from Serial unsigned int ID = 6400; // ID of Remote - type your own ID/ f.e. 6400; 19303; 10550; 8500; 7400unsigned int IDB = 0; // Number of remote's button #1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106unsigned int SCENE1 = 90; // Number of scene (available 90, 114, 10, 18)void setup() {Serial.begin(9600); // serial init}void loop() {// Serial reading// if (Serial.available() > 0) {onoff = Serial.read()-48;Serial.println(onoff); }if (onoff == 1){ livolo.sendButton(ID, IDB); Serial.println("Button"); delay (1000);}if (onoff == 2){ livolo.sendButton(ID, SCENE1); Serial.println("Scene"); delay (1000);}if (onoff == 0){ livolo.sendButton(ID, 106); Serial.println("off"); delay (1000);}}There are steps for programming below:1. wrote in header of code your ID, number off button and Scene.2. compile and download in Arduino3. open Serial monitor4. press Livolo switch for 5 seconds (untill BEEP)5. type 1 in Serial monitor and send - Livolo switch will BEEP6. press Livolo switch for 5 seconds again (untill BEEP)7. type 2 in Serial monitor and send - Livolo switch will BEEPfinNow You can test switch via sending same commands in Serial monitor.Make it with all swithes in your location with individual Remote ID for each switch. Now you can use 3 code for manage livolo switch from Arduino:1. Standart on/off in single button with code you write in headerlivolo.sendButton(RemoteID, Button)2. Only ON via sending code of scenelivolo.sendButton(RemoteID, Scene)3. Only OFF via sending code 106livolo.sendButton(RemoteID, 106)
#include <livolo.h>byte trport =12; // port of 433-transmitterLivolo livolo(trport); // transmitter connected to pin trportint onoff = 10; // data from Serial unsigned int ID = 6400; // ID of Remote - type your own ID/ f.e. 6400; 19303; 10550; 8500; 7400unsigned int IDB = 0; // Number of remote's button #1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106unsigned int SCENE1 = 90; // Number of scene (available 90, 114, 10, 18)void setup() {Serial.begin(9600); // serial init}void loop() {// Serial reading// if (Serial.available() > 0) {onoff = Serial.read()-48;Serial.println(onoff); }if (onoff == 1){ livolo.sendButton(ID, IDB); Serial.println("Button"); delay (1000);}if (onoff == 2){ livolo.sendButton(ID, SCENE1); Serial.println("Scene"); delay (1000);}if (onoff == 0){ livolo.sendButton(ID, 106); Serial.println("off"); delay (1000);}}
anyone?
Hi! Sorry for delay - was very busy.I use port 12 in my Mega - this is PWM-port."And one more thing" - i use DIY antenna with the transmitter. Without it Livolo work bad and unstable.
Just in case someone was looking for arduino code to decode Livolo remotes.Code: [Select]#define SIGNAL_IN 0 // INTERRUPT 0 = DIGITAL PIN 2 - use the interrupt number in attachInterruptvolatile byte impulse = 0; // kolejny pulsvolatile int bufor[53];volatile boolean header = false;volatile unsigned long StartPeriod = 0; // set in the interruptvolatile boolean stop_ints = false;void setup(){ attachInterrupt(SIGNAL_IN, calcInput, CHANGE); Serial.begin(9600);}void loop(){ if (stop_ints) //data in buffer { unsigned long binary = 1; //byte i = 0; for (byte j = 0; j < 46; j++) { //Serial.print(binary); if ((bufor[j] > 220) && (bufor[j] < 400)) { binary <<= 1; //binary |= 1; //i++; bitSet(binary,0); } else if ((bufor[j] > 90) && (bufor[j] < 220) && (bufor[j + 1] > 90) && (bufor[j + 1] < 220)) { binary <<= 1; j++; } else if ((bufor[j] > 90) && (bufor[j] < 220) && (bufor[j + 1] > 220) && (bufor[j + 1] < 400)) { binary <<= 1; bitSet(binary,0); //i += 2; j++; } else break; } //Serial.println(bitRead(binary,4)); if (bitRead(binary,23)) { bitClear(binary,23); Serial.print("remoteID:"); Serial.print((binary / 128) & 65535); Serial.print(" - "); Serial.print("key code:"); Serial.println(binary & 127); } else { Serial.println("wrong code "); Serial.println(binary, BIN); } delay (1000); header = false; impulse = 0; stop_ints = false; // } }}// interrupt below...void calcInput(){ // get the time using micros unsigned int duration = (int)(micros() - StartPeriod); // save pulse length to bufor StartPeriod = micros(); //begin next impulse //Serial.println(StartPeriod); if (stop_ints) return; if ((duration < 90) || (duration > 600)) goto reset; //impulse not right bufor[impulse++] = duration; if (duration < 415) return; if (!header) { header = true; impulse = 0; return; } else { if ((impulse < 23) || (impulse > 52)) goto reset; //too long or too short info stop_ints = true; return; }reset: header = false; impulse = 0; return;}Thanks to platenspeler and spchImproved code
#define SIGNAL_IN 0 // INTERRUPT 0 = DIGITAL PIN 2 - use the interrupt number in attachInterruptvolatile byte impulse = 0; // kolejny pulsvolatile int bufor[53];volatile boolean header = false;volatile unsigned long StartPeriod = 0; // set in the interruptvolatile boolean stop_ints = false;void setup(){ attachInterrupt(SIGNAL_IN, calcInput, CHANGE); Serial.begin(9600);}void loop(){ if (stop_ints) //data in buffer { unsigned long binary = 1; //byte i = 0; for (byte j = 0; j < 46; j++) { //Serial.print(binary); if ((bufor[j] > 220) && (bufor[j] < 400)) { binary <<= 1; //binary |= 1; //i++; bitSet(binary,0); } else if ((bufor[j] > 90) && (bufor[j] < 220) && (bufor[j + 1] > 90) && (bufor[j + 1] < 220)) { binary <<= 1; j++; } else if ((bufor[j] > 90) && (bufor[j] < 220) && (bufor[j + 1] > 220) && (bufor[j + 1] < 400)) { binary <<= 1; bitSet(binary,0); //i += 2; j++; } else break; } //Serial.println(bitRead(binary,4)); if (bitRead(binary,23)) { bitClear(binary,23); Serial.print("remoteID:"); Serial.print((binary / 128) & 65535); Serial.print(" - "); Serial.print("key code:"); Serial.println(binary & 127); } else { Serial.println("wrong code "); Serial.println(binary, BIN); } delay (1000); header = false; impulse = 0; stop_ints = false; // } }}// interrupt below...void calcInput(){ // get the time using micros unsigned int duration = (int)(micros() - StartPeriod); // save pulse length to bufor StartPeriod = micros(); //begin next impulse //Serial.println(StartPeriod); if (stop_ints) return; if ((duration < 90) || (duration > 600)) goto reset; //impulse not right bufor[impulse++] = duration; if (duration < 415) return; if (!header) { header = true; impulse = 0; return; } else { if ((impulse < 23) || (impulse > 52)) goto reset; //too long or too short info stop_ints = true; return; }reset: header = false; impulse = 0; return;}