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:


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
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
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 RC: Sony Televisions - Discrete Infrared Hex Codes (Page 4 of 6) which has the IR Codes of the remote control buttons :smiley: . 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 <CayenneEthernet.h> 
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard. 
char token[] = "********"; 
#include <IRremote.h> 
#include <IRremoteInt.h> 
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
Set up Cayenne Buttons as images show.

Step 4: 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!

Really… It happened another time… I don’t know what im doing wrong but the code is not well and I don’t know how to edit my post yet!!! :frowning:

No worries, this forum software took some getting used to for me too when first getting started with it :slight_smile: It’s difference than a lot of the others on the web.

Just linking the same response I made in your other thread, you’re looking for a pencil icon in your post which will allow you to edit. Let me know if you’re still stuck:

Thanks!