loading

Today I'm going to show you an introduction on home automation with RF signals.

Imagine the middle of the winter, it’s cold and dark outside, but thanks to automation you wake up to a warm and bright room, with a hot cup of coffee steaming by the side of your bed. This is what I'll show you!

Learning to control RF signals from an Arduino opens a world of possibilities. Here's some quick examples of what I've previously done with this technique:

  • Turn things on and off with sound or motion
  • Lights that adjust their brightness according to time of day or how bright a room is
  • Turn on a heating oven or a cooling fan according to temperature
  • Automatically turn of your 3D printer when it has finished printing

If you like this tutorial please press the VOTE button in the upper right corner!

Let’s get started!

Click here to see the video

Step 1: Parts and Tools

You are going to need the following parts:

Step 2: Decoding RF Signals

Let's start with something simple - using the Arduino to send wireless signals!

I connected the RF receiver to 5 volts, ground, and the signal pin to digital pin 2 on the Arduino. Then I downloaded the RC Switch library and uploaded the Receive-Demo-Advanced. You can download the library here.

Now, open up the serial terminal and press any button on your RF remote to decode the signals. The information that pops up in your serial terminal is what we'll be transmitting later on.

I went ahead and decoded all the buttons and stored them in a text file for quick reference.

Step 3: Transmitting RF Signals

Let's try and duplicate the remote with an Arduino.

Power the transceiver, and connect the signal wire to digital pin 10.

Open the example Send Demo and look at lines 39-42. This is what we're interested in to transmit decimal values for your code. Here you’ll insert the signals you want to transmit. This is what we just decoded and saved from the remote.

Upload the sketch and your outlet should start to toggle at each second. And that’s awesome! You just learned how to control outlets from a micro controller. This will be the basis for your home automation! Lets add some sensors and make the code more interesting!

Step 4: Example: Temperature Sensor

We'll start by controlling a room heater:

Connect the temperature sensor to the breadboard and the Arduino. Looking at the side without the sticker, pin 1 is on the left and pin 4 is on the right:

  • Pin 1 - 5V.
  • Pin 2 - Data out, D2.
  • Pin 3 - No Contact.
  • Pin 4 - GND.
  • 10k ohm resistor between pin 1 and pin 2

The example code I uploaded works by constantly reading the temperature in the room and comparing it to the temperatures I prefer. This will in turn send RF signals to the outlet we just learned to control!

Now just plug in the RF outlet between the oven socket and the wall outlet. You've automated the heating in your room, as quick as that!

You'll have to adjust the code based on what temperatures you prefer. I set my oven to turn on at 19 degrees and turn off at 26 degrees. You can adjust these temperature values in line 20 and line 24.

You can use any number of temperature sensors. If you chose a DHT11 or a DHT22 click here to download their library.

Step 5: Example: Light Sensor

Now, let’s control a LED dimmer! I used a photo resistor as a sensor to detect the light level in my room. Click here to see how I made the LED panel.

The code I wrote monitors the ambient light level, and if the room gets too dark the Arduino transmits the signal to turn on my LED panel. Also, the longer the room has been dark, the code sends signals to increase the brightness. How cool is that!

The LED panel will also automatically turn off again if the sensor detects enough light in the room.

To use a photoresistor as a light sensor we need to create a voltage divider. A photoresistor works by changing resistive value based on how much light is hitting the resistor. Microcontrollers are not so good at reading changes in electrical resistance, but they are good at reading analog changes in voltage.

We will utilize this by creating the voltage divider from the photorestior and a 10k ohm resistor. Start by wiring the 10k ohm resistor and the photoresistor in series. Connect 5V from the microcontroller at the 10k ohm resistor, and connect GND to the open end of the photoresistor. Now, we can read the change in voltage by connecting a wire to the junction where the 10k ohm resistor and the photoresistor connects. Connect this wire to analog input 0 on the Arduino.

Upload the sketch to your microcontroller and open up your serial terminal, we'll use this to calibrate the light levels. Note the light levels at which you want your light or LED panel to turn on and off. Enter these values in line 9 and 10 to calibrate the code for your room.

Step 6: Example: Real Time Clock

Let’s try something a bit more advanced. I'm connecting an RTC, which is a precise way of telling time on micro controllers. The RTC has it's own battery so you don't have to worry about powering down. I read somewhere that this battery should keep the module powered for about nine years!

Connect the RTC like this:

  • Pin 1, SDA - A4.
  • Pin 2, SCL - A5.
  • Pin 3 - No contact
  • Pin 4 - GND.
  • Pin 5 - 5V

The example code I wrote reads the time of day from the RTC module. When you upload the sketch to your Arduino the serial terminal reads the time and date on the computer and uses this to set the time and date on the RTC. Thay way the RTC gets a super precise starting point!

After the code is read on the microcontroller it is compared to a set time for when you wan't your outlet to toggle. This set time can be changed in line 23. Where the sketch performs an if-test on the hour of the day and the minute of the hour.

The way this is written the microcontroller will turn on my kettle each day at 6 am, boil the water, and switch it off again five minutes later. I'm using this to start each morning with hot water ready for a cup of coffee!

Click here to download the RTC library and learn more about how it works.

Step 7: Final Thougths

Watch the video to see how I put together the project!

As stated in the introduction there's a lot of possibilities with an Arduino and the know-how to control RF signals.

Now you have a great starting point to expand upon the technique and examples in this Instructable!

To give you some inspiration think about how you would solve the following tasks:

  • Turn things on and off with sound or motion
  • Lights that adjust their brightness according to time of day or how bright a room is
  • Turn on a heating oven or a cooling fan according to temperature
  • Automatically turn of your 3D printer when it has finished printing

If you like this tutorial please press the VOTE button in the upper right corner!

Click here to see the video

<p>Is it possible to give the receiver codes, thanks</p>
<p>Very good read! Definitely my next project. Thanks!</p>
<p>I'm happy you liked it mate! Hope you'll give an update on how it goes!</p>

About This Instructable

11,186views

259favorites

License:

More by Sverd Industries:Gift Away Your Heartbeat for Valentines Day! | Arduino Tutorial Cacio E Pepe - Cheesy Comfort Pasta 3D Printed Utility Desk Shelf! - Video 
Add instructable to: