Page 1 of 1
WiFi - KaKu Transmitter
Posted: Friday 19 February 2016 10:32
by Rolo
Hi,
Would like to show my project ;
I'm building an interface to get the KaKu (KlikAanKlikUit) hardware controlled by domoticz. It's based on a ESP-2866 WiFi module and a 433 Mhz transmitter. Both are cheap and compact modules. It wil only be able to transmit switch and dimming codes, no receiver.
This unit becomes a webserver in your private WiFi network and takes simple http post command to simulate a KaKu remote control. It only works with the newer, self learning KaKu units. In Domoticz you can create a virtual switch and use the HTTP line as script. It's send and forget, just as the KaKu remotes. It can operate next to your existing stand-alone KaKu remotes, so if Domoticz is off-line you can still operate your KaKu devices.
I'm programming the ESP-2866 in the Arduino IDE and have a prototype running now. It operates at 3.3V and I'm going to to some range testing arround my house this weekend. If the range is to short I have the option to run the transmitter on 5V, but I prefer the lowest possible TX power.
Here is a picture of the prototype, the real unit will be much smaller, only containing the ESP-8266 and 433Mhz transmitter.
It wil operate on a standard 5V USB phone charger.
Will post updates when the range testing is done.
Re: WiFi - KaKu Transmitter
Posted: Saturday 20 February 2016 17:29
by Thomio
Nice project keep us posted

Re: WiFi - KaKu Transmitter
Posted: Saturday 20 February 2016 18:42
by NietGiftig
Nice, like to see the code for the ESP
Re: WiFi - KaKu Transmitter
Posted: Saturday 20 February 2016 19:47
by gerardvs
Nice indeed, I would like to see the ESP code too.
Re: WiFi - KaKu Transmitter
Posted: Saturday 20 February 2016 21:53
by Rolo
Did some testing today and the range is fine at 3.3 volts. Comparable to the standard KaKu remote. (also on 3V battery). I can place this transmitter anywhere in my house al long as it's in the 2.4 Ghz WiFi range. You asked for the code, I'm programming the ESP-2866 in the Arduino IDE, the ESP can be added using the board manager function in the recent Arduino IDE. This way I can use Arduino libraries. You do need a board with a reset en programming button to program the ESP. That's the board on my picture. Also a 3 Volt serial-usb adaptor because the ESP in 3.3V only, not 5V tolerant. You do need some Arduino knowledge and have to handle the solder iron to get this running.
So I just combined the ESP and KaKu library's together. There is one practical issue with this setup, the WiFi SSID and password are programmed into the ESP, so when changing my WiFi network I have to compile a new version of the code and program it into the ESP.
I can't test the dimming function because I do not own a KaKu dimmer but I expect it to work as it's supported in the library.
My test are done with an ASUN-650 sun screen ( = Zonnescherm ?) controller.
Here is the code is use in this prototype :
Code: Select all
// Add the ESP8266 Boards to the Arduino IDE :
// https://github.com/esp8266/Arduino
// For the KaKu protocol the library NewRemoteTransmitter is used :
// https://github.com/hjgode/homewatch/tree/master/arduino/libraries/NewRemoteSwitch
const String ID = "KaKu_Transmitter\n";
const String Version = "Version 1.4\n";
// URL examples
// http://10.0.0.5/sendUnit?unit=1&value=1
// http://10.0.0.5/sendDim?unit=2&value=15
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <NewRemoteTransmitter.h>
const char* ssid = "yourSSID";
const char* password = "yourPassword";
ESP8266WebServer server(80);
// Create a KAKU transmitter on address 123, using digital GPIO0 to transmit,
// with a period duration of 260ms (default), repeating the transmitted
// code 2^3=8 times.
NewRemoteTransmitter transmitter(123, 0, 260, 3);
#define LED 2 // Status Led on GPIO2
void handleRoot() {
String message = ID;
message += Version;
message += "MAC ";
message += (WiFi.macAddress());
server.send(202, "text/plain", message);
}
void handleNotFound(){
String message = "Command not found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
void handleCommand(){
String message = ID;
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
if (server.uri() == "/sendUnit") {
int unit = (server.arg(0).toInt());
int val = (server.arg(1).toInt());
digitalWrite(LED, HIGH); // Blink status LED when transmitting data
transmitter.sendUnit(unit, val); // Transmit KaKu data
digitalWrite(LED, LOW);
}
if (server.uri() == "/sendDim") {
int unit = (server.arg(0).toInt());
int val = (server.arg(1).toInt());
digitalWrite(LED, HIGH); // Blink status LED when transmitting data
transmitter.sendDim(unit, val); // Transmit KaKu data
digitalWrite(LED, LOW);
}
server.send(200, "text/plain", message); // Echo the data to the webpage
// used for debugging from webbrowser
}
void setup(void){
pinMode(LED, OUTPUT);
digitalWrite(LED,LOW);
Serial.begin(9600);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
digitalWrite(LED, HIGH); // Blink LED three times to indicate that the unit is connected to WiFI
delay(200);
digitalWrite(LED, LOW);
delay(200);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
delay(200);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
Serial.println(""); // Echo status to serial port
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress());
if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on ("/sendUnit", handleCommand);
server.on ("/sendDim", handleCommand);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}
Re: WiFi - KaKu Transmitter
Posted: Saturday 20 February 2016 22:15
by NietGiftig
Rolo wrote:There is one practical issue with this setup, the WiFi SSID and password are programmed into the ESP, so when changing my WiFi network I have to compile a new version of the code and program it into the ESP.
Minor issue
You used the
NewRemoteTransmitter library.
I have older "Action" switches (store in NL)
I have to try if the RemoteTransmitter from the same git also works.
Thanks for sharing
Re: WiFi - KaKu Transmitter
Posted: Saturday 20 February 2016 22:19
by Rolo
Yes, I think you can use the RemoteTransmitter library, I should take some changes in the code, the example code that comes with the library should get you on your way.
Re: WiFi - KaKu Transmitter
Posted: Saturday 27 February 2016 13:42
by Rolo
Software update : group command is added :
Code: Select all
// Add the ESP8266 Boards to the Arduino IDE :
// https://github.com/esp8266/Arduino
// For the KaKu protocol the library NewRemoteTransmitter is used :
// https://github.com/hjgode/homewatch/tree/master/arduino/libraries/NewRemoteSwitch
const String ID = "KaKu_Transmitter\n";
const String Version = "Version 1.5\n";
// URL examples
// http://10.0.0.5/sendUnit?unit=1&value=1 value must be 0 or 1
// http://10.0.0.5/sendDim?unit=2&value=15 value must be 0 to 15
// http://10.0.0.5/sendGroup?unit=1&value=1 unit don't care in group command, value must be 0 or 1
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <NewRemoteTransmitter.h>
const char* ssid = "yourSSID";
const char* password = "yourPassword";
ESP8266WebServer server(80);
// Create a KAKU transmitter on address 123, using digital GPIO0 to transmit,
// with a period duration of 260ms (default), repeating the transmitted
// code 2^3=8 times.
NewRemoteTransmitter transmitter(123, 0, 260, 3);
#define LED 2 // Status Led on GPIO2
void handleRoot() {
String message = ID;
message += Version;
message += "MAC ";
message += (WiFi.macAddress());
server.send(202, "text/plain", message);
}
void handleNotFound(){
String message = "Command not found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
void handleCommand(){
int unit = (server.arg(0).toInt());
int val = (server.arg(1).toInt());
digitalWrite(LED, HIGH); // Blink status LED when transmitting data
if (server.uri() == "/sendUnit") transmitter.sendUnit(unit, val);
if (server.uri() == "/sendGroup") transmitter.sendGroup(val);
if (server.uri() == "/sendDim") transmitter.sendDim(unit, val);
digitalWrite(LED, LOW);
String message = ID;
message += Version;
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(200, "text/plain", message); // Echo the data to the webpage
// used for debugging from webbrowser
}
void setup(void){
pinMode(LED, OUTPUT);
digitalWrite(LED,LOW);
Serial.begin(9600);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
digitalWrite(LED, HIGH); // Blink LED three times to indicate that the unit is connected to WiFI
delay(200);
digitalWrite(LED, LOW);
delay(200);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
delay(200);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
Serial.println(""); // Echo status to serial port
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress());
if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on ("/sendUnit", handleCommand);
server.on ("/sendDim", handleCommand);
server.on ("/sendGroup", handleCommand);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}
Re: WiFi - KaKu Transmitter
Posted: Thursday 03 March 2016 18:43
by Rolo
Update : definitive schematic

Re: WiFi - KaKu Transmitter
Posted: Thursday 06 October 2016 8:21
by kniazio
Is the author of this project could add this project to plug EasyESP
https://github.com/ESP8266nu/ESPEasyPluginPlayground
Re: WiFi - KaKu Transmitter
Posted: Friday 21 October 2016 6:43
by kniazio
Is it really such a great project can not join even grander easyesp?

)