Control A/C with blynk only simple ON/OFF code problem

Hello, i need turn my A/C ON/OFF with blynk and simple two buttons.
if i remove this part of code ON function is working

BLYNK_WRITE(V1)
{
int statBUTTONB = param.asInt();
if(statBUTTONB == 1)
  {
      irsend.sendRaw(offa, sizeof(offa) / sizeof(offa[0]),khz); 
  }  
}

But if i leave it there blynk is simply offline. What i do wrong? It may be due

_Sketch uses 19946 bytes (61%) of program storage space. Maximum is 32256 bytes._
_Global variables use 2007 bytes (97%) of dynamic memory, leaving 41 bytes for local variables. Maximum is 2048 bytes._
**Low memory available, stability problems may occur.**

or not?

This is whole not working code but imo it should work.

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <IRremote.h>

IRsend irsend;


int khz=38; 
unsigned int offa[] = {4468, 4340, 572, 1616, 572, 528, 568, 1624, 568, 1620, 572, 528, 568, 528, 576, 1616, 564, 536, 572, 528, 568, 1624, 568, 532, 572, 524, 572, 1620, 572, 1616, 564, 532, 576, 1620, 572, 528, 576, 1616, 564, 1624, 568, 1620, 572, 1616, 576, 524, 572, 1620, 572, 1616, 572, 1624, 568, 532, 564, 532, 604, 496, 572, 524, 572, 1620, 568, 528, 568, 532, 576, 1620, 620, 1568, 572, 1616, 568, 532, 572, 524, 572, 528, 568, 528, 568, 532, 572, 528, 568, 532, 576, 520, 608, 1588, 572, 1616, 572, 1616, 568, 1620, 572, 1620, 568, 5240, 4436, 4380, 572, 1620, 572, 524, 572, 1620, 568, 1620, 572, 528, 568, 528, 568, 1624, 568, 532, 572, 528, 568, 1624, 568, 528, 568, 532, 576, 1612, 568, 1624, 568, 528, 568, 1628, 572, 528, 568, 1620, 572, 1616, 576, 1612, 568, 1620, 572, 528, 568, 1624, 576, 1616, 576, 1620, 572, 524, 572, 528, 564, 532, 576, 524, 572, 1616, 576, 524, 572, 528, 568, 1628, 572, 1616, 564, 1624, 568, 532, 564, 532, 572, 524, 572, 528, 568, 532, 576, 524, 572, 528, 568, 528, 576, 1620, 572, 1616, 564, 1624, 568, 1620, 572, 1620, 572};

unsigned int cold[] = {4468, 4344, 576, 1616, 564, 532, 576, 1620, 572, 1616, 576, 524, 572, 528, 568, 1620, 568, 532, 564, 536, 572, 1624, 568, 528, 576, 524, 572, 1616, 568, 1624, 568, 528, 576, 1620, 572, 528, 568, 532, 576, 1616, 576, 1616, 572, 1616, 568, 1620, 572, 1620, 572, 1620, 568, 1628, 564, 1624, 568, 532, 596, 500, 604, 496, 600, 500, 596, 504, 592, 508, 600, 500, 596, 1592, 600, 500, 596, 504, 600, 496, 600, 500, 596, 504, 604, 496, 600, 1596, 596, 504, 600, 1592, 600, 1588, 604, 1588, 592, 1596, 596, 1592, 600, 1592, 568, 5244, 4476, 4344, 596, 1596, 596, 500, 596, 1600, 604, 1584, 596, 504, 592, 504, 600, 1588, 596, 504, 600, 504, 592, 1600, 592, 504, 604, 496, 600, 1588, 604, 1584, 596, 504, 604, 1592, 596, 504, 592, 508, 600, 1592, 600, 1588, 604, 1584, 596, 1592, 600, 1592, 600, 1592, 600, 1592, 600, 1592, 600, 496, 600, 500, 592, 508, 600, 496, 600, 500, 596, 504, 600, 500, 596, 1592, 600, 500, 596, 504, 592, 504, 604, 496, 600, 500, 596, 504, 600, 1596, 596, 500, 596, 1596, 596, 1596, 596, 1592, 600, 1588, 604, 1584, 596, 1596, 564, 41416, 224};

char auth[] = "323********************";   //blynk token
 
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);

//Blynk.virtualWrite(V0, 0);
//Blynk.virtualWrite(V1, 0);
//Blynk.syncAll();
}

BLYNK_WRITE(V0)
{
int statBUTTON = param.asInt(); 
if(statBUTTON == 1)
  {
      irsend.sendRaw(cold, sizeof(cold) / sizeof(cold[0]),khz); 
  }
}

BLYNK_WRITE(V1)
{
int statBUTTONB = param.asInt();
if(statBUTTONB == 1)
  {
      irsend.sendRaw(offa, sizeof(offa) / sizeof(offa[0]),khz); 
  }  
}

void loop() 
{
Blynk.run();
}

please help me im out of ideas blynk is OFFLINE with this code. Using Arduino UNO with ethernet shield.IR led is on PIN D3 nothing more is connected.

I’m not familiar with this IRremote library but looking at your code, when you irsend.sendRaw(offa, sizeof(offa) / sizeof(offa[0]),khz); you send the entire offa and I bet it takes a long time resulting in a blocking function and doesn’t blynk to communicate.

The library https://github.com/z3t0/Arduino-IRremote has a lot of examples, aren’t you able to find your A/C there and use the specific example instead of this sendRaw?

thank you, im trying to figure out how irsend works… i have irsendSAMSUNG i have hex code but still dont understand how it code if use my raw code or not or whats diff. Trying to use ESP8266 for it…should it work? with sendRaw.

solved :slight_smile:
i switched to ESP8266 12-E and edited code to it.

working code for anyone in future

//#define BLYNK_PRINT Serial
//#include <SPI.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define IR_LED 4
IRsend irsend(IR_LED);

char auth[] = "*************";
char ssid[] = "*************";
char pass[] = "************";
int khz=38; 


uint16_t rawDataoff[201] = {4468, 4340, 572, 1616, 572, 528, 568, 1624, 568, 1620, 572, 528, 568, 528, 576, 1616, 564, 536, 572, 528, 568, 1624, 568, 532, 572, 524, 572, 1620, 572, 1616, 564, 532, 576, 1620, 572, 528, 576, 1616, 564, 1624, 568, 1620, 572, 1616, 576, 524, 572, 1620, 572, 1616, 572, 1624, 568, 532, 564, 532, 604, 496, 572, 524, 572, 1620, 568, 528, 568, 532, 576, 1620, 620, 1568, 572, 1616, 568, 532, 572, 524, 572, 528, 568, 528, 568, 532, 572, 528, 568, 532, 576, 520, 608, 1588, 572, 1616, 572, 1616, 568, 1620, 572, 1620, 568, 5240, 4436, 4380, 572, 1620, 572, 524, 572, 1620, 568, 1620, 572, 528, 568, 528, 568, 1624, 568, 532, 572, 528, 568, 1624, 568, 528, 568, 532, 576, 1612, 568, 1624, 568, 528, 568, 1628, 572, 528, 568, 1620, 572, 1616, 576, 1612, 568, 1620, 572, 528, 568, 1624, 576, 1616, 576, 1620, 572, 524, 572, 528, 564, 532, 576, 524, 572, 1616, 576, 524, 572, 528, 568, 1628, 572, 1616, 564, 1624, 568, 532, 564, 532, 572, 524, 572, 528, 568, 532, 576, 524, 572, 528, 568, 528, 576, 1620, 572, 1616, 564, 1624, 568, 1620, 572, 1620, 572};
uint16_t rawData[201] = {4468, 4344, 576, 1616, 564, 532, 576, 1620, 572, 1616, 576, 524, 572, 528, 568, 1620, 568, 532, 564, 536, 572, 1624, 568, 528, 576, 524, 572, 1616, 568, 1624, 568, 528, 576, 1620, 572, 528, 568, 532, 576, 1616, 576, 1616, 572, 1616, 568, 1620, 572, 1620, 572, 1620, 568, 1628, 564, 1624, 568, 532, 596, 500, 604, 496, 600, 500, 596, 504, 592, 508, 600, 500, 596, 1592, 600, 500, 596, 504, 600, 496, 600, 500, 596, 504, 604, 496, 600, 1596, 596, 504, 600, 1592, 600, 1588, 604, 1588, 592, 1596, 596, 1592, 600, 1592, 568, 5244, 4476, 4344, 596, 1596, 596, 500, 596, 1600, 604, 1584, 596, 504, 592, 504, 600, 1588, 596, 504, 600, 504, 592, 1600, 592, 504, 604, 496, 600, 1588, 604, 1584, 596, 504, 604, 1592, 596, 504, 592, 508, 600, 1592, 600, 1588, 604, 1584, 596, 1592, 600, 1592, 600, 1592, 600, 1592, 600, 1592, 600, 496, 600, 500, 592, 508, 600, 496, 600, 500, 596, 504, 600, 500, 596, 1592, 600, 500, 596, 504, 592, 504, 604, 496, 600, 500, 596, 504, 600, 1596, 596, 500, 596, 1596, 596, 1596, 596, 1592, 600, 1588, 604, 1584, 596, 1596, 564, 41416, 224};

void setup()
{
irsend.begin();
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
Blynk.begin(auth, ssid, pass);
}

void loop() 
{
Blynk.run();

}

BLYNK_WRITE(V0)
{
int statBUTTON = param.asInt(); 
if(statBUTTON == 1)
  {
      irsend.sendRaw(rawData, 201, 38);
  }
}

BLYNK_WRITE(V1)
{
int statBUTTONB = param.asInt();
if(statBUTTONB == 1)
  {
      irsend.sendRaw(rawDataoff, 201, 38);
  }  
  
}