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

LG code port problem #5

Closed direk closed 8 years ago

direk commented 9 years ago

Hi

Library is great, but I have strange problem. I ported LG code send function from here: https://github.com/z3t0/Arduino-IRremote/blob/master/ir_LG.cpp but it is not working. I am sending ir codes to my LG airconditioner from ESP8266. I also have second device based on arduino as ir-receiver for troubleshooting. Both codes, sent from ESP8266 and from oryginal ir remote looks identically in arduino code grabber, but remote is working fine and codes from ESP are being ignored. What am I doing wrong? Maybe I ported code in a wrong way? I just copied function code and declarations...

markszabo commented 9 years ago

Well can you send the code from the Arduino? I think, maybe your LED has a slightly different frequency then the receiver of the airconditioner

direk commented 9 years ago

The same LED and the same code on oryginal arduino board and oryginal IR library works fine. I have no idea what is wrong.

direk commented 9 years ago

One more thing - when I am sending NEC codes to my TV from ESP it works fine, so it looks like code need some tweaks after porting, or aircon is very sensitive for every disruption (length of signal for zeros and ones).

---edit--- I will try one more thing today - as I/O pins on ESP8266 can deliver only 12mA of current, I'll try to power IR LED directly from 3V3 by using transistor. Maybe 12mA is not enough and some devices cannot capture signal from LED...

---edit--- Problem fixed - driving led thru transistor helped. It looks like 12mA directly from IO pin is not enough for my IR LED to be recognized by AC.

It also shows that other protocols can be ported directly by copying corresponding functions :)

chaeplin commented 9 years ago

@direk Thank you for your tip.

gorec2005 commented 9 years ago

Hi! this code work for me: in IRremoteESP8266.cpp ... void IRsend::sendNEC(unsigned long data, int nbits) { enableIROut(38); mark(NEC_HDR_MARK); space(NEC_HDR_SPACE); for (int i = 0; i < nbits; i++) { if (data & TOPBIT) { mark(NEC_BIT_MARK); space(NEC_ONE_SPACE); }. else { mark(NEC_BIT_MARK); space(NEC_ZERO_SPACE); } data <<= 1; } mark(NEC_BIT_MARK); space(0); }

void IRsend::sendLG (unsigned long data, int nbits) { enableIROut(38); mark(LG_HDR_MARK); space(LG_HDR_SPACE); mark(LG_BIT_MARK); for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { if (data & mask) { space(LG_ONE_SPACE); mark(LG_BIT_MARK); } else { space(LG_ZERO_SPACE); mark(LG_BIT_MARK); } } space(0); }

void IRsend::sendWhynter(unsigned long data, int nbits) { ...

and off course in IRremoteESP8266.h

void sendNEC(unsigned long data, int nbits); void sendLG(unsigned long data, int nbits); void sendSony(unsigned long data, int nbits);

markszabo commented 9 years ago

Ok, thanks, I added your function. Next time you may issue a pull request, which would make my work easier and give you proper credits (but I still wrote your name in the commit message).