LuisMiCa / IRsmallDecoder

A small, fast and reliable infrared signals decoder to control Arduino projects with remotes.
MIT License
15 stars 5 forks source link

IR decoder and esp32 #7

Open fungreenfox opened 4 months ago

fungreenfox commented 4 months ago

example compiles and run okay, and printing out the "waiting for..:" No reaction from the remote. Esp32 30pin, gpio35. Was working with another library until esp32 firmware got updated. Not much working with this, so downgraded firmware to 2.1 from 3.x Error after monitor printout: E (130) gpio: ����}���}����}���������failed (0x103) So it doesn't like the pin its at?

LuisMiCa commented 4 months ago

I haven't tested this library on ESP32 boards, but I belive that some of the pins won't work because, according to the ESP32 documentation: "...only pins that support both input & output have integrated pull-up and pull-down resistors. Input-only GPIOs 34-39 do not..." And this library uses INPUT_PULLUP mode for the IR receiver signal...

There's also another issue with the ISR functions: they do not have the recomended attribute for ESP32 systems (IRAM_ATTR or ARDUINO_ISR_ATTR). I'm not sure how much this might affect the funcionality.

Try connecting the sensor to a different pin... You can also add #define IRSMALLD_DEBUG_STATE before the #include "IRsmallDecoder.h", to see if the ISR is being called (it should print FSM's state transitions to the serial port).

LuisMiCa commented 4 months ago

So, I've now tested this library on an Arduino Nano ESP32 and was able to make the HelloNEC example work by creating the decoder object in the loop() function (as a static object) or by dynamically allocating it in the setup() function.

Method 1: Instead of declaring a global object IRsmallDecoder irDecoder(2);, declare it inside the loop() function as a static object. As for the data structure irData, it can be declared either globally or inside the loop() function.

a

Method 2: Declare a pointer to an IRsmallDecoder object, then do a dynamic allocation in the setup() function. However, this way you'll be working with a pointer, so, in the loop(), instead of using irDecoder.dataAvailable(irData), you must use irDecoder->dataAvailable(irData).

b

Let me know if this works on your ESP32 board. If it does, you should consider adding the recommended attribute ARDUINO_ISR_ATTR in the ISR function, for the protocol you are using. If it's the NEC protocol, then, in the IRsmallD_NEC.h file, change line 51 from void IRsmallDecoder::irISR() { to void ARDUINO_ISR_ATTR IRsmallDecoder::irISR() {.

If this works with other ESP32 boards, besides the Arduino Nano ESP32, I might consider updating this library with that change.

fungreenfox commented 3 months ago

Many thanks for puzling this. Ill give it a try when i come around there. Its for a si4703 radio module in case with amplifier, big project. It has been difficult to get around, after uploading new firmware and updating the arduino IDE also. Had to change a lot, and the Irremote.h never got to work for me, after version 2.6.1, so i wanted to try this decoder instead.