DIY Smart Home

Home Automation Guide With Raspberry Pi and Arduino

James Bruce 21-08-2013

We’ve talked about the relative merits of Arduino and Raspberry Pi before – they each have their strengths. They needn’t be an either or choice though – combine them to get the best of both worlds. Home automation is the perfect candidate for this. The home automation market is flooded with expensive consumer systems, incompatible with one another and costly to install. If you have a Raspberry Pi Raspberry Pi: The Unofficial Tutorial Whether you're a current Pi owner who wants to learn more or a potential owner of this credit-card size device, this isn't a guide you want to miss. Read More and an Arduino, you can basically achieve the same thing at a fraction of the price, assuming you’re willing to put in the time and the effort.


Update: Since this article was written, I’ve discovered OpenHAB, a free and open source home automation platform that runs on Raspberry Pi and can be integrated with a huge range of off-the-shelf smart home kit as well as Arduino. Check out the video below for a sneak peak, then head on over to our Getting Started with OpenHAB on Raspberry Pi Getting Started with OpenHAB Home Automation on Raspberry Pi OpenHAB is a mature, open source home automation platform that runs on a variety of hardware and is protocol agnostic, meaning it can connect to nearly any home automation hardware on the market today. Read More guide to learn more. 

Heimcontrol.js is a Node.js app built to run on Raspberry Pi. Combined with an Arduino and some off-the-shelf remote control sockets, it makes controlling AC appliances easy. You can add temperature sensors, and even control your TV – but we’ll be keeping things basic today and extending the project in a later tutorial.

Here’s a breakdown of the project:

  • The Raspberry Pi will act as the brains and the gateway of operations – it will run a Node app, tied to a Mongo database, and serve the front-end interface to any web browser.
  • An Arduino, powered from the Pi, will interface between the electronics – radio control power switches, for now.

To do this, you will need:

  • Arduino and a Raspberry Pi
  • Some remote controlled sockets and controller (I used these)
  • Powered USB hub



Before we begin, here’s a demo video from the project creator himself.

Start Afresh

We’re going to use Raspian for this project 23 Operating Systems That Run on Your Raspberry Pi Whatever your Raspberry Pi project, there's an operating system for it. Here are the best Raspberry Pi operating systems! Read More , and I’d strongly suggest starting from a fresh install if you’ve previously performed other hacks and such. Download the latest Raspian image, copy it to your SD card, and be sure to expand the filesystem and enable SSH. The rest of this guide will assume you’ve done so, and are connecting over SSH using the default user.

If you haven’t done this before, this video explains the process of preparing your SD card in OS X:

And this one for Windows users:



The installation process is quite laborious, and derived from the instructions here. Unfortunately, these were outdated or not designed for Raspian, so I’ve adjusted them heavily below. The codes below can mostly be pasted in blocks – you needn’t paste one by one. Since we’re compiling a few things on the Pi itself, be warned that this entire process will take a long time. I would say go make yourself a cup of tea – but when I say a “long time”, I mean the best part of a day – so 178 cups would be more appropriate.

All commands should be typed into the Terminal, and you may need to press Enter at some points. These first few commands will update the system and install pre-requisites:

sudo apt-get update 
sudo apt-get upgrade
sudo apt-get install git-core git scons build-essential scons libpcre++-dev xulrunner-dev libboost-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev

Next we need to install Node:

sudo mkdir /opt/node
tar xvzf node-v0.10.2-linux-arm-pi.tar.gz
sudo cp -r node-v0.10.2-linux-arm-pi/* /opt/node
sudo ln -s /opt/node/bin/node /usr/local/bin/node
sudo ln -s /opt/node/bin/npm /usr/local/bin/npm

Add a PATH variable to your profile so that the OS knows where Node is located. Use the nano text editor as follows:

sudo nano /etc/profile

Locate the line that says export PATH and replace it with:

export PATH

Hit Ctrl-X to exit, and Y to save.

You may need to log out and in again for the path changes to take effect, but you can test with the command:

which node

If you don’t get any output pointing to the Node binary, something went wrong.



The next job is to install Mongo. Mongo is a document-based No-SQL database increasingly used by web apps. Unfortunately, this will take forever to install as we have to compile it. While running the following commands you’ll get a lot of errors like:

{standard input}:13085: Warning: swp{b} use is deprecated for this architecture

Don’t worry about these. So, run these commands to install Mongo:

git clone git://
cd mongopi
sudo scons --prefix=/opt/mongo install 
scons -c

When that’s finished, we need a little more setup first to fix permission issues and make sure it’s running on startup.

sudo useradd mongodb
sudo mkdir /data/dbb
sudo chown $USER /data/db
cd /etc/init.d
sudo wget -O mongodb
sudo chmod +x mongodb
sudo update-rc.d mongodb defaults

This last command will launch the Mongo server, and you’ll need to open a new Terminal to continue with the other commands. I’m not entirely confident of this step, so if anyone can correct this in the comments on how to have mongod launching automatically on start up, it would be much appreciated. For now, it works, just not elegantly.

sudo shutdown -r now

Finally, it’s time to install the Heimcontrol.js Node application.

cd ~pi
git clone git://
cd heimcontrol.js
npm install

You can start running the app by typing

node heimcontrol.js

At this point, you should be able to access the control interface with http://localhost:8080 from the Pi, or replace localhost with the IP address if you’re accessing it from a different computer (and you could also set up port forwarding What Is Port Forwarding? Everything You Need to Know What is port forwarding? How can you set it up? Is port forwarding good for gaming? How does it help? Here's what you need to know. Read More to access it from anywhere in the world), so I’d encourage you to poke around and check all is working with the database before attaching the Arduino.


Eventually I’d like a hardwired relay, but for now I’ll be using the safer option of radio-controlled switches.

I’ve used some reasonably cheap £20 sets from Maplin which come with 3 sockets, and opened up the remote control so I could interface directly with the 433 MHz chip inside. I found the instructions for this here.


You can also purchase individual 433 MHz transmitters ready for use on eBay or from hobby electronics suppliers. All you need to is connect the VCC to 5 V on the Arduino, the GNDs, and a single control pin – remember which one you used. (Schematic by Willi Thiel)


The plugin works by sending “tristate codes”, but these will vary by manufacturer. Refer to the RCSwitch documentation to find your exact codes. This wiki guide may help also.

Communication with the Arduino is done using a Node library called duino. Stop the Heimcontrol app if it’s running and install the Arduino bridge using the following command.

npm install duino

The Arduino must have this code uploaded – I suggest you copy and paste to install this from a different computer. It’s essentially a listener program that responds to serial commands from the Pi, but there’s nothing to stop you extending it with your own features.


With the web app launched, go to the Settings menu > Arduino.


From there you can add a new item, choosing RCSwitch method, the pin of your transmitter, and the tristate address code. Remember to save, then head back to the main screen screen for your new button.



After many hours of debugging the code, I found single digit pin numbers weren’t working – make sure your transmitter is placed on pin 10 to be sure.

I also found that the Arduino plugin was hardcoded with incorrect final bits for the tristate codes my receivers needed. A little explanation first: tristate codes consist of 3 bytes of information. The first determines us the network number (1-4), and the second provides the transceiver address (again, 1-4, producing a maximum of 16 addressable sockets). The final byte consists of two bits of padding, plus 2 bits for on/off. Unfortunately, the final byte is hardcoded in to the Arduino plugin – and in my case, the on/off code was incorrect.

I had to manually edit the plugins/arduino/index.js to use the correct codes. If you’re using the same remote control sockets as I am, change lines 80 onwards to:

// Send RC code
if (item.value) {
  return that.pins[].triState(item.code + "FFFF");//change from FF0F
} else {
  return that.pins[].triState(item.code + "FFF0");//change from FF00

Here’s a demo video of everything working:

I’m going to leave it here at this point, but sensor readings and IR remotes are also supported. I’ll probably revisit these at a later date with some more enhancements. If this has all been a little too complex for you, perhaps check out these beginner-friendly Arduino projects 15 Great Arduino Projects for Beginners Interested in Arduino projects but not sure where to begin? These beginner projects will teach you how to get started. Read More .

Related topics: Arduino, Raspberry Pi.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

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

  1. Himanshu Jha
    December 27, 2017 at 5:29 am

    How can I automate homemade lamps using relay driver circuit using the above methods....need your help.

  2. Timi
    April 20, 2015 at 12:15 pm

    "...and opened up the remote control so I could interface directly with the 433 MHz chip inside. I found the instructions for this here...."

    I can't seem to find the link.

  3. xarya
    April 10, 2015 at 10:20 am

    Hi, why i cant install node.js?

  4. Darius
    March 26, 2015 at 6:48 pm

    for some reason y can't download mongodb the code dose not work. it dose not recognize scons

  5. Mahathi
    February 28, 2015 at 10:47 am

    This is very interesting project.

    I am struck in the step of starting the mongo server. am getting the following error when i start the server.

    pi@raspberrypi /etc/init.d $ sudo ./mongodb start
    [FAIL] Starting database: mongodb failed!

    1. If i just type mongod, it is saying no such file or directory, so i started with "sudo ./mongodb start". Is this the write way or just typing mongod should work??

    2. I tried all the solutions given in comments., but no luck.
    I tried to remove the lock on mongod.lock file, but the file is not present anywhere in my system (i checked using find / -name mongod.lock, and also in /var/lib/mongod, but it is not there)

    3. And i found /data/db is empty. is it supposed to be empty?

    Please help me. I am not able to find out where i went wrong.

  6. chrisnelnine
    February 9, 2015 at 5:00 am

    That thumb in the video is going to give me nightmares.

  7. muhsin kbak
    January 11, 2015 at 2:09 pm


    i forgot my user name and password to login heimcontrol.js, what can i do? please help me.....

  8. Thibo
    January 2, 2015 at 12:39 pm


    I have a question. What is the code you need to upload to the arduino? i've tried duino/duino.ino but that doesn't work!

    • James Bruce
      January 2, 2015 at 12:47 pm

      That is the correct code, yes. If it doesn't work, check you have the correct COM port etc set and that communication between the Pi and Arduino is working. I'm afraid I can't offer much more help as this project is now quite old, but you could try the GitHub page.

  9. Steve
    February 15, 2014 at 4:49 pm

    Ok we are nearly there (i'm getting excited). The only thing I cannot figure out is how to connect the pi to the Arduino, is it TXD from the Pi to RXD on the arduino , hopefully not as thats not workng for me. I presumed the Pi would send commands over the serial line to the arduino which would then proccess them. However I am still getting the error
    Error cannot open /dev/

    Any advice on connecting Pi to arduino (which pin to which pin) would be appriciated

    • James B
      February 15, 2014 at 5:34 pm

      You don't connect pins - you plug it into the USB port on the Pi. Sorry for not making that obvious, the thought of connecting pins hadn't occurred to me!

  10. steve
    February 15, 2014 at 1:07 pm

    I decided to restart the whole processes after inadvertently missing a step out, however I get an error when i try to do the following

    sudo mkdir /data/db
    error mkdir: cannot create directory '/data/db'; No such file or directory

  11. david gardner
    February 15, 2014 at 10:42 am

    hi guys

    will give it a go over the weekend, works been busy so all projects were put on ice :)

    will keep you posted


  12. Steve
    February 14, 2014 at 8:15 pm

    I have now found a raspbian image without NOOBS and am starting the install over again. i am itching to try all this out, think its gonna be a late night for me

  13. steve
    February 14, 2014 at 6:24 pm

    Im also having problems and really keen to get this sorted. I am no expert infact a complete noob but this bit doesnt seem correct
    sudo mkdir /data/dbb

    the dir wont create if i create each seperatly then they create.
    sudo mkdir /data/dbb
    also note the next line "db" is referenced however in the previous line its "dbb" am I being stupid?
    sudo chown $USER /data/db

    Finally does anyone have a link to the none NOOBS raspian image as I thought i would give that a go.
    Thanks in advance

    • James B
      February 14, 2014 at 7:19 pm

      You're right - that should be db, not dbb.

  14. Rui S
    February 12, 2014 at 1:37 pm

    thanks for the quick reply!
    I've tried that command before but It always says "No such file or directory".
    Here's a print showing:

    Can I find that file in another place?
    Do you know another way to solve this problem?

    Thanks again

  15. Bene
    February 6, 2014 at 10:56 pm

    @david gardner..Try deleting lock-file from mongodb?

    • Rui S
      February 12, 2014 at 12:12 am

      Hi @Bene,
      I'm having the same problem as @david gardner.

      Could you explain how to delete the lock-file from mongodb?
      I've followed every tutorial on the web to fix that error:
      pi@raspberrypi /etc/init.d $ sudo ./mongodb start
      [FAIL] Starting database: mongodb failed!

      and I can't find an answer.
      Please Do you have time to post the commands?
      I would really appreciate.

    • Bene
      February 12, 2014 at 8:14 am

      Hi, I solved it with:
      • Manually remove the lockfile: sudo rm /var/lib/mongodb/mongod.lock
      • reboot ^^

    • Rui S
      February 12, 2014 at 9:48 pm

      thanks for the quick reply!
      I’ve tried that command before but It always says “No such file or directory”.
      Here’s a print showing:
      Can I find that file in another place?
      Do you know another way to solve this problem?


      P.S. Sorry for the re-post of this question...

  16. Marc
    February 4, 2014 at 6:54 pm

    Nice project, I am thinking of doing similar myself.
    I don't see why you should use 2 differtent computers for this.
    IMO Raspberry PI should be more than powerfull enough to do the task, and it also has I/O ports, so what is the rationale behind this ?

  17. david gardner
    February 3, 2014 at 8:31 pm

    back again and still no luck, not using NOOB tool, im using 2014-01-07-wheezy-raspbian which i run update on. mongo is failing to auto run, status says not started and if i try and start it i get.....

    pi@raspberrypi /etc/init.d $ sudo ./mongodb start
    [FAIL] Starting database: mongodb failed!

    anyone have a prebuilt image of their SD card or can you get in added to the repository seeing as its a popular DB app? i've run over this about 6 times now and its getting a little tiresome and i hear this pi is going to end up in the microwave :P


    • steve
      February 15, 2014 at 2:02 pm

      is /data/db directory in the root

  18. George
    February 3, 2014 at 10:18 am


    Great project!

    However, I am just in the process of installing and setting up everything.

    I had to add sudo command to the following commands, did I miss something from your instructions or is your instructions missing this information?


    tar xvzf node-v0.10.2-linux-arm-pi.tar.gz

  19. Daniel
    February 2, 2014 at 8:26 pm

    Hey could you take a look at this. I have tried fresh installs of this project 7 times. I think I'm really close but I keep getting this error and can not figure out how I am to resolve it. Any suggestions would be appreciated.

    I got my mongodb up and running and
    This is the error I get after i run node heimcontrol.js:

    info - started
    connect.multipart() will be removed in connect 3.0
    visit for alternatives
    connect.limit() will be removed in connect 3.0
    heimcontrol.js listening on port 8080

    throw er; // Unhandled 'error' event
    Error: Cannot open /dev/

  20. Riaan
    February 1, 2014 at 12:11 pm

    Please help how to i run this heimcontrol.js on startup having to time in the command every time i reboot is not fun

  21. david
    January 31, 2014 at 6:08 pm

    yes, clean install but my linux skills are alittle noob but I going over it again, might have fluffed the path part :)

    also might be good to add that when editing in nano, save by pressing ctrl-x, y for yes and Enter to accept name ( told you i was noob)

    will keep you posted but again thanks for you help and this is a very cool project

    • James B
      January 31, 2014 at 7:02 pm

      I wonder - are you using the RPi "noobs" boot image? The one where you get to choose which OS to start from? Might be worth trying to re-image the SD card as plain Raspian without the added noobs tool.

  22. Mark
    January 31, 2014 at 12:33 pm

    Does anyone have a prebuilt image of this hacking working
    That's all I get is error after error also can you confirm what the layout of codes to control the plugs are

    I have been reading that the first four digits are which band the plugs are on
    i.e FFF0
    The next four are which plug the pi is taking to
    i.e FFFF
    The next two are not used
    i.e FF
    The next two are the on or off bits
    i.e F0 or FF
    The last bit is not used

    So the complete code would be as below


    • James B
      January 31, 2014 at 12:47 pm

      Did you follow through the complete article? I detail a bug concerning tristate codes right at the end, which might be relevant in your case.

      Otherwise, confirming tristate codes is easier when you're just dealing with the Arduino - just use the sample RCSwitch code to experiment with different tri-states.

      Also, you've mentioned you're getting errors: post them so we can see. Not sure if it was a typo, but you wouldn't put "S" in a tri-state code at all, since it isn't a hex value.

    • George
      February 4, 2014 at 12:28 pm

      I had the same issue, it seems to be a fairly common issue:.

      just add following to mathkernel:

      # start/stop mathematica daemon.

      # Provides: mathematica
      # Required-Start: $network $local_fs
      # Required-Stop: $network $local_fs
      # Default-Start: S 2 3 4 5
      # Default-Stop: 0 1 6
      # Short-Description: Mathematica remote services
      # Description: Allows remote use of Mathematica.
      ### END INIT INFO

  23. david
    January 29, 2014 at 9:29 pm


    think this a good project, going through the steps now and hit a problem with " fix permission issues and make sure it’s running on startup"

    I get the following error

    pi@raspberrypi /etc/init.d $ sudo update-rc.d mongodb defaults
    update-rc.d: using dependency based boot sequencing
    insserv: warning: script 'mathkernel' missing LSB tags and overrides

    any ideas?

    • James B
      January 30, 2014 at 8:56 am

      Sounds very random - did you start from a clean install?

    • mike
      February 2, 2014 at 10:52 am

      I got the same error, first i used the old instructions, then i found this page and restarted from a clean install. But with no luck,...

      pi@raspberrypi /etc/init.d $ sudo chmod +x mongodb
      pi@raspberrypi /etc/init.d $ sudo update-rc.d mongodb defaults
      update-rc.d: using dependency based boot sequencing
      insserv: warning: script 'mathkernel' missing LSB tags and overrides
      pi@raspberrypi /etc/init.d $ mongod
      -bash: mongod: command not found

      Both times i was using 2014-01-07-wheezy-raspbian, maybe I should use another build?

    • Garrett
      February 5, 2014 at 3:05 am

      I'm also getting this error. Any help?

    • James B
      February 6, 2014 at 9:34 am

      Check out the comment from George, below.

  24. tim
    January 22, 2014 at 9:18 am

    Hi, I'm really interested in doing this, is this all I need?

    Arduino and a Raspberry Pi
    Some remote controlled sockets and controller (I used these)
    Powered USB hub

    Do I need a Soldering Iron? A breadboard? Jumper wires?


    • James B
      January 22, 2014 at 9:20 am

      You will need a soldering iron, yes, as well as jumper wires and a breadboard for testing. Sorry, I assumed those would be in your inventory if you're taking on this kind of project.

    • tim
      January 23, 2014 at 8:32 pm

      Thanks for replying :) I already have a raspberry pi which I've used for other projects. I don't have a soldering iron because I've never had a need for one.

      This project is what I need, I have no central heating, so electric heaters are all I have. Living in Norway, you want your house to be warm when you get home without leaving the heating on full all day. If I can get this all working, I will defiantly add temp sensors later!

    • tim
      January 29, 2014 at 10:40 pm

      I found this, and it has a 433mhz Transceiver. Would I be able to use this with the wireless controller pluga you use in your guide?

    • James B
      January 30, 2014 at 8:51 am

      Technically speaking, yes, but it looks like it's designed to fit on a Raspberry Pi rather than the Arduino, in which case the RPi software part of this project isn't compatible. There's a similar RC-Switch library for RPi, I believe, it's just that it would be up to you to integrate it with the other software components.

    • tim
      January 30, 2014 at 10:03 pm

      OK, thanks for the reply. I'll do some digging and see what I find .

  25. Bene
    January 21, 2014 at 11:39 pm

    Hello. I was wonderring if this works without an Arduino. I saw that there is something like rcswitch-pi to send via the 433 Mhz transmitter directly. Why do I need the Arduino?

    Thank you for the great guid! :)

    • James B
      January 22, 2014 at 9:27 am

      Interesting; but if you want to use this particular Node.js app, you will need the Arduino until it integrates with the other library you mentioned. You could write your own of course, and only use the rcswitch-pi thing.

  26. Ravi Thapliyal
    January 19, 2014 at 9:23 am


    i was wondering that can we run a raspberry-pi or arduino for 24 hours X 365 days?
    is it that durable?
    can we do the home automation stuff with PLC system?

    • James B
      January 19, 2014 at 9:24 am

      I don't know what PLC is, but there should be no issues with running Pi/Arduino on 24/7. Unless you're mining bit coins on the Pi or something, it won't burn out.

  27. Martin @ Hayling Islane
    December 1, 2013 at 8:50 am

    Been messing about with the plugs from maplin and just an arduino just using delay(delay time) to control plugs


    delay(n *60 * 1000) // Hours delay from midnight
    mySwitch.switchOn(4, 2) // Switch Desk lamp on
    mySwitch.switchOn(4, 4) // Switch Floor lamps on (6)
    delay(on time)
    mySwitch.switchOff(4, 2)
    mySwitch.switchOff(4, 4)
    delay(off time)
    mySwitch.switchOn(4,4) // on all night till midnight
    delay(on time till midnight)
    mySwitch.switchOff(4, 4)

    Loop ..

    Basic timer just has to be started at midnight ...

  28. mattadlard
    November 24, 2013 at 8:55 pm

    Love the project and been really studying it, however curious to know hw one would go about adding more transmitters if one had these over a larger emplacement and need to have say 4 transmitters to ensure coverage?


    • James B
      November 25, 2013 at 10:40 am

      Difficult as it is - one way would be to edit the Arduino side of things to send the same signal out over different pins. I don't know enough about electronics to know if you could just split one signal to different chips with some kind of amplifier though.

  29. tim
    October 30, 2013 at 1:50 pm

    Been racking my brain trying to figure out why heimcontrol will not start.

    $ node heimcontrol.js

    info - started
    connect.multipart() will be removed in connect 3.0
    visit for alternatives
    connect.limit() will be removed in connect 3.0

    heimcontrol.js listening on port 8080

    events.js:2817: Uncaught Error: Cannot open /dev/
    events.js:2817: Uncaught Error: Cannot open /dev/

    throw er; // Unhandled 'error' event
    Error: Serialport not open.
    at SerialPort.write (/home/pi/heimcontrol.js/node_modules/duino/node_modules/serialport/serialport.js:257:15)
    at Board.sendClearingBytes (/home/pi/heimcontrol.js/node_modules/duino/lib/board.js:112:15)
    at null._onTimeout (/home/pi/heimcontrol.js/node_modules/duino/lib/board.js:37:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

    • Brian Easley
      November 9, 2013 at 2:18 pm


      You need to have the usb cable plugged into your arduino when starting heimcontrol.

  30. Peter
    October 17, 2013 at 6:59 am

    Hello there and thanx a lot for sharing all this information. I'm currently working on the same home automation idea but software will be my implementation on java using a raspberry pi/arduino. I wanted to ask you if you believe for us owners of pi if it's worth to use only a pi and not an arduino. I think there are some modules you can find for pi but i don't have a clear image anyway. Also if you can recommend a module to wire it up on switch directly cause rf sockets are fun but i want a more advanced solution.Thanks in advance & keep up the good work!

    • James B
      October 17, 2013 at 7:52 am

      Hi Peter. This article outlines other ways of controlling AC appliances - quite dangerous to play with relays and AC current though. //

      This explains how to use GPIO without an Arduino - it's not great, and you would need to adpat most circuits to work with the samller 3.3v provided by Pi. //

    • Son Hoang
      October 27, 2013 at 8:16 pm

      my friends;

      You don't need to waste money on arduino ( you have to add more power supply, jumper cables). I just finished my project: one simple RF transmitter module (3 pins) add to Raspberry PI and control over 1000 channels/devices in your home. Don't need any additional hardware. You can search on google for rfCommandMe. I'm going to make a youtube video to show user how to implement HVAC control, light, fan, garage, sprinkler, Power Strip, or anything to do with electric current . Hope this will help your HOME AUTOMATION PROJECT.

    • James B
      October 27, 2013 at 8:35 pm

      "no additional hardware" - except for all those 1000s of RF controlled plugs, presumably?

    • son hoang
      November 23, 2013 at 7:00 am

      Here is the one only use Raspberry PI

    • son hoang
      November 23, 2013 at 7:02 am

      Here is video for one RF Transmitter and 1 Raspi control up to 1000 Channels Devices. Check it out and have fun

  31. Ash
    October 4, 2013 at 10:12 am

    Hi James

    Thanks for the quick reply! I have the exact same plugs and remote and have set both the remote and receiver to setting one. I have wired three wires as per tutorial: 1 to +, 1 to -, one to DOUT.

    I am running arduino on PC first before moving to use on Raspberry Pi.
    I am running arduino from PC USB port and have tried running the following sketch:

    Example for different sending methods

    Need help? [Broken URL Removed]


    RCSwitch mySwitch = RCSwitch();

    void setup() {


    // Transmitter is connected to Arduino Pin #10

    // Optional set pulse length.
    // mySwitch.setPulseLength(320);

    // Optional set protocol (default is 1, will work for most outlets)
    // mySwitch.setProtocol(2);

    // Optional set number of transmission repetitions.
    // mySwitch.setRepeatTransmit(15);


    void loop() {

    /* See Example: TypeA_WithDIPSwitches */
    mySwitch.switchOn("11111", "00010");
    mySwitch.switchOn("11111", "00010");

    /* Same switch as above, but using decimal code */
    mySwitch.send(5393, 24);
    mySwitch.send(5396, 24);

    /* Same switch as above, but using binary code */

    /* Same switch as above, but tri-state code */


    This lights up the LED on and off as per the script but unfortunately no change to receiver.
    I tried to look for the arduino plugin js file but couldn't see it in my arduino folders.

    Could you guide me further please on where this file is, what exactly I need to alter in the file and if the above script needs any changes?

    Many thanks once again, I really appreciate it.

    • James B
      October 17, 2013 at 7:56 am

      Sorry for the late reply Ash, didnt get a notification of this.

      First off, try removing the + into the remote. I don't know why this works, but it seems the signal level is strong enough without it. That did it for me.

      The example code is quite different to what I test with - try this instead. The code assumes pin 10 is transmit, and your plugs are set on group 3:


      RCSwitch mySwitch = RCSwitch();

      void setup() {
      mySwitch.enableTransmit(10); // Using Pin #10


      void loop() {
      mySwitch.switchOn(3, 1);
      mySwitch.switchOff(3, 1); // Switch 1st socket from 3 group off


      (yup, thats is)

  32. Ash
    October 3, 2013 at 7:52 pm


    Thanks for sharing the great project.

    I have the remote wired to my arduino as you have in your picture. I am managing to get the led to light when turning the pin on but it is not turning on the socket. Could you please guide me as to the sketch I need to use? Do I need to find the tristate code if I am using the remote wired?

    Sorry for being such a Noob!


    • James B
      October 4, 2013 at 8:21 am

      Hi Ash - are you using the same plugs and remote? If not, it's a bit hard to help with your exact case. If you are, check the addresses on the plugs themselves are inline with the codes you're sending; also, try writing a basic test case for the plugs without any additional logic in there or Raspberry Pi stuff.

      The remote needs to be wired to the arduino, yes - but check using the basic on/off code first without delving into tri-state stuff thats needed for the pi.

      Also, did you make the minor edit needed to the arduino plugin JS file? It's a small change, but critical to making it work with these particular sockets.

  33. Paul
    September 17, 2013 at 8:06 pm

    Many Thanks

    All working now

  34. Paul
    September 17, 2013 at 4:37 pm


    You mentioned "I had to manually edit the plugins/arduino/index.js to use the correct codes"

    How do i edit this ?



    • James B
      September 17, 2013 at 4:41 pm

      in the project directory, type:

      nano plugins/arduino/index.js

      and edit the lines mentioned.

      Press "CTRL-X , y" , to save.

  35. semu
    September 12, 2013 at 9:47 pm

    You can install Ubuntu's MongoDB 2.4.6 armhf packages on a current Debian Sid installation and skip compiling:

    [Broken Link Removed]

  36. Will Anderson
    August 24, 2013 at 10:54 am

    I made something quite similar to this but using purely an arduino (controlled from an iPhone). If you are looking at ways to further the system, I've also used mine to turn on and off the main lights in my house. Check it out if you fancy: