swithing off a mediabox with IR

After succesfully made a an actuator for my thermostate , it is time for the next project.

My audiosystem , Yamaha , I can controll via the plugin , also my Samsung , I can switch off with the plugin installed on vera 3 (with UI5) .
The mediabox, which is quite often forgotten to switch off ( and uses almost all my internet bandwith) has no plugin , just an old fashioned remote controll.

Hopefully I can change this with arduino.

The gateway is allready setup, and all the parts are allready in house to build this:
[url=http://www.mysensors.org/build/ir]http://www.mysensors.org/build/ir[/url]

But I read somewhere on the mysensor forum , it doesn’t work on Vera. Anyone knows if it will work?

More to follow hopefully,
Cor

I can’t help, but i’d be interested to hear if you have had any progress…?

I down have any experience with this setup but I’m quite sure the example from Infrared Sender and Receiver | MySensors - Create your own Connected Home Experience will work with Vera.
The example simply creates a normal light switch in Vera and the “On” command sends one ir code and the “Off” command sens another.

The hard part might be to record the ir code using the receiver and then re-sending it using the transmitter, this is all done in the Arduino and has nothing to do with Vera.

I’m sure there is example code for the arduino out there that you can use to figure out how to record and re transmit the ir code of your choice.

I'm sure there is example code for the arduino out there that you can use to figure out how to record and re transmit the ir code of your choice.

There is a good library and example code for IR receive/transmit with Arduino by Ken Shirriff.

@ RexBeckett: thanks for the link , that should make life more easy :slight_smile:

@Korttoma: No progress so far,it is still very high on my todo list , but time is for the moment my bigest enemy .
I expect to start/continue this project within 2 weeks.

Offcourse I will post here all my findings.

Cor

Here wo go >>>>>>>

Today I have hooked up a IR reciever and transmitter on a arduino uno.
Uploaded the sketch and tried to controll the media box.

No , it isn’t working , i think it is going wrong somewhere reading the IR-code.

Whatever button I press on a remote , it always shows the same code , for the transmitter of the mediabox it is “000000” , for the transmitter of a Yamaha amplifier , it is “ffffff” Every button on those remotes gives the same code, that can not be right.

Using the serial monitor this is confirmed. ( see the copy paste at the bottom of this post).

What is wrong? and what else can I try to read to correct code?

Thanks for the help ,

Cor

Here the output from serial monitor:

connecting at 115200
sensor started, id 105
send: 105-105-0-0 s=255,c=0,t=17,pt=0,l=3,st=ok:1.4
send: 105-105-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
read: 0-0-105 s=255,c=3,t=6,pt=0,l=1:M
send: 105-105-0-0 s=255,c=3,t=11,pt=0,l=9,st=ok:IR Sensor
send: 105-105-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 105-105-0-0 s=3,c=0,t=3,pt=0,l=3,st=ok:1.4
Decoded NEC: Value:5EA1E21C (32 bits)
Raw samples(68): Gap:6094
Head: m8850 s4450
0:m500 s700 1:m450 s1700 2:m450 s700 3:m450 s1750
4:m450 s1800 5:m450 s1750 6:m450 s1800 7:m550 s550
8:m450 s1800 9:m500 s600 10:m550 s1700 11:m500 s600
12:m450 s650 13:m450 s700 14:m450 s650 15:m550 s1700

16:m450 s1750 17:m450 s1800 18:m500 s1700 19:m550 s600
20:m500 s600 21:m550 s600 22:m500 s1700 23:m450 s700
24:m500 s600 25:m500 s650 26:m500 s550 27:m550 s1700
28:m550 s1650 29:m500 s1750 30:m550 s550 31:m550 s600

32:m500
Extent=66250
Mark min:450 max:550
Space min:550 max:1800

send: 105-105-0-0 s=3,c=1,t=24,pt=0,l=8,st=ok:5ea1e21c
Decoded NEC: Value:FFFFFFFF (0 bits)
Raw samples(4): Gap:40500
Head: m8850 s2250
0:m450
Extent=11550
Mark min:450 max:450
Space min:32767 max:0

send: 105-105-0-0 s=3,c=1,t=24,pt=0,l=8,st=ok:ffffffff
Decoded NEC: Value:FFFFFFFF (0 bits)
Raw samples(4): Gap:29764
Head: m8850 s2300
0:m500
Extent=11650
Mark min:500 max:500
Space min:32767 max:0

send: 105-105-0-0 s=3,c=1,t=24,pt=0,l=8,st=ok:ffffffff

It looks as though it is reading something but not identifying the code. Have you tried any other remotes?

I don’t recall having any issues getting Ken’s library working. Do make sure that your IR receiver is the correct voltage for your Arduino. Some only work on a specific voltage (3.3V or 5V), some will work from 3V to 5V. I also find it helps to add a 100nF decoupling capacitor right on the power pin of the receiver.

@RexBeckett: I tried 3 remotes , all 3 give a different code, but for every button it is the same code.

000000, ffffffff , and the last one is something different as well , but I don’t remember.

Just checked the voltage:
[url=http://www.ebay.de/itm/2x-Digital-38KHz-IR-Infrarot-Sensor-Transmitter-Kit-fur-Arduino-LS4G-/400602576265?hash=item5d45c63589]http://www.ebay.de/itm/2x-Digital-38KHz-IR-Infrarot-Sensor-Transmitter-Kit-fur-Arduino-LS4G-/400602576265?hash=item5d45c63589[/url] 5v , that’s correct.

100nF decoupling capacitor: I will get one of those today and try again.

Thanks for your help,
Cor

Digging back in my code archive, I found this sketch. I used it for early debug work on my IR receiver. It just prints the received codes including the raw data converted to Kira format.

Thanks RexBeckett,

It might be working ( with your sketch) , initially I recieved the same codes 000000 and fffffff, but suddenly I recieved something else. and for every button a different code , so that’s good news.

For the button I need , it spits out this code: 4CB0FADF

But no clue what I have to do with it, I inserted it in the mysensor sketch likt this:

[code]void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
int incomingRelayStatus = message.getInt();
if (incomingRelayStatus == 1) {
irsend.send(NEC, 4CB0FADF, 32); // on off mediabox
} else {
irsend.send(NEC, 0x1EE1F807, 32); // Vol down yamaha ysp-900
}
// Start receiving ir again…
irrecv.enableIRIn();

[/code]

But than I recieve an error message from codebender when I verified and tried to upload.

I tried this:

void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { int incomingRelayStatus = message.getInt(); if (incomingRelayStatus == 1) { irsend.send(NEC, 0x4CB0FADF, 32); // on off mediabox } else { irsend.send(NEC, 0x1EE1F807, 32); // Vol down yamaha ysp-900 } // Start receiving ir again... irrecv.enableIRIn();

No error message from codebender , but it also doesn’t work.

Any idea what I am doing wrong this time?

edit

Oh … this is wierd!!!

I wanted to try again and with the serial monitor I read the infrared code , it is different now.

Here the copy paste , I pressed THE SAME button several times:

connecting at 115200 Unknown encoding: 4AB0F7B6 (32 bits) Raw (6): 9248 800 -4000 150 -650 150 K 263 1E 99 5 19 5 2000 Unknown encoding: 8FDE36A7 (32 bits) Raw (8): -27714 400 -650 200 -2350 150 -800 450 K 264 F 19 7 5A 5 1E 11 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -20940 750 -1000 400 -1700 2000 K 263 1C 26 F 41 4C 2000 Unknown encoding: FEAC02E4 (32 bits) Raw (6): 24356 400 -3200 550 -700 600 K 263 F 7B 15 1A 17 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -6800 400 -650 150 -2350 1450 K 263 F 19 5 5A 37 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -28614 400 -550 250 -2350 1900 K 263 F 15 9 5A 49 2000 Unknown encoding: A7E5F685 (32 bits) Raw (8): -28164 400 -300 550 -2300 1450 -300 650 K 264 F B 15 58 37 B 19 2000 Unknown encoding: 4AB0F7B6 (32 bits) Raw (6): -27864 800 -3100 600 -650 600 K 263 1E 77 17 19 17 2000 Unknown encoding: 24AE7D4F (32 bits) Raw (6): -27714 650 -3400 600 -650 600 K 263 19 82 17 19 17 2000 Unknown encoding: 24AE7D4C (32 bits) Raw (6): -21994 150 -3850 150 -700 550 K 263 5 94 5 1A 15 2000

With the decoupling capacitor , nothing is working , when I press a button on the remote , no response at all.
Thanks,
Cor

With the decoupling capacitor , nothing is working , when I press a button on the remote , no response at all.

The decoupling capacitor should be connected between the 5V power pin of the IR receiver and ground. If it stopped working, you probably connected it to the data pin.

I notice that you removed the short delay I had in my code before re-enabling the IR receive function. It was there for a reason…

But no clue what I have to do with it...

I don’t know how I can help you with that. It depends on what you want the finished device to do. If you only need the ability to send on or off commands, you could just hard-code the values you find using the IR dump sketch. Presumably there is some appropriate binary switch sketch on MySensors that you could use as a base.

Oh h… the decoupling capacitor between 5v and ground … I had it only on between the 5V on arduino and the VCC on the IR .

Removed a delay? I just copy pasted it into codebender and uploaded it… Where should this shirt delay be?

[code]/*

  • IRremote: IRrecvDump - dump details of IR codes with IRrecv
  • An IR detector/demodulator must be connected to the input RECV_PIN.
  • Version 0.1 July, 2009
  • Copyright 2009 Ken Shirriff
  • http://arcfn.com
  • JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
    */

#include <IRremote.h>

int RECV_PIN = 8;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
Serial.begin(115200);
irrecv.enableIRIn(); // Start the receiver
}

// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: “);
}
else if (results->decode_type == PANASONIC) {
Serial.print(“Decoded PANASONIC - Address: “);
Serial.print(results->panasonicAddress,HEX);
Serial.print(” Value: “);
}
else if (results->decode_type == JVC) {
Serial.print(“Decoded JVC: “);
}
Serial.print(results->value, HEX);
Serial.print(” (”);
Serial.print(results->bits, DEC);
Serial.println(” bits)”);
Serial.print(“Raw (”);
Serial.print(count, DEC);
Serial.print(”): ");

for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" “);
}
Serial.println(”“);
Serial.print(“K 26”);
Serial.print(int(count/2), HEX);
for (int i = 1; i < count; i++) {
Serial.print(” “);
Serial.print(int(results->rawbuf[i]*USECPERTICK/26),HEX);
}
Serial.println(” 2000");
}

void loop() {
if (irrecv.decode(&results)) {
dump(&results);
delay(50);
irrecv.resume(); // Receive the next value
}
}[/code]

Tonight i will try again with the decoupling capacitor rightly installed ;D

Thanks,
Cor

I just tried again.

The decoupling capacitor paralel with vcc and ground.

When I long press the on-off button for 5 seconds , this is the output:

connecting at 115200 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -29114 800 -700 550 -1550 2650 K 263 1E 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -750 500 -1550 2650 K 263 1E 1C 13 3B 65 2000 Unknown encoding: 4AB0F7B6 (32 bits) Raw (6): -27364 800 -2800 500 -1150 450 K 263 1E 6B 13 2C 11 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -28264 750 -750 550 -1550 2650 K 263 1C 1C 15 3B 65 2000 Unknown encoding: FCABFFBD (32 bits) Raw (6): -27764 400 -700 550 -1550 2650 K 263 F 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2150 K 263 1E 1A 15 3B 52 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27414 750 -700 550 -1550 2700 K 263 1C 1A 15 3B 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27314 800 -750 550 -1500 2700 K 263 1E 1C 15 39 67 2000 Unknown encoding: 22AE7A2A (32 bits) Raw (6): -27364 750 -700 600 -1800 2400 K 263 1C 1A 17 45 5C 2000 Unknown encoding: 22AE7A2A (32 bits) Raw (6): -27614 500 -750 550 -1500 2700 K 263 13 1C 15 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 700 -950 400 -1800 2400 K 263 1A 24 F 45 5C 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 1050 -650 300 -1550 2700 K 263 28 19 B 3B 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1500 2700 K 263 1E 1A 15 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2650 K 263 1E 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27314 850 -650 600 -1500 2700 K 263 20 19 17 39 67 2000 Unknown encoding: 22AE7A2A (32 bits) Raw (6): -27364 800 -600 650 -1550 2650 K 263 1E 17 19 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2650 K 263 1E 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2650 K 263 1E 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27414 750 -700 550 -1800 2400 K 263 1C 1A 15 45 5C 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27414 750 -750 500 -1550 2650 K 263 1C 1C 13 3B 65 2000 Unknown encoding: 22AE7A2A (32 bits) Raw (6): -27664 500 -700 550 -1550 2650 K 263 13 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2650 K 263 1E 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27414 750 -700 550 -1800 2400 K 263 1C 1A 15 45 5C 2000 Unknown encoding: FCABFFBD (32 bits) Raw (6): -27764 400 -700 550 -1550 2650 K 263 F 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2700 K 263 1E 1A 15 3B 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 750 -750 550 -1500 2700 K 263 1C 1C 15 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 750 -750 550 -1500 2700 K 263 1C 1C 15 39 67 2000 Unknown encoding: 22AE7A2A (32 bits) Raw (6): -27364 750 -700 600 -2300 1900 K 263 1C 1A 17 58 49 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27314 800 -700 600 -1500 2700 K 263 1E 1A 17 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 750 -750 550 -1500 2700 K 263 1C 1C 15 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27314 800 -700 600 -1500 2700 K 263 1E 1A 17 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27314 850 -700 550 -1550 2650 K 263 20 1A 15 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -650 600 -1500 2700 K 263 1E 19 17 39 67 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -650 600 -1550 2650 K 263 1E 19 17 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 800 -700 550 -1550 2650 K 263 1E 1A 15 3B 65 2000 Unknown encoding: 22AE7A2A (32 bits) Raw (6): -27364 800 -300 950 -1550 2650 K 263 1E B 24 3B 65 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27364 1150 -350 550 -1550 2650 K 263 2C D 15 3B 65 2000 Unknown encoding: EA0E5282 (32 bits) Raw (8): -27364 800 -700 550 -350 500 -600 2900 K 264 1E 1A 15 D 13 17 6F 2000 Unknown encoding: 4CB0FADF (32 bits) Raw (6): -27264 650 -850 500 -1550 2650 K 263 19 20 13 3B 65 2000

can’t make heads of tail from it :-[

Those look like repeat codes. What do you get when you just click the button?

I did it twice; The first time when pressing the " on/off" button on the remote briefly:

Unknown encoding: 4CB0FADF (32 bits) Raw (6): -22114 850 -650 600 -1400 2800 K 263 20 19 17 35 6B 2000

I cloded the serial port , restarted and tried again, although very briefly pressed the same button again , it gives me 2 different (!!) codes:

Unknown encoding: FCABFFBD (32 bits) Raw (6): 25872 350 -750 550 -1800 1350 K 263 D 1C 15 45 33 2000 Unknown encoding: DDE32E9F (32 bits) Raw (8): -27964 500 -350 350 -700 550 -1800 1850 K 264 13 D D 1A 15 45 47 2000

Cor ???

No ideas how I can troubleshoot what’s wrong :-\ :cry:

Cor

You are consistently only receiving four raw values. Most real IR codes are much longer than that so something is not right with the IR receiver. Possibilities:

There is interference from lighting. Some receivers need an additional IR optical filter.

Your remote is too close or distant from the receiver. Some receivers work best when the remote is at least 500mm away.

The receiver is unsuitable or defective.

When debugging problems like this, it is a great advantage to have access to an oscilloscope (expensive) or a USB logic analyzer (Eu 20). Otherwise you can only keep changing things until you get better results.