Cheap, Easy Raspberry Pi Home Automation (for Australia) [Part 1]

watssclever2

In my hacking adventures I came across these awesome, super-cheap wirelessly controlled mains power outlets from Jaycar Electroncis in Australia. [UPDATE: This can also be used, but you need to get a 433Mhz transmitter separately]. They are on clearance, which means they are $5 per outlet, so you better read on and get some before they disappear. Don’t be fooled by the fact they are supposedly IR controlled, in truth they aren’t! The IR receiver unit that comes with the kit contains a ubiquitous 433Mhz wireless radio module. Once you know the wireless protocol, it’s straightforward to send commands from a transmitter attached to anything…

Enter the Raspberry Pi

Someone, somewhere has already written code for whatever you want to do on a Raspberry Pi*, all we need to do is put two things together. There is already the rcswitch-pi library which allows sending remote control codes over 433Mhz modules. With minor tweaks I was able to turn the Jaycar sockets on an off remotely from the command line! From here the possibilities are endless. The Raspberry Pi can automate lights, appliances, sprinkler systems, hydroponic systems, etc. And the cost is only AUD $5 per outlet!!! For this post I will explain how to set up a basic system and control it from the command line. In the next post I plan on explaining how to schedule events using cron. Eventually I plan on developing a simple web interface or integrate it into an existing home automation system.

The Steps

I’m assuming you already have a Raspberry Pi setup running Raspbian or similar, and you have a basic knowledge of the command line.

  1. Take apart the IR receiver box and extract the 433Mhz module. It’s a small green circuit board, seen here attached to an adapter I made. I made a new antenna from a piece of copper wire that is exactly 17.3cm long to try and improve the range.433
  2. Connect it to the Raspberry Pi’s GPIO header. The 433Mhz module has pins labelled:
      DATA – Connect to any numbered pin (see WiringPi diagram)
      GND – To GND on the RaspPi
      VCC – Connect to 3.3V on the RaspPi (NOT 5V!)
      ANT – Antenna

    WiringPi-GPIO-Pinout

  3. Install the wiringpi library using git, explained here.
  4. Grab a copy of my tweaked rcswitch-pi code to your home directory, using git:
    cd ~
    git clone https://github.com/guywithaview/rcswitch-pi
  5. Go into the rcswitch-pi folder and build the code using:
    cd rcswitch-pi
    make
  6. Plug one of the outlets into a power point and switch the power point on. The red LED on the front should flash which means it’s ready to be associated with a code. The following steps should associate the outlet.
  7. Run the command to turn ON (replace PIN with the pin number the 433Mhz module is connected to):
    sudo ./send PIN 0 1
  8. The red LED should flash. Run the command to turn OFF:
    sudo ./send PIN 0 0
  9. The outlet should now be associated as unit 0! Running the ON command should turn it on and running the OFF command should turn it off. Repeat with other outlets one by one, and assign them each a unique unitNumber.

The format of the send command is:

sudo ./send <pin> <unitNumber> <command>
    Where <pin> is the wiringpi pin number. NOT the GPIO pin number.
    The <unitNumber> identifies the device. Eg: 0, 1, 2, 3…
    The <command> is either 0 to turn OFF the outlet, or 1 to turn ON the outlet.

Have fun! Next will be a simple demonstration of how to schedule outlets to turn off and on using cron.

*maybe
Advertisement
This entry was posted in Automation, Projects and tagged , , . Bookmark the permalink.

1 Response to Cheap, Easy Raspberry Pi Home Automation (for Australia) [Part 1]

  1. Pingback: Simple Home Automation Web Interface [Part 3] | Mechinations

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s