I've posted this thread already on Arduino forum, but I'm here to ask held as well
original forum: http://forum.arduino.cc/index.php?topic=285012
I'm trying to clone a command sent by a remote that acts to turn ON or OFF a stove.
I've found this library which should do well the stuff I need:
https://github.com/shirriff/Arduino-IRremote
Following different tutorials I'm still blocked, I can't replicate the signal.
Let me make a step back. Hardware for my tests:
2x Arduino nano.
First Arduino with:
1x IR Receiver 1838T
Sketch loaded: Example 'IRrecvDump':
Code: Select all
/*
* 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)
* LG added by Darryl Smith (based on the JVC protocol)
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
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 == LG) {
Serial.print("Decoded LG: ");
}
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("");
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}
Second Arduino with:
1x IR LED sender connected on PWM 3 through 330Ohm resistor
Test 1:
Decode SONY signal:
Sending a signal from a SONY remote to the Receiver, I get:
Code: Select all
Decoded SONY: 540A (15 bits)
Raw (32): -27774 2500 -450 1200 -600 600 -600 1150 -600 600 -600 1150 -600 600 -600 550 -600 600 -600 600 -550 600 -600 600 -600 1150 -600 600 -600 1150 -600 600
Sketch on the Sender:
Code: Select all
#include <IRremote.h>
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
void loop() {
irsend.sendSony(0x540A, 15);
delay(3000);
}
Code: Select all
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18630 2550 -450 1350 -450 750 -450 1350 -450 750 -450 1250 -550 650 -550 600 -600 600 -600 600 -600 600 -550 650 -600 1200 -550 600 -600 1200 -600 600
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18580 2550 -450 1350 -450 750 -450 1350 -450 700 -500 1250 -550 600 -600 600 -600 600 -600 600 -600 600 -600 600 -600 1200 -550 650 -600 1200 -550 600
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18680 2550 -450 1300 -450 750 -500 1300 -450 750 -450 1250 -550 650 -550 650 -550 650 -550 600 -600 600 -600 600 -600 1200 -600 600 -600 1150 -650 600
Code: Select all
Raw (32): -18630 2550 -450 1350 -450 750 -450 1350 -450 750 -450 1250 -550 650 -550 600 -600 600 -600 600 -600 600 -550 650 -600 1200 -550 600 -600 1200 -600 600
Then, SONY signal should be sent at 40Khz.
So I've created this sketch that shoud send the signal first with RAW library, then with SONY library:
Code: Select all
#include <IRremote.h>
IRsend irsend;
unsigned int sonyPower[] = {2550,450,1350,450,750,450,1350,450,750,450,1250,550,650,550,600,600,600,600,600,600,600,550,650,600,1200,550,600,600,1200,600,600};
void setup()
{
Serial.begin(9600);
}
void loop() {
// send variable sonyPower in length 31 at 40 Khz
irsend.sendRaw(sonyPower,31,40);
delay(3000);
irsend.sendSony(0x540A, 15);
delay(3000);
}
Code: Select all
EE2AFAB
Unknown encoding: EE2AFAB (32 bits)
Raw (32): -18630 2750 -250 1500 -300 900 -300 1450 -350 800 -400 1250 -550 650 -550 600 -600 600 -600 600 -600 600 -550 650 -600 1200 -550 600 -600 1200 -550 600
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18030 2600 -400 1400 -400 800 -400 1350 -450 750 -450 1250 -600 600 -550 650 -550 600 -600 650 -550 600 -600 600 -600 1200 -600 600 -600 1200 -600 600
EE2AFAB
Unknown encoding: EE2AFAB (32 bits)
Raw (32): -18630 2700 -300 1500 -300 900 -300 1450 -350 800 -400 1250 -550 650 -550 600 -600 600 -600 600 -600 600 -550 650 -600 1150 -600 600 -550 1200 -650 600
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18030 2550 -450 1350 -400 750 -500 1300 -450 750 -500 1200 -550 650 -550 600 -600 600 -600 600 -600 600 -600 600 -600 1200 -600 600 -600 1200 -600 600
EE2AFAB
Unknown encoding: EE2AFAB (32 bits)
Raw (32): -18630 2750 -250 1500 -300 900 -300 1450 -350 850 -350 1300 -500 700 -500 600 -600 600 -600 600 -600 600 -550 650 -600 1200 -550 550 -650 1150 -650 550
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18030 2550 -450 1350 -450 750 -450 1350 -500 700 -450 1250 -600 600 -600 600 -550 600 -600 600 -600 600 -600 600 -600 1200 -600 600 -600 1200 -600 600
791C87DE
Unknown encoding: 791C87DE (32 bits)
Raw (32): -18630 2700 -300 1500 -300 900 -300 1450 -350 800 -400 1300 -500 650 -550 600 -600 600 -600 600 -600 600 -550 650 -600 1200 -550 600 -600 1200 -550 600
540A
Decoded SONY: 540A (15 bits)
Raw (32): -18080 2550 -450 1350 -400 750 -500 1300 -450 750 -500 1200 -550 650 -600 600 -550 600 -600 600 -650 550 -600 600 -600 1200 -600 600 -600 1200 -600 600
EE2AFAB
Unknown encoding: EE2AFAB (32 bits)
Raw (32): -18630 2750 -250 1500 -300 900 -300 1450 -350 850 -350 1300 -500 700 -500 600 -600 600 -600 600 -600 600 -550 650 -550 1200 -600 600 -550 1200 -600 650
What's wrong? What I'm missing?
If i change frequence from 40 to 38, same result.
Thanks for the help!
Simon