Controlling Air Conditioner via IR

I need to control my air conditioner, I have the IR codes, but blynk is offline (local server)

My code:

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleEthernet.h>
#include <Ethernet.h>
#include <SimpleTimer.h>
#include <DHT.h>
#include <IRremote.h>

/*DHT*/
#define DHTPIN 2         

#define DHTTYPE DHT11     // DHT 11

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

/*BLYNK*/
char auth[] = "2e633e295fbxxxxxxxxxxxxx";

/*INTERNET*/

IPAddress server_ip (xxx,xxx,xxx,xxx);

EthernetClient client;
byte arduino_mac[] = { 0xFE, 0xD7, 0xDF, 0xA2, 0xA5, 0xBE };
IPAddress arduino_ip (xxx,xxx,xxx,xxx);
IPAddress dns_ip     (xxx,xxx,xxx,xxx);
IPAddress gateway_ip (xxx,xxx,xxx,xxx);
IPAddress subnet_mask(xxx,xxx,xxx,xxx);

/*IR*/
int khz = 38; 

IRsend irsend;

unsigned int irON[] = {3000,9800, 400,1650, 350,650, 350,700, 300,700, 350,1600, 400,700, 300,700, 350,650, 350,650, 350,650, 350,700, 350,650, 350,650, 350,700, 300,700, 300,700, 350,1650, 350,650, 350,1700, 350,1700, 300,700, 300,700, 350,650, 350,650, 350,1700, 300,700, 300,1700, 350,1650, 350};
unsigned int irOFF[] = {3000,9700, 400,1700, 350,750, 250,700, 300,750, 300,1750, 250,600, 450,700, 300,700, 300,1750, 250,1700, 350,750, 250,750, 250,750, 300,700, 300,700, 300,650, 400,650, 350,650, 350,650, 350,600, 400,750, 250,1700, 350,700, 300,1700, 350,650, 350,750, 250,750, 250,1700, 350};
unsigned int irTEMPUP[] = {3008, 9812, 424, 1704, 332, 740, 304, 776, 224, 820, 184, 1864, 208, 800, 224, 736, 300, 740, 276, 740, 304, 784, 216, 736, 304, 780, 216, 1784, 272, 612, 432, 656, 364, 656, 364, 1640, 396, 1668, 368, 668, 348, 620, 424, 592, 428, 788, 208, 808, 248, 716, 312, 708, 312, 1820, 184, 820, 204, 812, 248};
unsigned int irTEMPDOWN[] = {3040, 9756, 424, 1608, 456, 584, 436, 584, 432, 584, 436, 1608, 452, 564, 456, 560, 460, 560, 456, 584, 436, 584, 432, 588, 456, 584, 436, 1608, 452, 564, 456, 584, 436, 584, 432, 1608, 428, 584, 460, 1584, 452, 1584, 456, 584, 432, 584, 436, 584, 432, 584, 436, 584, 436, 580, 460, 1584, 456, 1608, 428};



/*CONTROLES*/
BLYNK_WRITE(V1)
{
  if (param.asInt()){
    irsend.sendRaw(irON, sizeof(irON) / sizeof(irON[0]), khz); //  Turn On
    delay(40);
  }else {
    irsend.sendRaw(irOFF, sizeof(irOFF) / sizeof(irOFF[0]), khz); //  Turn Off
    delay(100);
    irsend.sendRaw(irOFF, sizeof(irOFF) / sizeof(irOFF[0]), khz);
    delay(100);
  }  
}


BLYNK_WRITE(V2)
{
  if (param.asInt()){
    irsend.sendRaw(irTEMPUP, sizeof(irTEMPUP) / sizeof(irTEMPUP[0]), khz); //  Up
    delay(40);
  }
}

BLYNK_WRITE(V3)
{
  if (param.asInt()){
    irsend.sendRaw(irTEMPDOWN, sizeof(irTEMPDOWN) / sizeof(irTEMPDOWN[0]), khz); //  Down
    delay(40);
  }
}


void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  DebugSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(auth, server_ip, 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
    // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates SimpleTimer
}

If I remove this part the code works

BLYNK_WRITE(V2)
{
  if (param.asInt()){
    irsend.sendRaw(irTEMPUP, sizeof(irTEMPUP) / sizeof(irTEMPUP[0]), khz); //  Up
    delay(40);
  }
}

BLYNK_WRITE(V3)
{
  if (param.asInt()){
    irsend.sendRaw(irTEMPDOWN, sizeof(irTEMPDOWN) / sizeof(irTEMPDOWN[0]), khz); //  Down
    delay(40);
  }
}

I tried this code but it did not work

@fernandesg what is the make and model of your AC unit?

Also interested in hearing from any other Blynkers that are interested in AC control. Please send us the make and model of your AC unit and whether you are up and running or looking to set up a project.

yep, the same thing happened with me. it took me 3 hrs to find the problem. the code usses most of the memory of the arduino. check the console after the code is complied. mine says “Low memory available, stability problems may occur.”

try using the irsend function rather than irsendraw as it uses more memory

also keep the delay function under 25 milliseconds

So maybe try a lower cost alternative to the Arduino.

@Costas i am quite intrested in AC controll functionality. mine is from TOTALINE which usses the ir codes of career ac.

esp8266 and esp32 have more memory than arduino. Try nodeMCU or WEMOS D1 mini. not to mention they have wifi so you will not need any wired connection.

@Sai_Khurana do you mean TotalLine uses Carrier AC signal, not “career”?

I need exact make and model, ideally a photo of the makers panel with all the details like this:

yep its carrier. thank for correcting me. on checking the ir signals on my arduino. the controller emits ir waves that are encoded my SAMSUNG

.
Encoding : SAMSUNG
Code : B24DBF40 (32 bits)
Timing[99]:
+4350, -4350 + 550, -1550 + 550, - 500 + 600, -1550
+ 550, -1550 + 600, - 500 + 550, - 500 + 550, -1600
+ 550, - 500 + 550, - 500 + 550, -1600 + 550, - 500
+ 550, - 500 + 550, -1600 + 550, -1550 + 550, - 500
+ 600, -1550 + 550, -1600 + 550, - 500 + 550, -1550
+ 600, -1550 + 550, -1550 + 600, -1550 + 550, -1550
+ 600, -1550 + 550, - 500 + 600, -1550 + 550, - 500
+ 550, - 500 + 600, - 500 + 550, - 500 + 550, - 500
+ 550, - 500 + 600, - 500 + 550, -1550 + 550, - 500
+ 600, -1550 + 550, - 500 + 600, - 500 + 550, - 500
+ 550, - 500 + 550, -1600 + 550, - 500 + 550, -1550
+ 600, - 500 + 550, -1550 + 550, -1600 + 550, -1550
+ 600, -1550 + 550
unsigned int rawData[99] = {4350,4350, 550,1550, 550,500, 600,1550, 550,1550, 600,500, 550,500, 550,1600, 550,500, 550,500, 550,1600, 550,500, 550,500, 550,1600, 550,1550, 550,500, 600,1550, 550,1600, 550,500, 550,1550, 600,1550, 550,1550, 600,1550, 550,1550, 600,1550, 550,500, 600,1550, 550,500, 550,500, 600,500, 550,500, 550,500, 550,500, 600,500, 550,1550, 550,500, 600,1550, 550,500, 600,500, 550,500, 550,500, 550,1600, 550,500, 550,1550, 600,500, 550,1550, 550,1600, 550,1550, 600,1550, 550}; // SAMSUNG B24DBF40
unsigned int data = 0xB24DBF40;

Hi @Costas
I’m going to start looking at controlling my LG S12AHP (AS-H126RLMO) inverter aircon in the next week or so.

I’d prefer to use a Wemos D1 Mini, but after doing a a bit of initial research it seems that the GitHub IRremote fork for ESP8266 doesn’t include an LG library so I’ll probably start by looking at getting something working on an Arduino then if that works okay I’ll see if I can port it across to an ESP.

If anyone has experience of using an ESP with an LG HVAC unit I’d be interested to hear anything that could save me some time.

Pete.

Model LG TSNC1825NW5.

Yes. This message appears. Should I change this part?

  if (param.asInt()){
    irsend(irON, sizeof(irON) / sizeof(irON[0]), khz); //  Turn On
    delay(25);

see IRremote example. use irsend demo and not irsendraw.

My code is not hexadecimal. Will it work?
for (int i = 0; i < 3; i++) {
		irsend.sendSony(0xa90, 12);
		delay(40);

irsend uses hex codes and you will have to get the ir signals from the AC’s remote. use a ir receiver to read the ir signal. use example IR rec dump 2

Encoding : UNKNOWN
Code : 64EE4580 (32 bits)
Timing[59]:
+3000, -9700 + 400, -1700 + 350, - 750 + 250, - 700
+ 300, - 750 + 300, -1750 + 250, - 600 + 450, - 700
+ 300, - 700 + 300, -1750 + 250, -1700 + 350, - 750
+ 250, - 750 + 250, - 750 + 300, - 700 + 300, - 700
+ 300, - 650 + 400, - 650 + 350, - 650 + 350, - 650
+ 350, - 600 + 400, - 750 + 250, -1700 + 350, - 700
+ 300, -1700 + 350, - 650 + 350, - 750 + 250, - 750
+ 250, -1700 + 350
unsigned int rawData[59] = {3000,9700, 400,1700, 350,750, 250,700, 300,750, 300,1750, 250,600, 450,700, 300,700, 300,1750, 250,1700, 350,750, 250,750, 250,750, 300,700, 300,700, 300,650, 400,650, 350,650, 350,650, 350,600, 400,750, 250,1700, 350,700, 300,1700, 350,650, 350,750, 250,750, 250,1700, 350}; // UNKNOWN 64EE4580

I should use 0x64EE4580?

since the encoding is unknown. try irsend command only and try which ir receiver are you using.

You can do so much more with an ESP than an Arduino but it’s probably easier to get started with the Arduino.
In due course you will not be limited by AC devices that are already in the libraries. Our IR projects that use ESP’s have a learner feature to store almost any IR signal.

irsend.sendRaw(rawData,59,38); 38Kz - rawData"rename"

A little late to the party, this topic is two years old :rofl: