Convert cheap 433Mhz sensors to KaKu/CoCo with an Arduino convertor

Categories Code, Hardware, Mods

In the past 1,5 year I have been playing a bit with Home Automation (or Domotics / Domotica) systems. I initially bought the HomeWizard, but was pretty disappointed in it. When the HomeWizard domotica system was introduced I expected a lot of it, sadly enough it has not been as great as I hoped and I am currently moving over to another system.  One of the things that annoyed me of the HomeWizard is the inability to add other sensors to the setup which were not part of the supported hardware (which is pretty limited). I moved to the HomeWizard from a different (alarm) system which contained a lot of 433Mhz sensors which I could not hook up to the HomeWizard. Because I did not want to throw all these sensors away I built a middle-ware system with an Arduino and some code which can convert the non-supported codes in to HomeWizard supported codes (KaKu / CoCo style codes). The middle-ware receives a code and then translates that to a code which can be understood by the HomeWizard. Initially designed for usage with HomeWizard this same approach also worked with HomeSeer, Domotiga and Domoticz, which all did not support my sensors directly (most of them because of the usage of the RFXCOM).

The approach described is shown in the overview below (the numbers used are just examples).

Overview

This post contains the schematic, code and all the info you need to build your own middle-ware. The described approach will work on the incompatible 433Mhz sensors of other (cheap) alarm systems, but also for ELRO remotes and probably a lot of other systems. It has been tested with the following devices:

TestedDevices

From left to right:

  1. Nameless motion sensor with  BX R433A and Semic CS5211DGO IBAU1K380BN chip
  2. Nameless button switch with  BX R433A and LP801B  APN03535 chip
  3. Nameless door sensor with BX R433A and Semic CS5211AGP ICAU1K3T11J chip
  4. Nameless remote with BX R433A and Semic CS5211AGP IBAU4K3807K chip
  5. ELRO AB440R (433.92Mhz) Remote
  6. Nameless 433Mhz smoke detector (not shown)

Arduino schematic

The hardware used for the middle-ware is a standard Arduino (or cheap alternative such as this), with an Arduino shield and a basic 433Mhz transmitter/receiver set. Any basic 433Mhz receiver and transmitter can be used for this, such as this pair on DealExtreme. The receiver module is the longer board of the two, the transmitter is the small one. The shield can of course also be replaced with a small breadboard, if that is what you prefer.

The following picture shows the setup of the Arduino and the 433Mhz sensors (green, receiver at the top, transmitter at the bottom), the red wires are the 5V wires, the black wires the GND wires and the blue wires the DATA wires. The antenna positions on the 433Mhz boards I used are shown by the A’s.

Shield_v4s

To extend the reach of the 433Mhz transmitter and receiver I added two antennas to the setup, made out of 16,7cm copper wire. I reinforced the antennas with the plastic part of cotton swabs (q-tips / wattenstaafjes (Dutch)) and some heat-shrink tubes, which worked out pretty well. The finished product can be seen below.

Middle-Ware2s

Code

The simplest code to run on the Arduino can be found below. This code makes use of two very nice Arduino libraries written by Randy Simons, it actually leans fully on those libraries and only links them together. Feel free to do whatever you want with the code below, only keep in mind the license of the libraries used. Any fixes or additions to the code are of course welcome, so please let me know if you have any.

// Cheap 443Mhz sensor to KaKu/CoCo convertor - simple
// Thijs Bosschert, 24-08-2014
// http://www.thice.nl

// Library: RemoteSwitch library v2.3.0 (20121229) for Arduino 1.0
//          Made by Randy Simons http://randysimons.nl/
//          https://github.com/hjgode/homewatch/tree/master/arduino/libraries/RemoteSwitch
#include <RemoteReceiver.h>
// Library: NewRemoteSwitch library v1.0.0 (20121229) for Arduino 1.0
//          Made by Randy Simons http://randysimons.nl/
//          https://github.com/hjgode/homewatch/tree/master/arduino/libraries/NewRemoteSwitch
#include <NewRemoteTransmitter.h>

void setup() {
  // Receiver, PIN 2 (0), only 1 received code is enough
  RemoteReceiver::init(0, 1, sendCodeNew);
}

void loop() {
}

void sendCodeNew(unsigned long receivedCode, unsigned int period) {
    // Disable receiver while sending
    RemoteReceiver::disable();
    // Send code
    NewRemoteTransmitter transmitter(receivedCode, 3, 260, 3);
    transmitter.sendGroup(1);
    // Enable Receiver again
    RemoteReceiver::enable(); 
}

 

This code sends out the same code it received, it is only converted to the other protocol. That way any 433Mhz device it picks up will be forwarded. This is the easiest way to add multiple 433 Mhz sensors to your setup. However, you can also choose to use the more advanced code below, which enables you to define your own codes and only forwards the codes it knows. This might be a solution you want when there is a lot of interference from other devices you do not want to have added to your system. This code below also has a debug option which shows you which 433Mhz codes are seen by the Arduino, which might be helpful to find the codes for all your devices.

 

// Cheap 443Mhz sensor to KaKu/CoCo convertor - advanced
// Thijs Bosschert, 24-08-2014
// http://www.thice.nl

// Library: RemoteSwitch library v2.3.0 (20121229) for Arduino 1.0
//          Made by Randy Simons http://randysimons.nl/
//          https://github.com/hjgode/homewatch/tree/master/arduino/libraries/RemoteSwitch
#include <RemoteReceiver.h>
// Library: NewRemoteSwitch library v1.0.0 (20121229) for Arduino 1.0
//          Made by Randy Simons http://randysimons.nl/
//          https://github.com/hjgode/homewatch/tree/master/arduino/libraries/NewRemoteSwitch
#include <NewRemoteTransmitter.h>

int debug = 1; // Turn debugging on (1) or off (0)
long int Code[30][2]; // Array to hold all the codes
int max = 30; // Maximum amount of codes, change if more needed

void setup() {
  // Only output information on the serial port when debugging is on
  if(debug) { 
    Serial.begin(115200);
    Serial.println("DEBUG ON");
  }
  // Receiver, PIN 2 (0), only 1 received code is enough
  RemoteReceiver::init(0, 1, showCode);

  // Code examples, replace with your own code
  Code[0][0] = 270867;  Code[0][1]  = 10420001; // Will show up in Homewizard as: 009EFF2100
  Code[1][0] = 270873;  Code[1][1]  = 10420002; // Will show up in Homewizard as: 009EFF2200
  Code[2][0] = 270891;  Code[2][1]  = 10420003; // Will show up in Homewizard as: 009EFF2300
}

void loop() {
}

void showCode(unsigned long receivedCode, unsigned int period) {
  // Debug info: print the received code
  if(debug) { 
    Serial.print("Code received:  ");
    Serial.println(receivedCode);
  }

  // Check if received code is in our list
  long int CoCoCode;
  for (int i = 0; i < max; i++) { 
    if(Code[i][0] == receivedCode) { 
      CoCoCode = Code[i][1]; 
      break; 
    }
  }
  
  // If code is in our list, then send KaKu/CoCo code
  if (CoCoCode) {
    // Disable receiver while sending
    RemoteReceiver::disable();
    // Send code
    NewRemoteTransmitter transmitter(CoCoCode, 3, 252);
    transmitter.sendGroup(1);
    // Debug info: print the CoCo code
    if (debug) { 
      Serial.print("Code sent:      ");
      Serial.println(CoCoCode); 
    }
    // Enable Receiver again
    RemoteReceiver::enable();
    CoCoCode = 0;
  } else {
    // Do not send anything if code is unknown
    if (debug) { 
      Serial.println("Code unknown");
    }    
  }
}

 

Debug output

The debug option (int debug = 1;), from the code above gives the following debug information on the COM port:

debug

 

Add to HomeWizard

Since the middle-ware is now sending out KaKu/CoCo codes that the HomeWizard can understand we can add them to the HomeWizard. Since we use a very simple protocol here we can at this moment only add the sensors as ‘Doorbells’, but that should not limit you in using the sensors.

AddSensor

 

 

 Add to Domoticz

When the Arduino middle-ware is being used the sensors will start showing up in Domoticz when the RFXCOM picks them up, they are shown as using protocol Lighting 2, AC.

ScreenShot_Domoticz

When linked they will also show up in the log file (in this example they are linked to an event which sends out notifications using NMA).

Sun Aug 24 18:54:11 2014 Notification send (NMA)
Sun Aug 24 18:54:11 2014 UI Event triggered: Alarm Events - Test
Sun Aug 24 18:54:10 2014 (RFXCOM) Lighting 2 (Test Sensor)
Sun Aug 24 18:54:20 2014 Notification send (NMA)
Sun Aug 24 18:54:20 2014 UI Event triggered: Alarm Events - Test
Sun Aug 24 18:54:19 2014 (RFXCOM) Lighting 2 (Test Sensor)

 

Two way communication

After writing this How-To I decided to make a new version which could do two way communication. Which means you can use the Home Automation system to control your cheap 433Mhz receivers (such as ELRO power adapters) as well. This has been successfully tested on ELRO AB440SC (433.92Mhz) Wireless Switch Units.

The Arduino schematic for this Two-Way version is shown below, because the Arduino interupts 0 & 1 are on digital pins 2 & 3 we need to move the sender to digital pin 4. We hook up the same receiver to both PIN 2 and PIN 3 (both of the middle pins in the receiver are DATA).

Shield_v4

The code for this version:

// Cheap 443Mhz sensor to KaKu/CoCo convertor - Two-Way
// Thijs Bosschert, 24-08-2014
// http://www.thice.nl

// Library: RemoteSwitch library v2.3.0 (20121229) for Arduino 1.0
//          Made by Randy Simons http://randysimons.nl/
//          https://github.com/hjgode/homewatch/tree/master/arduino/libraries/RemoteSwitch
#include <RemoteReceiver.h>
#include <RemoteTransmitter.h>
// Library: NewRemoteSwitch library v1.0.0 (20121229) for Arduino 1.0
//          Made by Randy Simons http://randysimons.nl/
//          https://github.com/hjgode/homewatch/tree/master/arduino/libraries/NewRemoteSwitch
#include <NewRemoteReceiver.h>
#include <NewRemoteTransmitter.h>

void setup() {
  // OldReceiver, PIN 2 (interupt 0), only 1 received code is enough
  RemoteReceiver::init(0, 1, sendCodeNew);
  // NewReceiver, PIN 3 (interupt 1), only 1 received code is enough
  NewRemoteReceiver::init(1, 1, sendCodeOld);
}

void loop() {
}

void sendCodeNew(unsigned long receivedCode, unsigned int period) {
    // Disable receiver while sending
    RemoteReceiver::disable();
    // Send code (on PIN4)
    NewRemoteTransmitter transmitter(receivedCode, 4, 260, 3);
    transmitter.sendGroup(1);
    // Enable Receiver again
    RemoteReceiver::enable(); 
}

void sendCodeOld(NewRemoteCode receivedCode) {  
  // Disable the receiver while sending
  NewRemoteReceiver::disable();
  // Send code (on PIN4)
  RemoteTransmitter::sendCode(4, receivedCode.address, 260, 5);
  // Enable Receiver again
  NewRemoteReceiver::enable();
}

 

I hope this approach might be of use to someone. Please let me know if you have additions, remarks or comments. As last I would like to thank Randy Simons for his great library which enabled me to create this in a fairly simple way.

 

19 Comments

  • Thice.nl » Post overview
    29/08/2014

    […] than $5 Crypto hardware Plug-over attack Hiding your data in plain sight – USB hardware hiding Convert cheap 433Mhz sensors to KaKu/CoCo with an Arduino convertor Soon: Forensic hardware – Logicube Forensic Dossier […]

  • Marc Spoorendonk
    03/12/2014

    Thijs, I’m looking into hooking up some RF door sensors to a Raspberry Pi connected to OpenHAB. I’m having trouble finding info on the events which I can capture with this. I’d like to capture both a door-open and door-close event in order to reliably determine the door state. This would require the sensor to send two different codes (one for open and a different one for close). Do you know if there are any sensors that do this? Or do they only send a door-open event (as this is the only relevant event for for alarm systems).

  • Thice
    08/12/2014

    Hi Marc, the KaKu (CoCo) door sensors do this. The cheaper sensors in general only send a ‘break’ event, which can happen when the door opens or closes. Info can be found here: http://www.klikaanklikuit.nl/home/
    However, KaKu is a bit more expensive.

  • deennoo
    12/02/2015

    Is there a way to use another sending protocole ?

  • Thice
    27/02/2015

    @deennoo
    Depends on what kind of protocol you want, as long as it is 433Mhz and there is a module for it you can. However if it is a different frequency you will need different hardware. And if there is no module for your protocol you will need to write it yourself.

  • Tom
    16/04/2015

    Thijs, sould it be possible to control my blinds with it? They are a NICE 433.92mhz remote with build-in engine receiver. I’m using a homewizard but the homewizard doesn’t support the NICE, only Somfy.
    I’m not a smart elecro-guy, but i would give it a try.

  • Tom
    20/04/2015

    Love the idea. Could it be possible to use this setting to control my screens? They are NICE remote 433.92mhz.
    I’m using a Homewizard, but because the screens are not Somfy I would have to buy 3 ASUN-650’s to control the screens.
    If the arduino setup could work, this costs me 1/3 of the price.

  • Diana
    05/05/2015

    Thanks for the tutorial
    I have one question:
    Do you still use RFXCOM
    Or connect the Arduino shield directly to the pi which runs domoticz

  • Thice
    13/05/2015

    @Tom
    You could check if the arduino can see the remote signals, if it can it can be done.

  • Thice
    13/05/2015

    @Diana
    At the moment I indeed still use the RFXCOM, mainly because I did not want to start coding on Domoticz yet, but you should be able to do it without it.

  • Gus Norman
    18/06/2015

    Hi Thice,
    I’m very interested in your work, and built the middle-ware. I now would like to add it to domoticz. So, several questions : How can I do that ? Just plug the arduino’s USB to the raspberry ? Will domoticz recongnize it ? Or is there an other thing to do ?
    Anyway, thanks a lot for this tutorial,
    Regards, Gus

  • Thice
    26/06/2015

    @Gus Norman
    At this time it works as a stand alone middleware communicating to the RFXCOM, however, with some coding you should be able to hook it up by USB.

  • Deennoo
    24/11/2015

    @Gus Norman

    Try RFLink !

    http://www.nemcon.nl/blog2/

  • Marty
    22/08/2016

    Which adaptions are needed to run these sketches on a Raspberry Pi 3?

  • Thice
    14/10/2016

    @Marty
    I have no experience with running Arduino code on the Raspberry Pi, so can’t help you there at the moment…

  • John Jasperse
    14/12/2016

    I am searching for the component diagram of the wireless switch unit AB440S (imported bij Elro)
    Is there someone who can sent me this?

  • Anthony
    15/12/2016

    Hi
    I used the NewRemoteReceiver library with the program ShowReceivedCode and it works perfectly using homewizard and remote control.
    I can see the code when pushing remote control, that’s fine.
    I bought a new 3 remotes control switches from a store called “Action” in France it’s comes from Netherlands manufacturer, I supposed that it worked with Homewizard box but apparently not. It is strange because the code is detected by the arduino program and show the code. additionnaly, the HW box shows the code learnt, but when I ask to HW to send the code to switch on, it doesn’t work, I don’t know why ?
    Is there anyone able to explain me please ?
    thanks a lot
    Anthony from France

  • Thice
    29/01/2017

    @John Jasperse
    Could you explain a bit more what you are looking for?

  • Thice
    29/01/2017

    @Anthony
    These devices are working a bit differently. You have to learn the powerdevices the code. I am no longer using HomeWizard but Domoticz myself, in Domoticz you need to create a new device and then send that signal after the powerdevice is plugged in. You might need to do the same with HomeWizard.

Leave a Reply

Your email address will not be published. Required fields are marked *