Linux Kernel Module to Control 434Mhz RC Outlets – Pi Version

Added a setup-script to cross-compile the Linux kenel module for the RC outlets for the Raspbarry Pi. To be able to cross-compile the module, in brief the following needs to be done:

Install ARM cross-gcc

On Ubuntu:

sudo apt-get install gcc-arm-linux-gnueabi make ncurses-dev

Get RasPi Kernel

E.g. use Kernel from GIT:

git clone linux-raspberrypi

Compile the Kernel (needs to be done once before building the rcswitch-kmod)

To be able to compile out-of-tree Kernel modules, you need to cross-compile the targets Kernel at least once. This is done like so:

cd linux-raspberrypi
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- bcmrpi_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

Depending on your machine, this may take some time …

Build rcswitch-kmod

Get the module from git:

git clone rcswitch-kmod
cd rcswitch-kmod

Edit, make sure LINUX_DIR points to the directory of your previously build kernel:

export LINUX_DIR=$PWD/../linux-raspberrypi

Next, build the module:

source ./
make all

Now copy the Kernel module to your PI. E.g. by using ssh:

scp module/src/rcswitch.ko pi@:/home/pi/.

Wiring the RF Transmitter to the PI (to use Kernel module defaults)

To use the modules build in default, connect the RF-Transmitter as shown in the picture below:

Connect transmitter to PI

Connect transmitter to PI

Loading the Module, Testing Module

On the Pi, the module could be loaded like this:

sudo su
insmod /home/pi/rcswitch.ko

Verify the module was loaded properly:


Should output something like this:

[ 3392.757506] rcswitch: init
[ 3392.757540] rcswitch: using tx_repeat of 10
[ 3392.757609] rcswitch: registered command interface under: /sys/kernel/rcswitch/command
[ 3392.757623] rcswitch: registered power   interface under: /sys/kernel/rcswitch/power
[ 3392.757641] rcswitch: using gpio #17 for TX
[ 3392.757650] rcswitch: EN disabled

And the following sysfs entries should have bean created:

ls -al /sys/kernel/rcswitch
--w--w--w- 1 root root 4096 Jul 25 23:15 command
-rw-rw-rw- 1 root root 4096 Jul 25 23:46 power

If all of the above is in place, you should be able to operate your switches. E. g. turn on switch at address 11111, channel A:

echo 11111A1 > /sys/kernel/rcswitch/command

And to turn the same switch off:

echo 11111A0 > /sys/kernel/rcswitch/command

Note: there is also a python example which could be used on the Pi here.

Leave a Reply

You must be logged in to post a comment.