Go Down

Topic: IR Remote control of Air Conditioner - Can't get it to work  (Read 1 time) previous topic - next topic

J_D_

Hi,
I'm new to arduino so I'm thinking I must be missing something simple as I am trying to control my air conditioner using an arduino Uno. The air conditioner is a Vaillant climoair and has the remote code 090 on the universal remotes. I have spent hours trying to make it work but have got completely stuck.
So far I have
installed the z3t0-Arduino-IRremote-0d39873 library
removed the robotIRremote as is somehow conflicts with the above
edited IRremoteInt.h RAWBUF 101 to RAWBUF 200 for long remote codes
used IRrecvDumpV2 to capture the code
eg
Encoding  : SANYO
Code      : FFFFFFFF (0 bits)
Timing[193]:
     + 550, - 600     + 500, - 650     + 400, - 700     + 450, - 650
     + 450, - 700     + 450, - 600     + 450, - 650     + 500, - 650
     + 450, - 650     + 450, - 700     + 450, - 650     + 450, - 700
     + 400, - 600     + 500, - 600     + 450, - 700     + 400, - 700
     + 450, - 650     + 500, - 650     + 450, - 700     + 400, - 650
     + 450, - 700     + 450, - 650     + 450, - 650     + 450, - 650
     + 500, -1700     + 450, - 650     + 500, - 650     + 450, - 600
     + 550, - 550     + 450, - 650     + 450, - 650     + 450, - 650
     + 500, - 650     + 450, - 650     + 450, - 650     + 450, - 600
     + 450, - 650     + 450, - 650     + 450, - 650     + 550, - 600
     + 500, - 600     + 550, - 550     + 550, - 600     + 500, - 600
     + 550, - 550     + 550, - 500     + 600, - 500     + 500, - 650
     + 550, - 550     + 500, - 600     + 500, - 600     + 450, - 600
     + 500, - 600     + 450, - 650     + 500, - 600     + 500, - 600
     + 500, - 550     + 600, -1550     + 600, - 500     + 600, - 550
     + 500, - 550     + 550, - 550     + 550, - 500     + 650, - 450
     + 500, - 600     + 500, - 650     + 500, - 550     + 500, - 600
     + 550, - 500     + 550, - 550     + 550, - 600     + 450, - 700
     + 500, -1650     + 550, - 600     + 500, - 600     + 600, -1550
     + 550, - 600     + 500, -1700     + 550, - 550     + 550, - 550
     + 550, -1650     + 550, - 450     + 600, -1600     + 600, - 500
     + 550, - 600     + 450, -1750     + 450, - 600     + 550, -1650
     + 550, -1650     + 500, - 600     + 500, - 650     + 450, - 650
     + 500, -1650     + 500, - 650     + 500, -1650     + 500, -1650
     + 500
unsigned int  rawData[193] = {550,600, 500,650, 400,700, 450,650, 450,700, 450,600, 450,650, 500,650, 450,650, 450,700, 450,650, 450,700, 400,600, 500,600, 450,700, 400,700, 450,650, 500,650, 450,700, 400,650, 450,700, 450,650, 450,650, 450,650, 500,1700, 450,650, 500,650, 450,600, 550,550, 450,650, 450,650, 450,650, 500,650, 450,650, 450,650, 450,600, 450,650, 450,650, 450,650, 550,600, 500,600, 550,550, 550,600, 500,600, 550,550, 550,500, 600,500, 500,650, 550,550, 500,600, 500,600, 450,600, 500,600, 450,650, 500,600, 500,600, 500,550, 600,1550, 600,500, 600,550, 500,550, 550,550, 550,500, 650,450, 500,600, 500,650, 500,550, 500,600, 550,500, 550,550, 550,600, 450,700, 500,1650, 550,600, 500,600, 600,1550, 550,600, 500,1700, 550,550, 550,550, 550,1650, 550,450, 600,1600, 600,500, 550,600, 450,1750, 450,600, 550,1650, 550,1650, 500,600, 500,650, 450,650, 500,1650, 500,650, 500,1650, 500,1650, 500};  // SANYO FFFFFFFF
unsigned int  data = 0xFFFFFFFF;

Then copies the rawData[193] and used the following code


Code: [Select]
#include "IRremote.h"

IRsend irsend;

void setup()
{
  Serial.begin(9600);
}

int khz=38; //NB Change this default value as neccessary to the correct modulation frequency
// ON and 2O C° with 1 FAN heat
unsigned heat[] = {550,600, 500,650, 400,700, 450,650, 450,700, 450,600, 450,650, 500,650, 450,650, 450,700, 450,650, 450,700, 400,600, 500,600, 450,700, 400,700, 450,650, 500,650, 450,700, 400,650, 450,700, 450,650, 450,650, 450,650, 500,1700, 450,650, 500,650, 450,600, 550,550, 450,650, 450,650, 450,650, 500,650, 450,650, 450,650, 450,600, 450,650, 450,650, 450,650, 550,600, 500,600, 550,550, 550,600, 500,600, 550,550, 550,500, 600,500, 500,650, 550,550, 500,600, 500,600, 450,600, 500,600, 450,650, 500,600, 500,600, 500,550, 600,1550, 600,500, 600,550, 500,550, 550,550, 550,500, 650,450, 500,600, 500,650, 500,550, 500,600, 550,500, 550,550, 550,600, 450,700, 500,1650, 550,600, 500,600, 600,1550, 550,600, 500,1700, 550,550, 550,550, 550,1650, 550,450, 600,1600, 600,500, 550,600, 450,1750, 450,600, 550,1650, 550,1650, 500,600, 500,650, 450,650, 500,1650, 500,650, 500,1650, 500,1650, 500};
// OFF the A/C
unsigned OFF[] = {550,600,550,500,600,550,600,500,600,500,500,650,450,650,450,650,600,550,500,600,450,600,500,600,500,600,500,650,500,600,550,550,550,550,600,500,600,500,600,500,600,500,600,500,600,500,550,550,500,1650,600,450,600,550,550,600,550,550,500,650,550,550,550,550,550,550,600,550,600,500,550,550,550,550,600,550,500,650,500,600,550,550,600,500,650,450,550,600,550,550,500,550,550,550,500,600,550,550,550,600,500,650,500,550,550,600,500,550,600,550,550,600,500,600,500,1700,500,600,550,600,500,550,550,600,500,600,550,550,550,650,450,600,500,650,450,650,500,550,500,650,500,600,500,650,500,1600,550,600,500,600,500,600,550,550,550,1600,550,550,550,550,550,1600,550,550,550,1650,500,600,500,650,500,1650,550,550,500,1650,550,1600,550,550,550,600,550,1650,500,600,450,650,450,1700,500,1650,550};


void loop() {

irsend.sendRaw(heat, sizeof(heat)/sizeof(int), khz);
delay(5000);
irsend.sendRaw(OFF, sizeof(OFF)/sizeof(int),khz);
delay(5000);
}


I have an IR led connect from pin 3 to 0v with a 220R resistor. Using a camera I can see the led does flash (not very brightly) but the AC doesn't respond, even when holding it close to the receiver.
I tried using a HG7881 to boost the output (as I had one) but not luck, maybe it isn't quick enough.
I tried changing the khz to 44
I then used the code from
https://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/
to capture the signal. This seemed more temperamental, often picking up a code when there wasn't one and the codes were of differing lengths. I tried them anyway (removing the "-"s) but still no response.

I then found
https://github.com/ToniA/arduino-heatpumpir
Which I thought would solve the problem, ran the test example (called simple) which sends a load of different codes but still no response. I found this surprising as I have a different make of AC which uses the same remote codes so I assumed it is a popular one.

Any idea what I'm doing wrong? Any help would be greatly appreciated.
I have noticed that the captured code is never quite the same when I repeat the same function. I don't know how accurate it has to be but I have tried many so I would have thought at least one would have worked.

Thanks

JD

J_D_

I tried using a transistor to boost the power to the LED, now it shines brightly but still no response from the AC. I tried taking 10 samples of the same code and using the average values but again no response.
I'm all out of ideas.


J D

INTP

Do you have the actual remote?

Using an IR receiver on the Arduino to get the codes would be a lot easier.

J_D_

Hi INTP,

Thank you for your reply.
I do have the remote and did use the an IR receiver to capture the remote code, or at least try to. When I sent the captured code the A/C doesn't respond so I don't know if it hasn't captured it correctly or if it isn't sending it correctly.

thanks

J D

INTP

When you have your Arduino receiving code, are you seeing consistent codes in Serial Monitor?
You need to see that a button reads the same each time, otherwise you're not set up with the right modulation protocol.

J_D_

When receiving the codes using IRrecvDumpV2, the codes I get in the serial monitor always start
Encoding  : SANYO
Code      : FFFFFFFF (0 bits)
Timing[193]:
Then the long list of numbers is sort of consistent, for the same function/button, each number in the sequence is the same +-50. So for example the first number will always be 500 or 550 or 600 I tried taking 10 samples of the same code and using the average.
I am thinking you are right, the modulation protocol could be wrong but there doesn't appear to be a way of changing it. (I don't have an oscilloscope or anything to view it)

Thanks

J D

Byork

For starters, I don't think you are capturing the whole length of the IR signal. My AC IR signal is over 440 int length long, and according to your posts, your buffer size is only 193. The z3t0 library could never once sucessfully capture the full length of my AC IR remote codes. The only successful way I have found is using the code by analysir.

INTP

You're reading raw which you may not be getting the entire pattern. When you read for hex codes along a particular protocol, you will see Serial Monitor receive something like this, which is a mapping I did of a Vizio Smart TV Remote yesterday (I added back in the F's for effect):

20DFE21D
FFFFFFFF
20DF22DD
FFFFFFFF
20DF12ED
FFFFFFFF
20DF52AD
FFFFFFFF
20DF629D
FFFFFFFF
20DF38C7
FFFFFFFF

So that would be 6 different buttons, and the same button always results in the same hex code. Using the same IRRemote.h lib, send commands are a little cleaner

irsend.sendNEC(0x20DFE21D, 32); 
for the first button, for example.

The lib comes with enough protocols that you just have to find the one that works with your remote, in that you get consistent readings and not jibberish from the same button.

J_D_

Hi Byork,

Could you please explain a bit more on how you managed to get yours to work, for example which sketches or instructions on the analysir site you used.
Did you have to change the frequency of irsend.sendRaw from the default 38?

When I first used IRrecvDumpV2 with the buffer at the default 101 it gave me a warning message saying the buffer was too small, I increased it to 200 and the message went away making me think it was now big enough (I get 193 numbers). I will try increasing it to see if it gets any longer results.
 
When I tried this sketch
https://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/
I did get slightly longer results, somewhere between 198 & 209, but it also picked up very short signals when nothing was pressed, even when the sensor was completely covered up, also the results were quite inconsistent.

Any help would be most appreciated

Thanks

JD

Byork

JD, sure here's what I did. Both receiving and sending are tested on Uno and Nano.

For receiving the signal, I am using the TSOP4838, connected to pin 2 according to the sketch. After pressing the button on your AC  remote, you may need to wait up to 5 seconds for the code to appear in serial monitor. The sketch I used was:

Code: [Select]
/*
Author: AnalysIR
Revision: 1.0

This code is provided to overcome an issue with Arduino IR libraries
It allows you to capture raw timings for signals longer than 255 marks & spaces.
Typical use case is for long Air conditioner signals.

You can use the output to plug back into IRremote, to resend the signal.

This Software was written by AnalysIR.

Usage: Free to use, subject to conditions posted on blog below.
Please credit AnalysIR and provide a link to our website/blog, where possible.

Copyright AnalysIR 2014

Please refer to the blog posting for conditions associated with use.
http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/

Connections:
IR Receiver      Arduino
V+          ->  +5v
GND          ->  GND
Signal Out   ->  Digital Pin 2
(If using a 3V Arduino, you may connect V+ to +3V)
*/

#define LEDPIN 13
//you may increase this value on Arduinos with greater than 2k SRAM
#define maxLen 800

volatile  unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR

void setup() {
  Serial.begin(115200); //change BAUD rate as required
  attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println(F("Press the button on the remote now - once only"));
  delay(5000); // pause 5 secs
  if (x) { //if a signal is captured
    digitalWrite(LEDPIN, HIGH);//visual indicator that signal received
    Serial.println();
    Serial.print(F("Raw: (")); //dump raw header format - for library
    Serial.print((x - 1));
    Serial.print(F(") "));
    detachInterrupt(0);//stop interrupts & capture until finshed here
    for (int i = 1; i < x; i++) { //now dump the times
      if (!(i & 0x1)) Serial.print(F("-"));
      Serial.print(irBuffer[i] - irBuffer[i - 1]);
      Serial.print(F(", "));
    }
    x = 0;
    Serial.println();
    Serial.println();
    digitalWrite(LEDPIN, LOW);//end of visual indicator, for this time
    attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal
  }

}

void rxIR_Interrupt_Handler() {
  if (x > maxLen) return; //ignore if irBuffer is already full
  irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions

}


My AC IR code received was this:

Code: [Select]
Raw: (439) 3552, -1664, 508, -364, 508, -1232, 504, -364, 508, -360, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -1236, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -1232, 508, -1232, 480, -1256, 484, -392, 480, -388, 480, -1256, 484, -388, 480, -388, 480, -392, 504, -364, 480, -388, 508, -360, 508, -364, 480, -388, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 508, -360, 508, -364, 504, -364, 504, -364, 508, -364, 504, -368, 476, -392, 476, -392, 480, -1256, 484, -1256, 508, -364, 504, -364, 504, -364, 508, -360, 508, -364, 504, -10884, 3528, -1688, 504, -368, 504, -1232, 484, -384, 484, -388, 484, -384, 484, -384, 484, -384, 484, -392, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -1228, 508, -364, 504, -364, 508, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -1232, 508, -1232, 508, -1232, 504, -364, 508, -364, 504, -1232, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 480, -1260, 484, -384, 484, -384, 484, -384, 484, -388, 484, -384, 508, -368, 476, -1256, 508, -1228, 512, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 480, -388, 480, -392, 484, -384, 480, -388, 484, -388, 484, -384, 484, -384, 484, -392, 480, -388, 480, -388, 480, -388, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -1232, 504, -1236, 504, -1232, 504, -364, 508, -364, 504, -364, 480, -388, 480, -392, 476, -392, 480, -392, 480, -388, 480, -392, 480, -1252, 512, -1232, 504, -1232, 508, -364, 504, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -368, 472, -396, 476, -392, 476, -392, 476, -396, 476, -1256, 484, -392, 476, -392, 480, -388, 480, -388, 508, -364, 504, -364, 504, -1236, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -368, 500, -368, 500, -368, 476, -396, 476, -392, 476, -392, 476, -1260, 484, -1252, 484, -1260, 480, -388, 504, -364, 508, -364, 504, -1232, 508

You then need to remove all the negative signs using a text editor. After which I used and inserted my IR code into this sketch. The IR emitter LED is connected to pin 3 as according to the sketch:

Code: [Select]
/*
 * IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 *
 * IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
 */


#include <IRremote.h>

IRsend irsend;

void setup()
{

}

void loop() {
  int khz = 38; // 38kHz carrier frequency for the NEC protocol
  unsigned int irSignal[] = {3552, 1664, 508, 364, 508, 1232, 504, 364, 508, 360, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 1236, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 1232, 508, 1232, 480, 1256, 484, 392, 480, 388, 480, 1256, 484, 388, 480, 388, 480, 392, 504, 364, 480, 388, 508, 360, 508, 364, 480, 388, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 508, 360, 508, 364, 504, 364, 504, 364, 508, 364, 504, 368, 476, 392, 476, 392, 480, 1256, 484, 1256, 508, 364, 504, 364, 504, 364, 508, 360, 508, 364, 504, 10884, 3528, 1688, 504, 368, 504, 1232, 484, 384, 484, 388, 484, 384, 484, 384, 484, 384, 484, 392, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 1228, 508, 364, 504, 364, 508, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 1232, 508, 1232, 508, 1232, 504, 364, 508, 364, 504, 1232, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 480, 1260, 484, 384, 484, 384, 484, 384, 484, 388, 484, 384, 508, 368, 476, 1256, 508, 1228, 512, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 480, 388, 480, 392, 484, 384, 480, 388, 484, 388, 484, 384, 484, 384, 484, 392, 480, 388, 480, 388, 480, 388, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 1232, 504, 1236, 504, 1232, 504, 364, 508, 364, 504, 364, 480, 388, 480, 392, 476, 392, 480, 392, 480, 388, 480, 392, 480, 1252, 512, 1232, 504, 1232, 508, 364, 504, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 368, 472, 396, 476, 392, 476, 392, 476, 396, 476, 1256, 484, 392, 476, 392, 480, 388, 480, 388, 508, 364, 504, 364, 504, 1236, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 368, 500, 368, 500, 368, 476, 396, 476, 392, 476, 392, 476, 1260, 484, 1252, 484, 1260, 480, 388, 504, 364, 508, 364, 504, 1232, 508};
  
  irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.

  delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}


I have tested several AC IR remotes in the past, and it seemed that all of them had incredibly long IR codes, which only worked with the AnalysisIR sketch. The z3t0 library has absolutely no issues with other regular remotes like TV, DVD, etc.

J_D_

Byork, thank you so much.
I now have it working. It looks like I was on the correct track but just needed to filter out the rubbish from the signal. My IR receiver, VS1838B, picks up all kinds of interference when using the analysir sketch. Putting it in a dark cardboard box and then putting that box in a metal box, turn off the florescence lights and move it well away from the computer and I got a much more consistent code. When comparing several results of the same function I then had to remove the random figures at the beginning and end and of course delete the "-" signs and it work perfectly. The code is less than 200 long, probably because it's a cheap A/C without timer functions it doesn't need such a long code as yours.

Thanks again for you help.

JD

J_D_

Just  a quick note for anybody else trying this, I bought a TSOP4838 IR receiver and found it much better, it gets a more consistent result with little noise (much better than the VS1838B I was using).

JD

zoomx

AC remote use longer codes because there is no feedback from the split unit so if one command is lost the remote is still synchronized the next command,  sending all the current settings.

TM_031

Hello JD,

I am in the same situation than you...

I would like to pilote my AC with my Arduino UNO : I have scanned my remote with IRrecvDumpV2 and I have capture exactly the same code than you (see below) => 193 blocks also !

I have tried to send the raw to the AC but nothink happen... can you help me ?


Encoding  : SANYO
Code      : FFFFFFFF (0 bits)
Timing[193]:
     + 550, -1650     + 500, -1650     + 500, -1700     + 500, -1650
     + 550, -1600     + 550, -1650     + 550, -1650     + 500, -1650
     + 500, - 600     + 550, - 550     + 550, - 600     + 550, - 550
     + 550, - 550     + 550, - 600     + 550, - 550     + 550, - 600
     + 500, -1650     + 550, -1650     + 500, -1700     + 450, -1700
     + 500, -1650     + 550, -1650     + 500, -1650     + 550, -1650
     + 500, - 600     + 500, - 600     + 550, - 550     + 550, - 600
     + 550, - 550     + 550, - 600     + 500, - 600     + 500, - 600
     + 550, -1650     + 550, -1600     + 550, -1650     + 500, -1700
     + 500, -1650     + 500, -1650     + 500, -1700     + 500, -1650
     + 550, - 550     + 550, - 600     + 500, - 600     + 550, - 550
     + 550, - 600     + 500, - 600     + 550, - 600     + 500, - 600
     + 500, -1700     + 500, - 600     + 500, -1650     + 550, - 550
     + 550, -1650     + 550, -1650     + 500, -1650     + 550, -1650
     + 500, - 600     + 500, -1650     + 550, - 550     + 550, -1700
     + 450, - 650     + 500, - 600     + 500, - 600     + 550, - 550
     + 550, -1650     + 500, - 600     + 550, -1650     + 500, - 600
     + 500, -1700     + 500, -1650     + 550, -1650     + 500, - 600
     + 500, - 600     + 550, -1650     + 550, - 550     + 500, -1700
     + 500, - 600     + 550, - 550     + 550, - 600     + 500, -1650
     + 550, - 550     + 550, -1650     + 550, - 550     + 550, -1650
     + 500, - 600     + 550, -1650     + 500, - 600     + 500, - 600
     + 550, -1650     + 550, - 550     + 500, -1700     + 500, - 600
     + 550, -1650     + 500, - 600     + 500, -1650     + 550, -1650
     + 550





zoomx


Go Up