Introduction: How to Make an Universal TV Remote Control With Cayenne IoT

Picture of How to Make an Universal TV Remote Control With Cayenne IoT

Hi! I'm Neoxelox! In this project I will show you how to turn your mobile phone to an Universal TV remote control with Cayenne IoT APP!

We need:

- Cayenne Account

- Arduino (Obviously)

- IR Emitter (Mine is KEYES IR Emitter)

- Arduino ethernet shield (Mine is W5100)

- IRremote library: http://www.mediafire.com/file/noes8859gos4ka4/Arduino-IRremote-master_%281%29.zip

- Some TV remote controls (if you don't know their IR codes)

If you don't know this, you can dumb your remote control with this library and with a IR Receiver (In the library you have and example of "Dump", just execute that and press the buttons of your remote control).

Step 1: Connect the IR Emitter to Arduino and Also the Triggers

Picture of Connect the IR Emitter to Arduino and Also the Triggers

Connect the IR Emitter to Arduino board.

Pinout:

IR Emitter / Arduino

pin "-" ---> pin GND

this pin doesn't have any letter so, the middle pin ---> pin 5V

pin "S" ---> digital pin 3 or other digital pin (It cannot be pin 0,1,2 or 13)

Triggers:

I was thinking what is the easiest way to do this project, and I realized if we connect a wire through digital pin 9 to 8 and digital pin 7 to 6 is the best way to do it, so:

Connect Arduino digital pin 9 to Arduino digital pin 8, repeat with 7 to 6.

Step 2: The Code

Picture of The Code

I was lucky and this library also has a specific IR command for Sony's TV remote controls, so I just search a lot in the internet and I found this page http://files.remotecentral.com/library/3-4/sony/te... which has the IR Codes of the remote control buttons :D . NO ALL IR CODES OF THAT PAGE WORKS!!! For example there is one PowerOn/Off comand that doesn't work.

If you do it with raw code, you have to put this line after the line 33 (you have to know what speed you IR Emitter works with (mine 38 khz):

int khz = 38;

Just copy that (Obviously you need to change the line 33 with your IR Emitter digital pin.

/*
Cayenne Button Widget Example

This sketch shows how to set up a Button Widget with Cayenne.

The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps: 1. In the Cayenne Dashboard add a new Button Custom Widget. 2. Select a digital pin number. Do not use digital pins 0 or 1 since those conflict with the use of Serial. 3. Attach a digital output device (e.g. a LED) to the digital pin on your Arduino matching the selected pin. 4. Set the token variable to match the Arduino token from the Dashboard. 5. Compile and upload this sketch. 6. Once the Arduino connects to the Dashboard you should be able to control the digital output device with the Button widget.

Notice that there isn't much coding involved to interact with the digital pins. Most of it is handled automatically from the Cayenne library.

For further examples of how to receive data from Cayenne see the example sketches under Actuators. */

#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space

// If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples. #include

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard. char token[] = "********";

#include #include IRsend irsend; IRrecv irrecv(3);

unsigned int SpeakersOnOff[] = {0000, 0067, 0000, 000d, 0060, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0030, 0018, 0018, 0018, 0030, 0018, 0030, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 03f2}; unsigned int PowerOnOff[] = {0000, 0067, 0000, 000d, 0060, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0030, 0018, 0030, 0018, 0030, 0018, 0018, 0018, 0030, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0018, 0410};

void setup() { pinMode(8, INPUT); pinMode(6, INPUT); Serial.begin(9600); Cayenne.begin(token); }

void loop() { Cayenne.run(); if(digitalRead(8)==HIGH){ irsend.sendSony(SpeakersOnOff, 20); while(digitalRead(8)==HIGH){} } if(digitalRead(6)==HIGH){ irsend.sendSony(PowerOnOff, 20); while(digitalRead(6)==HIGH){} } }

Step 3: Set Up Cayenne Buttons

Picture of Set Up Cayenne Buttons

Set up Cayenne Buttons as images show.

Step 4: Test Your Awesome Homemade Universal TV Remote Control!

Picture of Test Your Awesome Homemade Universal TV Remote Control!

Test your awesome homemade Universal TV remote control!!! And you finish!

PD:

Cayenne has and APP in the google play store and IOS app store, you can control the TV's with your phone!

Comments