Hi,
I am trying to control AC with IR transmitter connected to Arduino with no success.
I started with this code to decode IR signals using arduino and an IR Receiver module like this
Here is the code:
#include <IRremote.h>
int RECV_PIN = 9;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
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: ");
}
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
}
}
I found that setting the temperature to 25C degrees keep producing this IR code: 9890040A
Decoded NEC: 9890040A (32 bits)
Raw (74): 10436 8650 -4350 600 -1650 650 -600 650 -550 600 -1700 650 -1650 650 -600 600 -550 700 -550 650 -1650 600 -600 600 -600 600 -1700 600 -600 650 -600 600 -600 600 -600 650 -550 650 -600 600 -600 600 -600 600 -600 600 -1700 650 -550 650 -600 600 -600 650 -550 650 -550 650 -600 600 -1650 650 -600 650 -1600 650 -600 650 -550 650 -1650 650 -550 650
To another Arduino I connected IR Transmitter such as this and uploaded this code to test it:
#include <IRremote.h>
//IR Variable declaration
IRsend irsend;
void sendIRCommand()
{
long command = 0x9890040A;
Serial.print("Command: ");
Serial.println(command, HEX);
irsend.sendNEC(command, 32);
delay(40);
}
void setup()
{
Serial.begin(9600);
}
void loop() {
handleSerial();
}
void handleSerial() {
while (Serial.available() > 0) {
String incoming = Serial.readString();
Serial.println(incoming);
if (incoming == "TEST") {
sendIRCommand();
}
}
}
Trasmitting to the AC doesn't do anything
I then tried to transmit to the other Arduino with the receiver and these are the results:
Original Remote
Decoded NEC: 9890040A (32 bits)
Raw (74): 10436 8650 -4350 600 -1650 650 -600 650 -550 600 -1700 650 -1650 650 -600 600 -550 700 -550 650 -1650 600 -600 600 -600 600 -1700 600 -600 650 -600 600 -600 600 -600 650 -550 650 -600 600 -600 600 -600 600 -600 600 -1700 650 -550 650 -600 600 -600 650 -550 650 -550 650 -600 600 -1650 650 -600 650 -1600 650 -600 650 -550 650 -1650 650 -550 650
Smartphone app that uses phone's IR transmitter
Decoded NEC: 9890040A (32 bits)
Raw (74): -9686 8900 -4450 650 -1650 650 -550 600 -550 650 -1650 650 -1650 650 -550 650 -550 600 -550 650 -1650 650 -550 650 -550 650 -1650 600 -550 650 -550 650 -550 650 -550 650 -550 650 -550 650 -550 650 -550 650 -550 600 -1650 650 -550 650 -550 650 -550 650 -550 650 -550 650 -500 650 -1650 650 -550 650 -1650 650 -550 650 -500 650 -1650 650 -550 650
Infrared Transmitter Module
Decoded NEC: 9890040A (32 bits)
Raw (68): -16622 8900 -4450 600 -1650 600 -500 600 -500 500 -1750 500 -1750 500 -600 550 -550 550 -550 550 -1700 550 -550 550 -600 550 -1650 600 -500 600 -500 600 -550 550 -600 500 -550 550 -600 500 -600 500 -600 550 -600 500 -1700 550 -600 500 -600 550 -550 550 -600 500 -600 550 -550 550 -1650 600 -550 550 -1700 550 -500 600
// NOTE THE DIFFERENCE BETWEEN THE WORKING SCENARIOS (RAW (74)) TO THE NOT WORKING ONE (RAW (68))
From the original remote and a smartphone app, I can control the AC. With the IR transmitter connected to the Arduino I cannot.
The only difference that I could see in the decode dump is the Raw Length which is 74 in the both the original remote and the smartphone app when it works, whereas the Raw length is 68 when transmitting using the IR transmitter module
Can anyone please guide me through what's going on here, why is the difference in the raw length and how to solve this issue?
Thanks in advance!