Solved: LG air conditioning codes

the output for the IR library
8250h 4300l = header
next
450h 1700l = 1
450h 700l = 0

first byte after header: 1 0 0 0 1 0 0 0 (i will not repeat this below)
power on: 0 0 0 0 0 1 0 0 1 1 1 1 0 1 0 0 + CRC 0 1 1 1 ( = 1 0 0 0 + 1 0 0 0 + 0 0 0 0 + 0 1 0 0 + 1 1 1 1 + 0 1 0 0; I will not repeat CRC below)
(this power on includes mode, temp and fan speed)
power off:1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 ( dont't see here any info about mode, temp and fan speed)
change temp/fan / mode:
0 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 = heating 29 C Fan4
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
1-5 always the same except for timer set, or jet mode (or other SF I was not interested)
6-8 heating 4, auto 3, dehumidification 1, cooling 0
9-12 = temp -15
13 = 0
14-16 = fan1 1, fan2 0 (strange), fan3 2, fan4 4

Make sure you add the header, the first byte and the CRC.
The code was tested with 38kHz modulation and it worked

Can you also share how you convert the pulses to byte data? I am poking my eyes on a WAV file I recorded with my sound card and am able to read the data by eye, but it is tedious...

My Daikin has apparently aound 35 byte frame from what I see in the WAV file, broken in two transmissions (one short and one double that)

here is the WAV file itself:
http://dl.dropbox.com/u/18771283/daikin.wav

it has been quite a challenge so far, you have motivated me again.

My previous solution with emulating the keys clicks is HIGHLY unsatisfying since the arduino doesn't know the current readings on it, neither can get feedback..

also, if you may share the code, it will give the rest of us directions.

Thanks :slight_smile:

Hi Martin,

Your ir is modulated with aprox 38 khz, so using the sound card is the wrong way to start.
From your picture I don't understand how you captured it, but lets start the way I did it:

My advice is to spend 2€ on a 38khz ir receiver with digital output and a ir led and install the library from the second post.
You should be able to see the byte stream and play it back. If your air conditioner responds to it you have a solution using certain preconfigured commands.

Decoding is another story:
The library will give you the streams in a numeric format that can be converted into a 1/0 stream (with ms excel)
You set the temp to 29 and then to 28 and look for the differences in the stream...
Let me know when you have the hardware tested with the library and give me the output from ir library, I'll fill in the excel and post it.

One word of caution: the remote is the state machine memory, if you use another remote in parallel your arduino is quite lost.

The code I have until now are some undocumented test, but the main is irsend.sendRaw(codesArray,buffer_size,38);

Regards,
Adi

Hi Adi,
I installed the IR library for Arduino, and used it to record the signal sent by my remote control to my Elco airconditioner.
However, when using the IRecvDump sketch, the output is in a form such as

Raw (76): 21114 1400 -1450 500 -500 500 -500 450 -1000 450 -500 500 -500 950 -550 450 -1000 950 -550 450 -950 500 -500 950 -550 450 -500 450 -550 450 -500 450 -550 450 -500 450 -550 450 -550 450 -550 400 -550 450 -550 450 -500 450 -550 450 -500 450 -550 450 -550 400 -550 450 -550 400 -1000 950 -550 1400 -1500 450 -550 400 -550 450 -1000 450 -550 400 -550 950

and I have no idea how to convert this to hex.
Can you please give me a hand?

Thanks!
-Ethan

Have a nice surf on my blog! :slight_smile:

Nice work, thanks!

dear Adis,

may post code to clone the LG remote control, and the code to send commands acquired??

PS: I am using the examples of Ken Shirriff (IRrecvDemo.ino or IRrecvDump.ino) I get a 16-bit code (the original code is 24-bit.) These are the first 16 bits of the command.

thank you very much :slight_smile:
(sorry for my bad english)

Alessandro

IRrecvDump.ino (2.03 KB)

Hi,

Below is the test program and a library I wrote in january.
I did my best to make it as clear as possible.

Regards,
Adi

#include <LG.h>
#include <IRremote.h>

// the LG code generator object

// the IR emitter object
IRsend irsend;

void setup()
{
Serial.begin(9600);
Serial.println("Start");


// wait 5 seconds
//delay(5000);
//LG LG(mode_heating,fan_4,30,state_on);
//LG LG(mode_heating,fan_4,30,state_off);
LG LG(mode_cooling,fan_1,18 ,state_on);


LG.debug();
// change the state
//LG.setState(STATE_off);
// send the code

irsend.sendRaw(LG.codes,LG_buffer_size,38);
//
Serial.println("End");


	
// wait 10 seconds
//delay(10000);

// change the state
//LG.setState(STATE_on);			
// send the code
//irsend.sendRaw(LG.codes,LG_buffer_size,38);
}

void loop() {}

LG.h

#ifndef LG_h
#define LG_h
#include <WProgram.h>

#define first_byte 136 //b10001000

#define state_on 0
#define state_off 24 //b11000
#define state_change_mode 1

#define mode_heating 4 //b100
#define mode_auto 3 //b011
#define mode_dehuidification 1 //b001
#define mode_cooling 0
#define mode_none 0

#define temperature_offset 15

#define fan_1 1
#define fan_2 0
#define fan_3 2
#define fan_4 4 //b100
#define fan_none 5 //b101

#define first_high 8271
#define first_low 4298
#define zero_and_one_high 439
#define zero_low 647
#define one_low 1709

#define LG_buffer_size 59

class LG
{
	public:
		// fields
		unsigned int codes[LG_buffer_size];
		// methods
		// setter
		LG(int _mode, 
				int _fan, 
				int _temperature,
				int _state);
		// getter
		// debugging
		void debug();
	private:
		// fields
		byte crc;
		// methods
		void FillBuffer(byte _pos, byte _bit, byte _value);
};

#endif;

LG.cpp

#include "LG.h"
LG::LG(int _mode, 
				 int _fan, 
				 int _temperature,
				 int _state)
{
	// set sync
	codes[0] = first_high;
	codes[1] = first_low;
	crc = 0;
	FillBuffer(0,8,first_byte);
	FillBuffer(8,5,_state);
	if(_state==state_off)
		FillBuffer(13,3,mode_none);
	else
		FillBuffer(13,3,_mode);
	if(_state==state_off)
		FillBuffer(16,4,0);
	else
		FillBuffer(16,4,(byte)_temperature-temperature_offset);
	FillBuffer(20,1,0); //jet
	if(_state==state_off)
		FillBuffer(21,3,fan_none);
	else
		FillBuffer(21,3,_fan);
	FillBuffer(24,4,crc);
	codes[LG_buffer_size-1] = zero_and_one_high;
}

void LG::FillBuffer(byte _pos, byte _bits, byte _value){
	for (int i=_bits;i>0;i--){
		codes[2+2*(_pos+_bits-i)] = zero_and_one_high;
		codes[2+2*(_pos+_bits-i)+1] = (bitRead(_value,i-1)==1?one_low:zero_low);
		if(bitRead(_value,i-1)==1){
			byte bitset = 0;
			bitSet(bitset,(128+i-_pos-_bits-1)%4);
			crc = crc + bitset;
		}
	}
}
void LG::debug()
{
	for(byte i=0;i<LG_buffer_size;i++){
		Serial.print(codes[i],DEC);
		Serial.print(",");
	}
}

Another HELP!!??? XD :smiley:

I use Arduino 1.0.1
in the verification phase of the first code posted by Adis:

[ERROR]
Programmi\arduino-1.0.1\libraries\LG/LG.h:49: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type

[Possible solution] in 'LG.h' I changed the code to "unsigned char"................ but appears a new error:

sketch_LG_ino.cpp.o: In function setup': C:\Users\ALESSA~1\AppData\Local\Temp\build6352010931496577367.tmp/sketch_LG_ino.cpp:22: undefined reference to LG::LG(int, int, int, int)'
C:\Users\ALESSA~1\AppData\Local\Temp\build6352010931496577367.tmp/sketch_LG_ino.cpp:25: undefined reference to `LG::debug()'

adis is there a way of turning the unit off with provided libary?
I will be working on a web-client seeing these lg ac units have issues turning back on once they loose power :).

any information would be great thanks.

from a previous post

power off:1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1

so looks like it can be done
(never used those thingies disclaimer)

by the looks of the libary that was supplied though thats the turn off for each of the compoents not the unit its self.

class LG
{
public:
// fields
unsigned int codes[LG_buffer_size];
// methods
// setter
LG(int _mode,
int _fan,
int _temperature,
int _state);
// getter
// debugging
void debug();
private:
// fields
byte crc;
// methods
void FillBuffer(byte _pos, byte _bit, byte _value);
};

I would like to create a program that allows you to control all (or almost all) Brands of air conditioners.
Is there anyone who has already done it?
Some of you have never planned an air conditioner that is not LG?

Thanks to all of you ... :slight_smile:

PS: I will open another post anyway

Hi All

I am just wondering which model LG remotes this is for.

Thanks

Darryl

ethan1701:
Hi Adi,
I installed the IR library for Arduino, and used it to record the signal sent by my remote control to my Elco airconditioner.
However, when using the IRecvDump sketch, the output is in a form such as

Raw (76): 21114 1400 -1450 500 -500 500 -500 450 -1000 450 -500 500 -500 950 -550 450 -1000 950 -550 450 -950 500 -500 950 -550 450 -500 450 -550 450 -500 450 -550 450 -500 450 -550 450 -550 450 -550 400 -550 450 -550 450 -500 450 -550 450 -500 450 -550 450 -550 400 -550 450 -550 400 -1000 950 -550 1400 -1500 450 -550 400 -550 450 -1000 450 -550 400 -550 950

and I have no idea how to convert this to hex.
Can you please give me a hand?

Thanks!
-Ethan

Hi, did you find a solution to your problem ?

Many thnaks

vk2tds:
Hi All

I am just wondering which model LG remotes this is for.

Thanks

Darryl

The code works with LG S09AW
Regards,
Adi

Hi Adis,

Im trying to achieve what you have been able to do with the lg remote, using the codes mentioned in the earlier posts. Im using the Uno and been able to record the incoming IR pulses from the remote controller. But if I send them from the uno and compare it to the pulses sent from the remote controller itself, the uno seems less bright and the LG aircon doesnt respond. Is there a way to address this issue or is it normal?

Appreciate your help in this.

Cheers,
Arvind

Hi, I used this code for LG A/C Power On : Header NEC + 10001000 + 0000 0000 + 10100100 + 1110 + final pulse (520,4200usecs)
and it works fine with the LG Air Condition power on but how i switch off ?Not the same....i can't switch off....
Can you share the code for power off and others functions?
I find the code from there....http://irremote.psiloc.com/Show.aspx?d=Air%20Conditioner
Thanks.

Hi power7net,

these are the two codes which I received

using IRrecord
ON
Received unknown code, saving as raw
m8750 s4150 m500 s1550 m400 s650 m150 s900 m50 s3200 m100 s750 m50
OFF
Received unknown code, saving as raw
m8750 s4200 m500 s1650 m50 s250 m50 s650 m100 s900 m50 s3000 m50 s1000 m50 s4300 m50 s1850 m0 s1000 m100

using IRrecvDump
ON
Unknown encoding: 1C583E4B (32 bits)
Raw (16): -21000 8850 -4050 500 -1600 200 -100 100 -650 150 -850 150 -2900 150 -950 100
OFF
Unknown encoding: 8BCEFF74 (32 bits)
Raw (18): -22958 8850 -4050 650 -1500 150 -900 100 -3950 150 -950 100 -4150 100 -1750 150 -850 200

But a funny thing happens when I cycle the ON/OFF button more than 5-6 times, the codes double in size for both functions and return to the original size, after cycling them 5-6 more times.

Cheers,
Arvind

argonauta1:
Another HELP!!??? XD :smiley:

I use Arduino 1.0.1
in the verification phase of the first code posted by Adis:

[ERROR]
Programmi\arduino-1.0.1\libraries\LG/LG.h:49: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type

[Possible solution] in 'LG.h' I changed the code to "unsigned char"................ but appears a new error:

sketch_LG_ino.cpp.o: In function setup': C:\Users\ALESSA~1\AppData\Local\Temp\build6352010931496577367.tmp/sketch_LG_ino.cpp:22: undefined reference to LG::LG(int, int, int, int)'
C:\Users\ALESSA~1\AppData\Local\Temp\build6352010931496577367.tmp/sketch_LG_ino.cpp:25: undefined reference to `LG::debug()'

to solve that just change the header on LG.h from '#include <wprogram.h>' to '#include <Arduino.h>'