loading
Picture of Infrared-RF 433-Bluetooth Arduino Remote
Having seen several tutorials on home automation, I thought it would be cool to take on an all in one remote control box that contained infrared protocols to turn on the tv, rf 433 protocols to control lighting and other household electronics and transmit and receive Bluetooth commands. Most importantly do it on the cheap. I use a web interface to send BT signals from a RPI (this is out of the scope of this tutorial but pretty cool stuff).   I hope you enjoy and maybe spark more ideas. Before we start I have to give several others credit as none of this is original, many thanks folks.
IR Tutorial/Library
Ken Shirriff  http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
Bluetooth and Arduino
Mohannad Rawashdeh http://www.instructables.com/id/Arduino-AND-Bluetooth-HC-05-Connecting-easily/
RF Tutorials/Library
Suat Özgür  http://code.google.com/p/rc-switch/
Ray Wang http://rayshobby.net/?p=2427
BIG THANKS!!!!!
 
Remove these adsRemove these ads by Signing Up

Step 1:

Picture of

Materials used in this project and source

Arduino UNO R3 board with DIP ATmega328P, Amazon.com

Arduino Wireless Bluetooth Transceiver Module Slave 4Pin Serial + DuPont Cable, Amazon.com

Infrared Receiver, Amazon.com

Infrared LED, Old remote

433M receiver module 433MHZ Superregeneration Wireless Transmitter Module, Amazon.com

Jumper Wires, Amazon

Etekcity® 5 Pack Wireless Control Electrical Outlet Switch Socket with 1 Remote, Amazon.com

Sanyo TV with IR Remote, Already had.com

Step 2:

Picture of
I am not going to devote to much time to this I found that Ken Shirriff’s http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
Has done an excellent job of demonstrating the codes receive process, after you follow his physical and virtual setup loading the IRrecvDump sketch.
Next open Arduinos IDE serial monitor
Point your IR remote to the IR Receiver on the Arduino, press each button from top left to working your way down. It may not need to be said but keep track of your remote button pushes
OUTPUT I GOT LOOKED LIKE THIS “Decoded NEC: 1CE348B7 (32 bits)”
In the serial monitor you will begin to see values appear, once completing with the remote buttons copy these values into a text editor, notepad would be fine,  Using the text editor note each code and save for later, I did this:
TVINPUT,1CE3C837
TVPOWER,1CE348B7
TVINFO,1CE330CF
TVPIXSHAPE,1CE3EA15
TVAUDIO,1CE358A7
TVRESET,1CE338C7
ETC…

Step 3:

Picture of
Learn the RF remote codes
To learn the codes I used Suat Özgür’s library http://code.google.com/p/rc-switch/ , (I could not get the library to send the learned codes)
Save and add the following link to your Arduino IDE  http://rc-switch.googlecode.com/files/RCswitch_2.51.zip
Following the steps provided with one modification, instead of using ReceiveDemo I used  RecieveDemo_Advanced
Following the instructions I received the following on the serial monitor:
Decimal: 1922051 (24Bit) Binary: 0001110101010100000000110 Tri-State: 0F1FFFF00001 PulseLength: 162 microseconds Protocol: 1
Raw data: 5036,120,524,116,528,116,524,444,204,440,200,444,200,120,528,440,216,128,592,532,252,152,688,608,288,172,792,708,376,228,1276,436,2580,1224,524,124,524,120,528,116,524,124,528,116,528,440,200,444,200,
I saved the binary from each button push in a text editor
1. 000111010101010000000011
2. 000111010101010000001100
3. 000111010101010000110000
4. 000111010101010011000000
5. 000111010101011100000000

Step 4:

Picture of
Now that the codes have been captured we can begin physically building the Arduino: 
Connect your ir led to the GND and #3 Pins
Connect the rf transmitter data pin to pin 10 on the Arduino
Connect the rf transmitter GND pin to GND pin on the Arduino
Connect the rf transmitter VCC pin to 5V pin on the Arduino (It needs the voltage more than the BT)
Bluetooth can only be connected after the sketch is uploaded

Step 5:

Picture of
Now to load the sketch but before loading, I analyzed each rf code and noticed that each had the same leading 14 digit signature and 10 digit command after I will break the command into two parts (later testing revealed that by manipulating the last ten digits I could control multiple sockets at one time ex 0000110011 toggles socket one and socket three, 1111111111 toggles all the sockets)
The code below is modified from Ray Wang’s original rf sketch  http://rayshobby.net/?p=2427

My Example Sketch

//Use the irremote library
#include <IRremote.h>
IRsend irsend;
// Buffer to store incoming commands from serial port/bluetooth
String inData;
//defines the pin that will send the rf data
int sendPin = 10;
//defines how long to hold a rf burst
#define DELAYSHORT 160
#define DELAYLONG  500

static void ookPulse(int on, int off) {
  digitalWrite(sendPin, HIGH);
  delayMicroseconds(on);
  digitalWrite(sendPin, LOW);
  delayMicroseconds(off);
}
static void pt2262Send(uint14_t signature, uint10_t command) {
  byte i, k;
  // send 14 times
  for(k=0;k<14;k++) {
    // send signature first
    for(i=0;i<14;i++) {
      if((signature>>(13-i)) & 0x1) {
        ookPulse(DELAYLONG, DELAYSHORT);
      } else {
        ookPulse(DELAYSHORT, DELAYLONG);
      }
    }
    for(i=0;i<10;i++) {
      if((command>>(9-i)) & 0x1) {
        ookPulse(DELAYLONG, DELAYSHORT);
      } else {
        ookPulse(DELAYSHORT, DELAYLONG);
      }
    }
    // end with a '0'
    ookPulse(DELAYSHORT, DELAYLONG);
    // short delay
    delay(5);
  }
}
void setup() {
Serial.begin(9600);   
pinMode(sendPin, OUTPUT); 
}
void loop() {
    while (Serial.available() > 0)
    {
        char recieved = Serial.read();
        inData += recieved;

        // Process message when K character is recieved
        if (recieved == 'K')
        {
            Serial.print("Arduino Received: ");
            Serial.print(inData);
if (inData == "TVINPUTK") { irsend.sendNEC(0x1CE3C837, 32); delay(100); }
if (inData == "TVPOWERK") { irsend.sendNEC(0x1CE348B7, 32); delay(100); }
if (inData == "TVINFOK") { irsend.sendNEC(0x1CE330CF, 32); delay(100); }
if (inData == "TVPIXSHAPEK") { irsend.sendNEC(0x1CE3EA15, 32); delay(100); }
if (inData == "TVAUDIOK") { irsend.sendNEC(0x1CE358A7, 32); delay(100); }
if (inData == "TVRESETK") { irsend.sendNEC(0x1CE338C7, 32); delay(100); }
if (inData == "TVCAPTIONK") { irsend.sendNEC(0x1CE38877, 32); delay(100); }
if (inData == "TVSLEEPK") { irsend.sendNEC(0x1CE3B04F, 32); delay(100); }
if (inData == "TVONEK") { irsend.sendNEC(0x1CE3807F, 32); delay(100); }
if (inData == "TVTWOK") { irsend.sendNEC(0x1CE340BF, 32); delay(100); }
if (inData == "TVTHREEK") { irsend.sendNEC(0x1CE3C03F, 32); delay(100); }
if (inData == "TVFOURK") { irsend.sendNEC(0x1CE320DF, 32); delay(100); }
if (inData == "TVFIVEK") { irsend.sendNEC(0x1CE3A05F, 32); delay(100); }
if (inData == "TVSIXK") { irsend.sendNEC(0x1CE3609F, 32); delay(100); }
if (inData == "TVSEVENK") { irsend.sendNEC(0x1CE3E01F, 32); delay(100); }
if (inData == "TVEIGHTK") { irsend.sendNEC(0x1CE310EF, 32); delay(100); }
if (inData == "TVNINEK") { irsend.sendNEC(0x1CE3906F, 32); delay(100); }
if (inData == "TVCHLUPK") { irsend.sendNEC(0x1CE350AF, 32); delay(100); }
if (inData == "TVCHLDWNK") { irsend.sendNEC(0x1CE3D02F, 32); delay(100); }
if (inData == "TVZEROK") { irsend.sendNEC(0x1CE300FF, 32); delay(100); }
if (inData == "TVVOLUPK") { irsend.sendNEC(0x1CE3708F, 32); delay(100); }
if (inData == "TVVOLDWNK") { irsend.sendNEC(0x1CE3F00F, 32); delay(100); }
if (inData == "TVRECALLK") { irsend.sendNEC(0x1CE39867, 32); delay(100); }
if (inData == "TVMUTEK") { irsend.sendNEC(0x1CE318E7, 32); delay(100); }
if (inData == "LIGHTONEK") { pt2262Send(0b00011101010101, 0b0000000011); delay(100); }
if (inData == "LIGHTTWOK") { pt2262Send(0b00011101010101, 0b0000001100); delay(100); }
if (inData == "LIGHTTHREEK") { pt2262Send(0b00011101010101, 0b0000110000); delay(100); }
if (inData == "LIGHTFOURK") { pt2262Send(0b00011101010101, 0b0011000000); delay(100); }  
if (inData == "LIGHTFIVEK") { pt2262Send(0b00011101010101, 0b1100000000); delay(100); }
if (inData == "LIGHTALLK") { pt2262Send(0b00011101010101, 0b1111111111); delay(100); }
if (inData == "LIGHTLRK") { pt2262Send(0b00011101010101, 0b0000001111); delay(100); }
//FLASHES EACH SOCKET ON AND OFF IN A PANIC MODE
if (inData == "LIGHTPANICK") { for (int i = 2; i < 50; i++) {
    pt2262Send(0b00011101010101, 0b0000000011); delay(500);
    pt2262Send(0b00011101010101, 0b0000000011); delay(100);
    pt2262Send(0b00011101010101, 0b0000001100); delay(500);
    pt2262Send(0b00011101010101, 0b0000001100); delay(100);
    pt2262Send(0b00011101010101, 0b0000110000); delay(500);
    pt2262Send(0b00011101010101, 0b0000110000); delay(100);
    pt2262Send(0b00011101010101, 0b0011000000); delay(500);
    pt2262Send(0b00011101010101, 0b0011000000); delay(100);} }

if (inData == "TVMEDIAK") { irsend.sendNEC(0x1CE300FF, 32); delay(500);
                            irsend.sendNEC(0x1CE340BF, 32); delay(500);
                            irsend.sendNEC(0x1CE3D02F, 32); delay(500);
                            irsend.sendNEC(0x1CE3D02F, 32); delay(500);
                          }

            // You can put some if and else here to process the message just like that:

            if(inData == "+++K"){ // DON'T forget to add "\n" at the end of the string.
              Serial.println("OK. Press h for help.");
            }  
inData = ""; // Clear received buffer
        }
    }
}

Step 6:

Picture of
To test I opened the serial monitor and typed in one of the command words above (no newline) if the code uploaded correctly you should see “Arduino Received:” along with the word. If everything went really well an action should have happened in your physical world as well.

Step 7:

Picture of
BTRFIR_REMOTE.png
Remote.JPG
On success unplug the serial cable and power to connect the Bluetooth module
Connect the Bluetooth modules RX pin to the Arduino TX pin
Connect the Bluetooth modules TX pin to the Arduino RX pin
Connect the Bluetooth modules VCC pin to the Arduino 3V pin
Connect the Bluetooth modules GND pin to the Arduino GND pin
Plug Arduino back in and start sending bluetooth commands to the device via your phone or computer
diy_bloke11 months ago

Well done, but I am not sure if I fully understand the coding. Maybe you can help me on my way. If I take the data for instance of your first button:

000111010101010000000011
which you split in:

00011101010101 0000000011
You send those seperately to yr pt2262Send routine.
Now do I understand correctly that yr routine goes through these numbers digit by digit (in the loop) and then sends each digit?
The

#define DELAYSHORT 160
#define DELAYLONG 500

are those the standard times ? or did you also get that from yr analysis?
Why end with a '0'?

Anyway, quite nifty to just make yr own sendroutine. I hadnt even thought of that and was preparing to use the library.
Great work

Raphango1 year ago
Wow Project!
Gonna make it someday! =D