crankyoldgit / IRremoteESP8266

Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
GNU Lesser General Public License v2.1
2.98k stars 832 forks source link

Problem air conditioner #26

Closed josep112 closed 7 years ago

josep112 commented 8 years ago

Hello The air conditioner uses a raw 199, this has to change the IRremote.h -> #define RAWBUF 100 to 200 and change IRremoteInt.h #define _GAP 5000 change to 50000, the problem is that there are over 300 air and the string only accepts 255 to solve this?

annhan commented 8 years ago

Hi josep112, i can change typedef struct { uint8_t recvpin; // pin for IR data from detector uint8_t rcvstate; // state machine unsigned int timer; // state timer, counts 50uS ticks. unsigned int rawbuf[RAWBUF]; // raw data uint8_t rawlen; // counter of entries in rawbuf } irparams_t;

to typedef struct { uint8_t recvpin; // pin for IR data from detector uint8_t rcvstate; // state machine unsigned long timer; // state timer, counts 50uS ticks. unsigned long rawbuf[RAWBUF]; // raw data long rawlen; // counter of entries in rawbuf } irparams_t; you can change rawbuf to 800 for all AIR (Daikin..). Sketch leaning rawbuf 800 for arduino of Link analysir.com #define LEDPIN 5 #define maxLen 800

volatile unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR

void setup() { Serial.begin(115200); //change BAUD rate as required attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal }

void loop() { // put your main code here, to run repeatedly:

Serial.println(F("Press the button on the remote now - once only")); delay(5000); // pause 5 secs if (x) { //if a signal is captured digitalWrite(LEDPIN, HIGH);//visual indicator that signal received Serial.println(); Serial.print(F("Raw: (")); //dump raw header format - for library Serial.print((x - 1)); Serial.print(F(") ")); detachInterrupt(0);//stop interrupts & capture until finshed here for (int i = 1; i < x; i++) { //now dump the times if (!(i & 0x1)) Serial.print(F("-")); Serial.print(irBuffer[i] - irBuffer[i - 1]); Serial.print(F(", ")); } x = 0; Serial.println(); Serial.println(); digitalWrite(LEDPIN, LOW);//end of visual indicator, for this time attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal }

}

void rxIR_Interrupt_Handler() { if (x > maxLen) return; //ignore if irBuffer is already full irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions

} Sorry for my english thank you

josep112 commented 8 years ago

Hi Annhan, Thanks for the reply, I changed the code but did not work my code is below

include

long rawlen; uint8_t RECV_PIN = 2; //an IR detector/demodulatord is connected to GPIO pin 2

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver }

void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value } delay(100); }

josep112 commented 8 years ago

Sorry I had not seen the link, I could change my raw and went from 254 to 347 will test the air thanks for the help

josep112 commented 8 years ago

Hi Annhan, Not quite understand what you need, you had said that does not speak in English which his country talves can talk in another language

safari2 commented 8 years ago

Hi all.

I've just solved the similar problem. The issue is only with long IR reading. There are good solution with hardware interrupt driving reading: http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/ It works almost out of the box for ESP8266. Just change this code from 0 to your pin number (I used 12 (D4 on nodemcu aka lolin):

   attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
   detachInterrupt(0);//stop interrupts & capture until finshed here
   attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal

So I've successfully got unsigned int rawData [439] for my Panasonic HVAC.
Than you can use irsend.sendRaw() from this library.

helio58 commented 7 years ago

So I've successfully got unsigned int rawData [439] for my Panasonic HVAC. Than you can use irsend.sendRaw() from this library.

Please safari2 where is the irsend.sendRaw() ? and how to send the obtained code? Thanks

safari2 commented 7 years ago

helio58, see link below.

crankyoldgit commented 7 years ago

Closing this issue. Versions of the library later than v2.0 now support larger (256+) capture buffers.