DIY IHC Internet bridge

First a little background : IHC is a system that makes it possible to improve the old light switch, the “new” wireless version makes it possible to do this to old houses without having to pull new expensive wiring.
For about 100-150$ you get a wireless lightswitch or outlet, and it takes half an hour to install (Danish law allows you to do the work yourself IF you know how to, otherwise its an electrician job).

In addition to the mains modules, theres also battery operated modules that are simply radio transmitters.

Once you have a few modules, they can be linked so that you can control the outlets from somewhere else, eg. turn off the kitchen light at the other end of the room, or control 2 outlets from 1 place.

Now if you want to add some smarts to the system you can buy an controller and install it in your meter closet and connect it to the network and use an outdated PC application to click some outlets on and off… so old fashioned, and the controller costs 700$ alone, so its a bit steep.

So I decided to see if I could make a lesser controller with a photon and a “Wireless input 1-4 channels”, this module consist of a small plastic unit with a CR2032 battery and 8 wires exposed to the user, originally its intended to connect other buttons to the IHC system, but it can also be used as a way of getting 3rd party components to control the IHC system.
Luck has it the wires are GND controlled, 4 of them are just tied to ground, and the other 4 are pulled up to 2.2V, so connecting it to the photon is somewhat easy.
One of the ground wires to gnd, other 3 not connected, the 4 input wires to a digital output pin, ideally with a diode inbetween so that the photon can only pull the pins low, not send 3.3V out on them, although I have tested that 3.3V does not kill the unit :blush:


The board is a prototype from another project, I only use D0-3 from the photon for this bridge.

Now I can control the 4 inputs from the photon/tinker app.
Next up, adding easyier control from the phone, I made a simple program to control each output when a cloud function is triggered.
Note that this sloppy code only works if you only intend to use 1 input module, since we can only register 4 cloud function, so if you add more than 1 module, it needs to be changed to one function with more arguments in the command string.
The timeout code is a bit odd at first glance, because I use the device in “Control link” mode, which means one output turns on a selection of outputs, and another output turns the same selection off, so if I want Output 1 to be on for 10seconds, then I trigger O1 wait 10s and then trigger O2.
The alternative control mode is “Scenario mode” where each output triggers a scenario, for example specific light levels on specific outlets, and a scenario to turn it all off again.

uint16_t timerO1 = 0;
uint16_t timerO2 = 0;
uint16_t timerO3 = 0;
uint16_t timerO4 = 0;

void setup() {
  
  Particle.function("O1", O1);
  Particle.function("O2", O2);
  Particle.function("O3", O3);
  Particle.function("O4", O4);
}

void loop() {
    if (timerO1 > 0)
    {
        timerO1--;
        if (timerO1 == 0) O2(String("0"));
    }
    if (timerO2 > 0)
    {
        timerO2--;
        if (timerO2 == 0) O1(String("0"));
    }
    if (timerO3 > 0)
    {
        timerO3--;
        if (timerO3 == 0) O4(String("0"));
    }
    if (timerO4 > 0)
    {
        timerO4--;
        if (timerO4 == 0) O3(String("0"));
    }
    delay(1000);
}





int O1(String command)
{
    //1=D0=Spot on
    pinMode(D0, OUTPUT);
    digitalWrite(D0, LOW);
    delay(100);
    digitalWrite(D0, HIGH);
    pinMode(D0, INPUT);
    timerO1 = command.toInt();
}

int O2(String command)
{
    //2=D1=Spot off
    pinMode(D1, OUTPUT);
    digitalWrite(D1, LOW);
    delay(100);
    digitalWrite(D1, HIGH);    
    pinMode(D1, INPUT);
    timerO2 = command.toInt();  
}

int O3(String command)
{
    //3=D2=Kugle on
    pinMode(D2, OUTPUT);
    digitalWrite(D2, LOW);
    delay(100);
    digitalWrite(D2, HIGH);    
    pinMode(D2, INPUT);
    timerO3 = command.toInt();    
}

int O4(String command)
{
    //4=D3=Kugle off
    pinMode(D3, OUTPUT);
    digitalWrite(D3, LOW);
    delay(100);
    digitalWrite(D3, HIGH); 
    pinMode(D3, INPUT);
    timerO4 = command.toInt();  
}

To control it from the phone I made 4 nearly identical tasker task´s that calls the photon.io api and sends a cloud command.

I then added a shortcut for these tasks to one of the home screens.

And finally now that I can have tasker control my lights, I made a profile that turns on my general light for 5 minutes, when the alarm sounds and I am connected to my home wifi :smile:

This solution costs about 120$ and can be extended to take inputs from low voltage switches, the biggest limitation compared to the real controller is the inability to get an command from the switches, from the photon point of view its output only, the only output module (ie input to photon) they sell is a single channel one intended for mains power.

1 Like