How to send HEX data using Arduino

Everything related to protocols and IR codes
Post Reply
peros550
Posts: 8
Joined: Thu Aug 16, 2018 3:34 pm

How to send HEX data using Arduino

Post by peros550 »

How, sorry for this basic question.

I am trying to reverse engineer my A/C (Toyotomi) protocol and I believe I'm doing progress.
One thing I still don't have clear in mind is how I would use the hex values and send data using Arduino and IRemote library.

(I have already sent captured RAW data successfully, I would just like to see how could I do that using hex data. )

Many Thanks
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: How to send HEX data using Arduino

Post by AnalysIR »

Sorry for the delay in responding, I must have missed the notification.

You could use the examples provided on our blog.
https://www.analysir.com/blog/2015/09/0 ... r-signals/
peros550
Posts: 8
Joined: Thu Aug 16, 2018 3:34 pm

Re: How to send HEX data using Arduino

Post by peros550 »

Many thanks for your support!!!!!
peros550
Posts: 8
Joined: Thu Aug 16, 2018 3:34 pm

Re: How to send HEX data using Arduino

Post by peros550 »

Hi again, I need to ask for your help.

My remote has been recognized by AnalysisIR as ELECTROLUX67_134AC. The bits are 67. Here is a batch export:

Code: Select all


21 : ELECTROLUX67_134AC : 25 : 31200A0040002000E : 67 : 0

unsigned int Signal_25_21[] = {9024,4360,736,1568,716,456,740,452,744,1564,720,1564,716,456,740,452,740,456,744,1540,740,456,744,448,740,1548,740,452,740,452,748,448,744,456,740,452,740,456,740,452,744,452,740,452,744,456,740,452,740,456,740,452,744,452,744,452,744,452,740,1544,740,452,744,1544,740,452,740,452,748,1540,740,452,744,19756,744,452,740,452,744,452,744,448,744,452,744,452,740,452,744,452,744,452,744,452,744,448,744,452,744,452,744,1540,744,448,744,452,744,452,744,452,740,452,744,452,744,452,740,456,740,452,744,452,744,452,744,452,740,452,744,452,744,452,740,1568,716,1544,744,1564,716}; //AnalysIR Batch Export (IRremote) - RAW

int khz=38;

irsend.sendRaw(Signal_25_21, sizeof(Signal_25_21)/sizeof(int), khz); //AnalysIR Batch Export (IRremote) - RAW
 // AnalysIR IR Protocol: ELECTROLUX67_134AC, Key:  25
I checked the link that you 've posted and there is an example there for Mitsubish AC. I thought I would modify the following values to reflect the ELECTROLUX67_134AC protocol and reuse the same code. Here is what I did:

Code: Select all

#define MITSUBISHI88AC_HEADER_MARK 9000
#define MITSUBISHI88AC_HEADER_SPACE 4500
#define MITSUBISHI88AC_ONE_MARK 600
#define MITSUBISHI88AC_ZERO_MARK 600
#define MITSUBISHI88AC_ONE_SPACE 1700
#define MITSUBISHI88AC_ZERO_SPACE 600
#define MITSUBISHI88AC_TRAILER_MARK 200
Unfortunately, I was not able to send any signals either RAW or HEX.

To eliminate the hw factor, I need to report that using the same board (it's a Wemos D1 mini) with IRremoteESP8266 library I can successfully send signals as RAW and my (Toyotomi) A/C fully recognizes them. Any help or suggestion would be highly appreciated.

I have also attached my captured signals.

Many Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: How to send HEX data using Arduino

Post by AnalysIR »

As yo ucan see from the signal trace, the signal is split in 2.

It is contructed as fillws:
Header
35 data Bits
trailer with long 20ms gap
32 data bits
Final trailer


So you will need to update the code/logic to also send the trailer with the long gap in the middle of the signal and also split the data bits into 2 parts.
peros550
Posts: 8
Joined: Thu Aug 16, 2018 3:34 pm

Re: How to send HEX data using Arduino

Post by peros550 »

Session History01-Sep-2018_History.txt
I have followed your advice and made changes to the code of Simple Infrared PWM part3 to work with ELECTROLUX67_134AC protocol.

here is a changed function (sendHexMITSUBISHI88AC):

Code: Select all

void sendHexMITSUBISHI88AC(unsigned char *sigArray, unsigned int sizeArray, unsigned char kHz) { //Mitsubish 88 bit Ir protocol format

#define MITSUBISHI88AC_HEADER_MARK 9000
#define MITSUBISHI88AC_HEADER_SPACE 4500

#define MITSUBISHI88AC_ONE_MARK 590
#define MITSUBISHI88AC_ONE_SPACE 1650

#define MITSUBISHI88AC_ZERO_MARK 725
#define MITSUBISHI88AC_ZERO_SPACE 475

#define MITSUBISHI88AC_TRAILER_MARK 600
  //
  if (carrierFreq != kHz)  initSoftPWM(kHz); //we only need to re-initialise if it has changed from last signal sent
  sigTime = micros(); //keeps rolling track of signal time to avoid impact of loop & code execution delays

  // First send header Mark & Space
  mark(MITSUBISHI88AC_HEADER_MARK);
  space(MITSUBISHI88AC_HEADER_SPACE);



  int counter1 =0;

 Serial.println(F("SENDING NEW CODE"));
Serial.println(F("  "));
  for (unsigned int i = 0; i < sizeArray; i++) { //iterate thru each byte in sigArray
    register unsigned char bitMask =  0x80; //starting value of bitmask fo each Hex byte
Serial.print(F("Now sending: "));
 Serial.println(sigArray[i],HEX);

if (i==0){
  // The sigArray consists of 9bytes, 9 Bytes x 8 bits = 72bits. 
  //This specific protocol uses 67 bits. Therefore, first 5 bits are not to be taken into account.
  bitMask = (unsigned char) bitMask >> 1; 
  bitMask = (unsigned char) bitMask >> 1; 
  bitMask = (unsigned char) bitMask >> 1; 
  bitMask = (unsigned char) bitMask >> 1; 
  bitMask = (unsigned char) bitMask >> 1; 


for (int k = 0 ; k<3; k++)
  {
               if (bitMask & sigArray[i]) { //its a One bit
                   mark(MITSUBISHI88AC_ONE_MARK);
                  space(MITSUBISHI88AC_ONE_SPACE);
                  Serial.print(F("1"));
                }
                else { // its a Zero bit
                  mark(MITSUBISHI88AC_ZERO_MARK);
                  space(MITSUBISHI88AC_ZERO_SPACE);
                  Serial.print(F("0"));
                }
                bitMask = (unsigned char) bitMask >> 1; // shift the mask bit along until it reaches zero & we exit the while loop
                counter1+=1;
  }   
}
else
{

for (int k = 0 ; k<8; k++){
                if (bitMask & sigArray[i]) { //its a One bit
                   mark(MITSUBISHI88AC_ONE_MARK);
                  space(MITSUBISHI88AC_ONE_SPACE);
                  Serial.print(F("1"));
                }
                else { // its a Zero bit
                  mark(MITSUBISHI88AC_ZERO_MARK);
                  space(MITSUBISHI88AC_ZERO_SPACE);
                  Serial.print(F("0"));
                }
                bitMask = (unsigned char) bitMask >> 1; // shift the mask bit along until it reaches zero & we exit the while loop
                counter1+=1;

                  if (counter1 == 36) {
                    space(19860);
                 Serial.println(F(" "));
                  }
      
    }    
   
    Serial.println(F(" "));

  }


  }
  // Last send NEC Trailer MArk

                  mark(MITSUBISHI88AC_ZERO_MARK);
                  space(MITSUBISHI88AC_ZERO_SPACE);
 
}
Then I tried to send one signal from my original remote and multiple signals through an Arduino Uno using the above function.
If you can see in the following screenshot, although the signals seem to have the correct form, they are not recognized as ELECTROLUX67_134AC and my AC does not get the commands. Hardware is tested and is able to send RAW commands to the A/C successfully.
This is the HEX I am trying to send (as decoded in the first place)

unsigned char Mitsubishi88AC_Hex[] = {0x4, 0xC0, 0x00, 0x10, 0x52, 0x00, 0x04, 0x00, 0x0A};

Any ideas as to what I might be doing wrong?
I am also attaching the session file, in case you want to take a look in the timings.
Session History01-Sep-2018_History.txt
Many Thanks
You do not have the required permissions to view the files attached to this post.
peros550
Posts: 8
Joined: Thu Aug 16, 2018 3:34 pm

Re: How to send HEX data using Arduino

Post by peros550 »

Here is the session I am referring to , on my previous message.
Session History01-Sep-2018_History.txt
You do not have the required permissions to view the files attached to this post.
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: How to send HEX data using Arduino

Post by AnalysIR »

You have have made great progress :) & at first look it just seems that the timings you are using are wrong...

...try the following..

Code: Select all

#define MITSUBISHI88AC_HEADER_MARK 9000
#define MITSUBISHI88AC_HEADER_SPACE 4500

#define MITSUBISHI88AC_ONE_MARK 600
#define MITSUBISHI88AC_ONE_SPACE 1700

#define MITSUBISHI88AC_ZERO_MARK 600
#define MITSUBISHI88AC_ZERO_SPACE 600

#define MITSUBISHI88AC_TRAILER_MARK 600
Post Reply