Max data on the Virtual Pin and Webhook

HW: ESP8266
OS: Android 10
Latest Blynk Lib

Background:
I am using a ESP8266 IR remote to turn on my light, tv and air conditioner.
I did this back in 2018, but i found there is Blynk now and would like to switch to Blynk for the implementation.
Since my device only have 2M of memory, i could not store all the raw data of IR in the Arduino, therefore i use google apps script(GAS) to send the IR raw data to the Arduino.

Q1:
Currently I update pin V1 to receive the IR raw data from GAS by sending a PUT webhook.
This is perfect for Light and TVs. But when it comes with Air Condition, I face the issue that the data was too large and my device crash.

The data is as the following.

aircon&439=3550, 1668, 506, 364, 532, 1206, 506, 360, 536, 334, 506, 364, 530, 334, 510, 360, 506, 364, 506, 360, 510, 360, 506, 364, 506, 360, 506, 364, 532, 1206, 506, 364, 506, 360, 510, 360, 506, 364, 506, 360, 504, 364, 506, 364, 506, 1232, 504, 1232, 506, 1232, 510, 360, 532, 338, 532, 1206, 506, 364, 506, 360, 506, 364, 532, 334, 536, 336, 506, 364, 506, 360, 506, 364, 506, 360, 510, 360, 532, 338, 506, 360, 506, 364, 506, 364, 506, 360, 506, 366, 506, 360, 506, 364, 506, 360, 510, 360, 506, 364, 506, 360, 536, 334, 532, 338, 506, 360, 536, 334, 506, 360, 510, 360, 506, 364, 506, 360, 510, 1228, 510, 1230, 532, 334, 510, 360, 506, 360, 536, 278, 562, 364, 532, 9874, 3556, 1662, 510, 360, 506, 1232, 510, 360, 506, 364, 506, 360, 506, 364, 506, 360, 510, 360, 506, 360, 510, 360, 506, 364, 506, 364, 506, 360, 506, 1232, 510, 360, 506, 360, 536, 334, 510, 360, 506, 360, 510, 360, 506, 364, 506, 1232, 506, 1230, 506, 1230, 510, 360, 506, 364, 506, 1232, 506, 360, 510, 360, 506, 364, 506, 360, 510, 360, 506, 360, 510, 360, 506, 286, 610, 334, 510, 360, 506, 360, 510, 360, 506, 366, 532, 334, 506, 364, 532, 1206, 506, 1232, 536, 334, 506, 364, 532, 334, 506, 364, 506, 360, 536, 334, 506, 364, 506, 360, 510, 1232, 530, 1206, 532, 334, 510, 360, 510, 360, 506, 360, 506, 366, 532, 334, 536, 334, 506, 364, 506, 360, 506, 1232, 536, 1206, 532, 1206, 506, 1232, 506, 1232, 510, 360, 506, 1232, 510, 360, 506, 1230, 506, 1232, 536, 334, 506, 1232, 506, 1230, 510, 360, 506, 364, 506, 360, 510, 360, 532, 334, 510, 360, 506, 360, 510, 360, 506, 366, 506, 364, 506, 360, 506, 364, 532, 334, 510, 1232, 532, 1206, 506, 1232, 506, 364, 506, 360, 536, 334, 532, 338, 532, 334, 510, 362, 530, 340, 506, 360, 506, 364, 506, 1232, 506, 1232, 510, 1232, 506, 360, 506, 360, 510, 360, 510, 360, 506, 360, 510, 360, 506, 364, 506, 360, 510, 360, 506, 360, 510, 360, 506, 364, 506, 360, 510, 360, 532, 334, 510, 360, 506, 1232, 506, 364, 506, 1232, 510, 1226, 510, 360, 506, 360, 510, 360, 506, 1232, 510, 360, 532, 338, 506, 360, 506, 364, 532, 1206, 506, 1232, 510, 1228, 510, 360, 510, 360, 506, 360, 510, 1232, 506, 360, 510, 360, 506, 366, 506, 360, 506, 364, 506, 1230, 506, 364, 506, 1230, 506, 1230, 536, 334, 506, 1232, 506, 1232, 510, 360, 506

when using Serial.println to print this data out, I got a SW WDT reset.
If i don’t print then the code use this data to send also crash.
I have set BLYNK_MAX_READBYTES to 4096 already as i look through the community.
I have also checked this data, it appears to be about 2256 Bytes.
Is there anyway i can use data as it is?

function that processing the IR Raw Data was the same as before i use Blynk.

Q2:
Since i could not send the data like the above method.
I tried another method to set V2 as a webhook and while received “aircon” string i call

Blynk.virtualWrite(V2, "https://GASwebhook/exec");

calling this seems to be fine. I set the URL and GET method with content type as Text/plain.
I could receive some data. But it’s not my IR raw data, instead is a html code.
Seems to be i need to request for the body of the GET response data.
How do i do that.

PS. Just for reference.
I used to use the following piece of code to get the IR raw data from GAS, and the aircon raw data was able to process.

String doRedirectGet()
{
  HTTPSRedirect* client = nullptr;
  String body = "";
  client = new HTTPSRedirect(HTTPS_PORT);
  if (!client->connect(HOST, HTTPS_PORT)) {
    Serial.println("connection failed");
    return body;
  }

  client->GET(URL, HOST);
  body = client->getResponseBody();
  delete client;
  client = nullptr;
  return body;
}

What make of aircon unit are you using, and which IR library are you using?

Pete.

It’s a Panasonic. But i think the code from Japan and other regions are different.

And are you using the IRSendESP8266 library?

Pete.

No I am not using any library for sending the IR code since i am sending raw data i think.
The following code is the function i use to send.

void sendIRData(unsigned int  *data, int dataSize)
{
  int i = 0, power = HIGH;

  digitalWrite(IRLEDPIN, LOW);

  while(i < dataSize)
  {
    if(power == HIGH)
    {
      long startedTime = micros();
      while (micros() - startedTime < data[i])
      {
        digitalWrite(IRLEDPIN, HIGH);
        delayMicroseconds(8);
        digitalWrite(IRLEDPIN, LOW);
        delayMicroseconds(13);
      }

      power = LOW;
    } else {
      digitalWrite(IRLEDPIN, LOW);
      delayMicroseconds(data[i]);
      power = HIGH;
    }
    i++;
  }

  digitalWrite(IRLEDPIN, LOW);
}

The IRemoteESP8266 library has built-in support for these Panasonic range of aircon units:

A75C2311 remote (CKP)
A75C2616-1 remote (DKE)
A75C3704 remote
A75C3747 remote
CKP series A/C
CS-E7PKR A/C (DKE)
CS-ME10CKPG A/C
CS-ME12CKPG A/C
CS-ME14CKPG A/C
CS-YW9MKD A/C
CS-Z9RKR A/C
DKE series A/C
DKW series A/C (DKE)
JKE series A/C
NKE series A/C
PKR series A/C (DKE)
RKR series A/C

If you have one of these then you’ll just pass a short command to the library to transmit the correct code. Turning a Panasonic AC on will be something like ac.on();

Pete.

I have CS-WX Series.
Like i mentioned the aircons in Japan is having different codes from the other regions.
Because i tried the libs in the beginning when i build the ESP8266 IR remote the first time.
The data the library is totally different to the one sent from my aircon remote.
That why i decide to record it myself.

I think that what your data is showing are a header pulse of 3550, 1668 followd by pulses of three different durations:
Long - around 1220
Medium - around 510
Short - around 330

The variations you’re seeing 506, 532, 536, 530, 510 etc for the medium pulses are simply inaccuracies in the timing, probably caused by the capture process.
This theory is easy to prove, by changing all occurrences of 5xx to 510
If it still works then do the same for the long and short pulses, possibly tweaking the values slightly to get more consistent results.

Once you have established this you can then encode the values to much simplet (shorter) values. If you used 3, 2 and 1 to represent Long, Medium and Short then the second row of data would change from:
506, 364, 506, 360, 510, 360, 506, 364, 506, 360, 506, 364, 532, 1206, 506, 364, 506, 360, 510,
to:
2,1,2,1,2,1, 2,1,2,1,2,1, 2,3,2,1,2,1,2

You’d then need to change your sendIRdata function to translate these back into your timing data, but it would have the effect of significantly reducing the size of your raw IR variables.

If you look at your data in more detail you’ll actually see that the pairs of numbers form a pattern, and a “2,1” pattern could be reduced further to a single character that medium/short mark/space pulse.

This is an extremely simplified version of what the IR libraries do for known codes, and you could add codes and timoing into the IR library if you wished, but that’s not a very intuitive process.
However, you may find that a bit of searching will reveal someone who’s done this for you already, as a variation on the existing library.

Pete.

Is this the same for all the IR devices?
because i still have light and tv doing the same thing but with shorter data.
Looks like i have to do a study on IR code.

Most IR devices use fairly simple codes, but aircon units are a bit of a law unto themselves and all seem to use complex protocols. I guess it’s because most manufacturers have systems where aircon units can be ‘networked’ together, so they have a communication protocol that works with hard-wired thermostat type controllers as well as IR controllers.

With a well known brand like Panasonic, I’d be really surprised if someone hasn’t done at least part of the work before, even if your device uses a more unusual protocol.

Pete.

Since i could not find the Library for the IR.
If i use the data above with the following code:

void analyseAndSend(String Data)
{
  String       tempData = Data;
  int          i;
  int          dataSize = tempData.substring(tempData.indexOf("&") + 1, tempData.indexOf("=")).toInt();
  unsigned int IrData[dataSize];
  String       LcdText = tempData.substring(0, tempData.indexOf("&"));
  
  if(dataSize == 0)
    return;

  lcd.print(0, 0, "               ");
  lcd.print(3, 0, LcdText);

  tempData = tempData.substring(tempData.indexOf("=") + 1);
  for(i=0; i<dataSize; i++)
  {
    if(tempData.indexOf(",") != -1)
    {
      IrData[i] = tempData.substring(0, tempData.indexOf(",")).toInt();
      tempData = tempData.substring(tempData.indexOf(",") + 1);
       Serial.println(IrData[i]);
    }
    else
    {
      IrData[i] = tempData.toInt();
       Serial.println(IrData[i]);
      break;
    }
    yield();
  }
  sendIRData(IrData, i + 1);
}

then i get the following after some loop:

Fatal exception 9(LoadStoreAlignmentCause):
epc1=0x4023233f, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000222, depc=0x00000000

Exception (9):
epc1=0x4023233f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000222 depc=0x00000000

I guess it’s at

IrData[i] = tempData.substring(0, tempData.indexOf(",")).toInt();

when doing cast, but i can’t see what’s wrong with it.

I’ve also tried to send the data in an array.
Then inside BLYNK_WRITE
store the array into int array as the use of array[i] = param[i].asInt().
When i send a data with size of 83+2 (Light), it’s fine.
But when i send a data with 439+2 (Aircon), the arduino crashes when printing out each value.
This means arduino does not have enough memory for the aircon data?

Why not get the Arduino to print the free memory to the serial monitor during the process?

Better still, but a NodeMCU or Wemos D1 Mini.

Pete.

Tried to check free memory. It always have 4xxxx byte.
It only takes 2k for the above data.
So memory should not be a problem.
I was also able to print the full data if i disable sw WDT, so virtual pin receiving the data also shouldn’t be a problem.

But once the string is send to analyseAndSend() and for some loops then fatal exception 9 and 28, 29 occur.

Also tried some of the method found on the web. like attribute((aligned(4))) but didn’t work out.

I fixed the problem, it was a stupid mistake by myself.
Arduino complier does not pick up this.

int  dataSize = tempData.toInt();
unsigned int IrData[dataSize];

This is illegal, should use malloc for IrData.
Thanks for the help.

But the question for the webhook, no one answered.
How to i set this to soved?