ESP32 (Heltec Wifi32 Kit) and IRremoteESP8266

Hello Community,

im experimenting with the FastLED library and try to controll / switch between the animations with an Logitech Harmony 555 remote controll. using a TSOP4838 IR Receiver.
So far im quite sucessfully but now i ran into the following Problem.

The Remote seems to send the IR code 3 times on a single buttonpress.
This is my Code in the loop:

EVERY_N_MILLISECONDS(5) {
if (irrecv.decode(&results)) {
Serial.print(millis());
Serial.print(" - IR_CODE: ");
serialPrintUint64(results.value, HEX);
Serial.print(" - ");

switch (results.value) {
case KEY_0:
if(LEDS_ON) {
toggle_fire = false;
Serial.println("Key 0");
gCurrentPatternNumber = 1;
}
break;

[...more case statements...]

case KEY_BLUE:
Serial.println("Key BLUE");
break;
}
irrecv.resume();
}
}

if i now press a Key on the Remote the console shows the following

57739 - IR_CODE: E0E0A05F - Key 2
57840 - IR_CODE: E0E0A05F - Key 2
57991 - IR_CODE: E0E0A05F - Key 2
68603 - IR_CODE: E0E010EF - Key 4
68715 - IR_CODE: E0E010EF - Key 4
68816 - IR_CODE: E0E010EF - Key 4

So every keypress on the remote is received 3 times by the ESP32
In most cases its not a big deal but i want to youse some keys to toggle functions, like Leds on / Leds off so receiving the code 3 times on a single buttonpress becomes a problem.

i can add a delay at the end of the if (irrecv) loop what somehow solve the problem but i dont want to work with delays because of FastLED.

So how can i make sure only one IR code is receivied or the received code is recognised only once so if i use a button for a toggle function the function wont toggle 3 times on a single buttonpress?

Any hints would be appreciated

Why not use that the IR sends 3 times as a data received verification?

Data stream 1 comes in, clear all the previous data stream info and get ready to receive new info. Data Stream 2 comes in, store the data stream info. Data stream 3 comes in, compare data stream 3 with data stream 2, do they match? If they do then do the thing. If they do not match then this is a new data stream set condition data stream 1.

Or you can just ignore the other 2 data streams.

thats what i want to do, but atm i have no clue how to do it, thats why i asked for help here :wink:

What do you want to do, Ignore or process?

If you want to ignore then record the last message received and if the next message matches the previous, ignore.

I described in #1 how to process.


I'm not going to write the code for you, someone else may. I suggest you make your best attempt at one of the two options and, after you fail, post your best efforts.


But seriously you can write

if (irrecv.decode(&results))

and if(LEDS_ON)
but you cannot write a code that saves the previous info and compare it to the newly received info?

well im quite new and doesnt have much experience with c++, im comming from php coding where you dont have to care if you store an int, a flow or a string in a variable or array.

my attempt was something like this

...
int i = 0; 
char value[3] = {0};

if (irrecv.decode(&results)) {
  value[i] = results.value;
  i++;
}

i = 0;

if (value[0] == value[1] || value[0] == value[2]) {
  swich (value[0]) {
    [case....]

but somehow it doesnt seems to work

make a variable call it whatever and make it a String

Now read your incoming info does it equal the data stored in the string.

No, it is new info store in whatever and process your thing.

Now read your incoming info does it equal the data stored in the whatever.

No, It is new info store in whatever and process your thing.

Yes, ignore.