RasPi does the Home Automation (Part I): Setting up the Pi

Hi all,

it’s some time ago since my last post as I was very busy due to other projects.
But I still intent to control my wireless power outlets with the Raspberry.

The hardware

In the meantime the receiver/transmitter components arrived from Hong Kong (took some weeks, but 8€ (incl. shipping!) for 5 pairs of receiver/transmitter is quite unbeatable ;-)):


Next: connect the transmitter to PIN 0, +5V and GND:


The software

To “talk” to the radio-controlled sockets you have to send serial data to a generic GPIO pin to be send by the transmitter, keyword: “bit-banging”.

Sadly by now Pi4J does not include any bit-banging techniques or built in support. Anyway bit-banging in Java may not be the best solution since timing cannot be guaranteed. (Thanks to Robert Savage from Pi4J for support)

OK then, down-to-earth: install required stuff on the Rasperry

  1. GPIO access library: wiringpi
  2. and the RaspPi adaption of RCSwitch (Arduino): rcswitch-pi

Then I replaced send.cpp from rcswitch-pi by my own version:

#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
  int PIN = 0;

  if (wiringPiSetup() == -1) return 1;
  RCSwitch mySwitch = RCSwitch();

  if (argc==5)
    char* houseCode = argv[1];
    int group = atoi(argv[2]);
    int device = atoi(argv[3]);
    int command  = atoi(argv[4]);
    printf("sending: houseCode:%c group:%i device:%i command: %i\n", houseCode[0], group, device, command);
    switch(command) {
    case 1:
        mySwitch.switchOn(houseCode[0], group, device);
    case 0:
        mySwitch.switchOff(houseCode[0], group, device);
        printf("command[%i] is unsupported\n", command);
        return -1;
    printf(" Usage: ./send <houseCode> <groupCode> <deviceCode> <command>\n");
    printf(" Command is 0 for OFF and 1 for ON\n");

  return 0;

For convenience, I allow send to run as root:

sudo chown root ./send
sudo chmod 4711 ./send

My Intertechno devices can now be controlled from the prompt with my “send”-command:

./send [houseCode] [group] [device] [command]

Here we go:

pi@raspberrypi ~/rcswitch-pi $ ./send a 1 3 1
sending: houseCode:a group:1 device:3 command: 1
pi@raspberrypi ~/rcswitch-pi $

And the fountain in the garden ripples…

Next: “I need a UI” or Crossing the bridge to JavaFX