IRremote IRSend and storing raw codes into arrays CONSUMING TOO MUCH MEMORY

OK so ... I have a Cisco brand cable TV box and I wanted to make an Arduino based IR remote control that I manipulate with a java program using an ESP8266 as a simple relay between the java app and the Arduino. And the WiFi / relay portion works just fine ... where I am having a problem is in the specific IR codes themselves.

Since there doesn't seem to be a Cisco brand "awareness" in the IRremote library, I went ahead and set up the Arduino as a receiver and I just hit the buttons and used the raw code values that I got back which end up looking something like this:

unsigned int ciscoGuide[] = {3300,3350,800,2550,750,2550,800,850,800,2500,850,2500,800,900,800,2500,800,2550,800,850,800,850,800,850,800,900,750,900,750,2550,800,900,750,850,800,2550,800,850,800,850,800,2550,800,2500,800,2550,800};

This array can then be sent to the cable box using IRSend.h and passing the array plus it's size and the frequency into that library which does also work fine...

MY PROBLEM IS in a library I made that contains something like 50 of these arrays which can be invoked easily from my java program with simple one word commands...

Having 50+ of those arrays in my library ... when I compile everything for the Arduino, it says that I'm using 348% of available memory ... so the compiler chokes obviously and tells me its not gonna happen ... and so I'm not sure how I can do what I want to do now, but I'd like to believe there is a way...

Anyone out there an expert with IR who can point me in the right direction?

Thank you,

Mike

Did you use the IRrecvDumpV2 example to dump the raw codes? If you used a different sketch you might want to try IRrecvDumpV2 which will tell you if the encoding matches a known protocol.

You could also add a decoder/encoder for the Cisco protocol. It looks like one kind of bit is 800,800 and the other kind of bit is 800/2550. It shouldn't take much to compress each code down to a single long int.

johnwasser:
Did you use the IRrecvDumpV2 example to dump the raw codes? If you used a different sketch you might want to try IRrecvDumpV2 which will tell you if the encoding matches a known protocol.

You could also add a decoder/encoder for the Cisco protocol. It looks like one kind of bit is 800,800 and the other kind of bit is 800/2550. It shouldn't take much to compress each code down to a single long int.

Is there a way to use the arrays that I already have and convert them? Or is this another exercise where I need to run through the buttons again from the remote to the arduino using this V2 library?

MY PROBLEM IS in a library I made that contains something like 50 of these arrays which can be invoked easily from my java program with simple one word commands...

Why not have the Java program send the appropriate data to the 8266 to be passed on ? That way the array data does not have to be in the 8266 but on whatever the device is that you are running Java on.

Use PROGMEM.
Factor the numbers.

More here

If you put your data in PROGMEM you will need a version of IRsend::sendRaw() that can read from PROGMEM:

void  IRsend::sendRaw_p (const unsigned int buf[] PROGMEM,  unsigned int len,  unsigned int hz)
{
    // Set IR carrier frequency
    enableIROut(hz);
    
    for (unsigned int i = 0;  i < len;  i++) {
        if (i & 1)  space(pgm_read_word_near(buf[i])) ;
        else        mark (pgm_read_word_near(buf[i])) ;
    }
    
    space(0);  // Always end with the LED off
}

Be sure to add the declaration to IRremote.h:

		void  sendRaw     		(const unsigned int buf[],  unsigned int len,  unsigned int hz) ;
        // Add this line:
        void  sendRaw_p         (const unsigned int  buf[] PROGMEM,  unsigned int len,  unsigned int hz) ;

Then call irsend.sendRaw_p() instead of irsend.sendRaw() when you are passing an array in PROGMEM. To put your array in PROGMEM, add the keyword just before the ‘=’:

  unsigned int irSignal[] PROGMEM = {9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; //AnalysIR Batch Export (IRremote) - RAW

UKHeliBob:
Why not have the Java program send the appropriate data to the 8266 to be passed on ? That way the array data does not have to be in the 8266 but on whatever the device is that you are running Java on.

I actually have been trying to do this ... but the 8266 has to relay between the java program and the nano ... and I was successful at getting the codes to the 8266, but for some reason when it sends it on to the nano over software serial (the hardware serial on my nano's are all dead because they suck) ... I use an LED to see if the code made it and was sent through the IR library and for some reason it's not ... and troubleshooting without a working usb port on a nano kinda sucks .... but some of the other recommendations here look promising so I think I'm going to see if I can make it work the way I originally wanted to ... its much simpler in terms of the interaction with the java program.

johnwasser:
If you put your data in PROGMEM you will need a version of IRsend::sendRaw() that can read from PROGMEM:

WOW, thank you very much this looks promising … I use CLion to write my Arduino code and when I added the function to the cpp file and the declaration to the header file, the IDE complains about one portion of the code:

I have non idea what that even means.

but the 8266 has to relay between the java program and the nano

Do you actually need to use a Nano at all ?

If I understand correctly your Java program sends commands to the 8266 which passes them on to the Nano to be decoded and sent as IR signals to the cable TV box.

If that is right then why not use the 8266 to send the decoded commands to the TV box ? If my understanding is not correct then please explain in more detail what part the Nano plays in your project ?

UKHeliBob:
If that is right then why not use the 8266 to send the decoded commands to the TV box ? If my understanding is not correct then please explain in more detail what part the Nano plays in your project ?

No, your understanding is correct, and I did purchase and attempt to do this with a Node MCU, but the IR Libraries are different for the Node MCU, and there is a stepper motor control portion of this project which I haven't even mentioned because its not really relevant to the issue at hand, and ultimately I abandoned trying to use the Node because I ran into more obstacles than I was willing to deal with.

I abandoned trying to use the Node because I ran into more obstacles than I was willing to deal with.

and then you ran into some different obstacles.

When you encounter a problem the answer rarely lies in adding more complication

UKHeliBob:
and then you ran into some different obstacles.

When you encounter a problem the answer rarely lies in adding more complication

My original design was a nano with an ESP-8266-01 ... someone in this forum convinced me to try the Node MCU ... I tried it ... I wasn't happy where it was going, so I went BACK to the design that I started with ... any other criticisms for me?

Believe it or not, the Node MCU was a more complicated solution because of the difficulties I had with the IR library and it not having a feature I need, then controlling the stepper motor and some other things I am doing with this project, the Node MCU turned out to be useless for this project ... it were issues with some of the pins and the way I was limited in their usage and it just became frustrating and I didn't want to keep trying to solve one road block after the next ... this solution WORKS ... it's not very complicated and Its been fun to work on.

any other criticisms for me?

It is your project so you can do it however you like, but until you mentioned the

not really relevant

stepper motor I would still have favoured using the 8266 alone as the bridge between the Java device and the TV box. What, may I ask, is the purpose of the stepper motor in a project controlling a cable TV box ? I am intrigued

Now you have added
and now

some other things I am doing with this project

Don't you think it might help if you gave us an idea of the full scope of the project ?

UKHeliBob:
It is your project so you can do it however you like, but until you mentioned thestepper motor I would still have favoured using the 8266 alone as the bridge between the Java device and the TV box. What, may I ask, is the purpose of the stepper motor in a project controlling a cable TV box ? I am intrigued

Now you have added
and now
Don't you think it might help if you gave us an idea of the full scope of the project ?

When I'm only dealing with a specific issue, I don't think it's prudent to complicate a forum thread with details that aren't relevant.
This project will be an Arduino that is basically a "command center" for my elderly mothers television technology which includes a 55" Samsung TV, the Cisco cable box and a Roku ... She has issues with hitting the IR in the right spot because of the way things have to laid out in her place so Im going to use this as an IR Relay, as well as being able to control devices from the next room (with Java app) and the stepper motor is controlling volume on a set of speakers with subwoofer that have an analog volume knob... everything works but the last part Im dealing with now is this issue (the reason I started this thread in the first place) ... One of the problems I had with the IR Library for the Node MCU was that it wasn't able to give me control of LED blink feedback which is needed for this project ... my mom always thinks that she needs new batteries for her remote ... like every month ... and I keep telling her that she doesnt its just an issue with the angle of the IR etc. which I HOPE to solve with the IR Relay .. but I added into my code a feature where if she holds down the Exit button for more than one second, it will blink an LED which also happens to reflect the strength of the IR its receiving as when I did it from different angles, the brightness of the LED varied with those changes ... but like I said ... I cant do that feature with the NodeMCU IR Library but the regular IRremote library I CAN ... and having that ability will let me show her that her remote is working when she thinks its not.

johnwasser:
If you put your data in PROGMEM you will need a version of IRsend::sendRaw() that can read from PROGMEM:

John,
It seems that even though CLion is complaining about reading the array out of PROGMEM with the macro you specified, when I use the Arduino IDE to compile everything, it compiles just fine.
Thank you for putting that together for me.
Mike

Good luck with the project, which will hopefully help your mother however you implement it

I cant do that feature with the NodeMCU IR Library but the regular IRremote library I CAN

Another intriguing titbit of information. Out of interest, what functionality in one library allows you to do this that is not in the other one ?

UKHeliBob:
Good luck with the project, which will hopefully help your mother however you implement it
Another intriguing titbit of information. Out of interest, what functionality in one library allows you to do this that is not in the other one ?

The standard IRremote library has a blink13 function that turned out to be easily modified to assign a different pin for blinking and in my case, I am using an LED that uses a positive cathode and negative anode, so I even had to tweak the library so that when it did flash the LED, it needed to go LOW for on and HIGH for off .. and the IRremoteESP8266 library does seem to have a blink13 function, but its very strict in its implementation and any attempts to tweak it simply did't work and I was getting frustrated with it. I suspect that it blinks pin 13 using direct register writing and not using the digitalWrite function ... and I didn't want to have to learn how to do all that ... not to mention I was also having issues with controlling my stepper motor ... at some point you have call a dead horse a dead horse and just walk away.