Saturday, March 2, 2013

LIRC RasPi remote control configuration for GE Air Conditioner

I set up lirc_rpi so that I can use my RaspberryPi as an infrared remote control. As detailed nicely here, the process has been much simplified, at least if you're on Raspbian. Note, as I commented there, you'll probably want to add --listen to your LIRC_ARGS in hardware.conf so that you can connect to the LIRC daemon from your home network. This allows you to send IR remote control signals out from the RasPi by connecting from any computer. There's also a nice Android app called Amote, probably there are good ones for iOS as well.

I found that our Samsung BN59-00857A remote worked fine with an existing lircd.conf configuration file for the BN59-00856A. (Actually the 00856 includes a few additional buttons not on the 00857; several of these work for controlling our TV even though they're not on our OEM remote!)

When it came to controlling our GE air conditioner, I didn't find any existing configuration file. The process of getting a working config file together was a little more involved than I expected, so I'm detailing it here and posting the resulting config (also sent it to the LIRC maintainers, but didn't hear anything back).

I knew from running mode2 that raw signals from the AC remote were being received correctly. But I wasn't able to get irrecord to pick up the AC remote signals even when forcing it into raw mode. It turns out that the GE AC remote has an unusually long code length, 48 bits, so maybe that was part of the issue. I'm also not clear on whether my irrecord was going into raw mode correctly; seemed to behave exactly like non-raw mode so maybe there's a problem with the version built for Raspbian?

Anyway, to get a config file, I had to pipe the mode2 raw data to text files and then manually pull the text into a raw conf file and filter out the "pulse" and "space" text (thanks vim). I confirmed that the resulting raw file works for controlling the AC through LIRC. Then I used irrecord -a to retroactively convert the raw codes into a more succinct config file. Looking at the various wall mount ACs GE sells, it seems likely to me that these codes will work for any unit since the controls all look the same. (If you have a heat+cool unit then you'll be missing the "heat" button since my AC doesn't have that.)

Hope it's useful. If you want the raw version of the conf file for some reason, just ping me for it.

# this config file was automatically generated
# using lirc-0.9.0-pre1(emulation) on Sat Mar  2 14:09:22 2013
# contributed by Peter Li
# brand: GE
# model no. of remote control: 
# devices being controlled by this remote: All the GE wall mount air 
# conditioners look like they have very similar controls, so I would guess this 
# will work for all.  It will probably also work for the Heat/Cool wall models,
# other than the missing heat button, but I haven't tried that.

begin remote

    name  GE_AirConditioner
    bits           48
    flags SPACE_ENC
    eps            30
    aeps          100
    header       3388  1678
    one           430  1257
    zero          430   412
    ptrail        428
    gap          40991
    toggle_bit_mask 0x0
    begin codes
        on_stop                  0x555AF308598F
        cool                     0x555AF3081D8F
        fan                      0x555AF3085D8B
        tempup                   0x555AF308D987
        tempdown                 0x555AF308198B
        timeron                  0x555AF308D58B
        timeroff                 0x555AF308958F
        hi                       0x555AF308DD83
        mid                      0x555AF3083D8D
        low                      0x555AF308BD85
        sleep                    0x555AF3085583
    end codes
end remote


  1. Hi Peter
    I'm trying to do the same thing, but can't get the raw mode config file to be recognised. Could you post yours?
    Also, you could have used the -m switch in mode2 to save yourself having to get rid of the "pulse" and "space" bits...

  2. Hey Nick, out of curiosity, what device are you working with? Thanks for the mode2 tip; that gives much more nicely formatted output!

    Here's the head and first command of my raw mode file. I don't remember how I set the header fields; I think just copied from a failed attempt to use irrecord in raw mode, but maybe something else. Note the timing values don't have to be formatted any particular way. After I had a couple commands working with this 6-column format I just dropped to one value per line. Also note that you of course need to drop the first "space" value which is just the time between the start of mode2 and you hitting the button :).

    begin remote
    name geac
    flags RAW_CODES
    eps 30
    aeps 100

    ptrail 0
    repeat 0 0
    gap 40991

    begin raw_codes

    name on_stop
    3408 1657 435 404 437 1248
    465 381 467 1220 431 411
    460 1229 466 376 436 1252
    461 390 434 1246 459 385
    437 1251 433 1253 441 403
    460 1226 439 407 465 1225
    430 1256 458 1229 467 1216
    466 383 439 403 439 1248
    437 1251 434 409 462 383
    439 402 458 388 457 1230
    435 408 464 380 462 382
    461 383 466 1222 439 402
    437 1252 431 1257 438 406
    466 378 434 1252 431 1264
    432 405 436 407 466 378
    464 1223 461 1227 468 1217
    437 1253 430
    end remote

    1. Of course, this dropped initial whitespace; in my file things are indented nicely but I don't think this matters. I hand cut the other commands and pasted here without testing, so it's possible you need a blank line at the end of each command.

  3. Hi Peter

    I'm currently waiting on a new IR receiver because i think my current one is on the blink. Anyway, i'm trying to control a Daikin Heat Pump. I believe the remote works by sending the entire "state" in one bang i.e. it sends the temperature, the heating mode , wheather its on or off etc in one go. Hence it needs "raw mode". My plan is to use the Raspi pi to control all our appliances (as present its quite hard on my wife to switch to Rapbmc, select the correct input on the amp, and select the tv or projector....).

    In terms of the raw file. I still can't read it properly. I using the latest raspbian, but if i have more then 5 timing values, it won't load in the file.... grrrr.

    I will wait until i get a new sensor, as at the moment i getting really noisy and inconsistent values. Ps I can't seem to get it to force to do raw data either...

  4. Hi.... im having trouble with generating lirc configuration file It keeps said "Something Went Wrong", im using WinLIRC 0.9.0f, AudioCapture Plugin... I Checked my hardware using IRGraph and RawCodes, its working...

    I tried to use template , but its not helping and said the same thing "Something Went Wrong" Could You help me? :D

    i tried to force in raw mode with -f option, it works, it records the raw codes. but when i analyze it with -a, decode failed...

    somebody can help??

    1. Hi, I don't have experience with WinLIRC and "Something Went Wrong" isn't an error I've seen come up with the Linux LIRC utilities. Do you have CygWin installed? Maybe you could try running standard LIRC through CygWin? Otherwise I would try asking in a LIRC or WinLIRC specific forum. I have some windows machines but I don't have IR hardware for them, so I can't really help you debug.

  5. Hi, I'm working with a sanyo heat pump and have similar issues with irrecord. However, when I input the data from mode2 to a file, with a single off command I get couple of hundred of lines. How can you interpret it?


  6. Hi Eippi, are you sure you're sending only a single off command? With some controllers if you hold down the button it just keeps sending and sending...

    I would check the output from several attempts at sending a single off and see if it's consistent. Should be the same length and look the same other than the initial space of time before you hit the button.

    If that all looks consistent, then maybe your command really is just a lot of pulses. In that case, you want to hand write a raw code version, similar to my comment in reply to Nick above. In that example, there's only one command with the mode2 output timings pasted under it. You might want to do this too; start with a file for just the one command and test that before spending time trying to record the other commands.

    Once you have a hand pasted raw code version, you run irrecord -a on that file to ask it to calculate the more condensed version.

    1. Of course, you should try the normal record and raw mode record options first, but in my experience they often don't work.

  7. hi there! did anyone find a way to handle long codes? its a thing with most A/C remotes. Thats the problem, lirc tells me that the code is too long. did any of you manage to find the solution to this problem? thanks!

  8. I imagine if you try the raw code approach discussed here it will handle long codes okay.

  9. hi there , i am trying to use irrecord to create a configure file for my LG a/c using row mode , when i reach the step
    " Press RETURN now to start recording." it generate only 1-3 or 4 dots then nothing appear ,after that i stop pressing buttons there is a new message says
    "irrecord: no data for 10 secs, aborting
    irrecord: gap not found, can't continue"
    when i use mode2 there are many spaces and pulses genereted !
    any help please

  10. Hi Ahmed, it sounds similar to the situation described above. You might try a few more times the traditional way but if you keep getting only a few dots you should try the raw method.

    In brief, record your codes using mode2 -m, pipe those to a separate file for each code, then paste them into a template like in my comment above that has the "begin raw_codes" line. I don't remember where I got the template from, but try an existing file or else try the failed output from your 3-4 dots irrecord attempt.

    Try pasting just one code in and loading LIRC with that and testing it. If it works, you can go ahead and keep adding the rest of the buttons. Test all of them using the raw_codes config, then if you want a nicer file you can run irrecord -a to retroactively convert the raw codes to something nicer.

    1. Also, as noted above, you probably want to drop the very first number in the file you piped from mode2 -m; that first number is just the time between when you started recording and when you hit the button. It might help to look at the output a bit from mode2 without the -m option to get a feel for what a code should look like first.

    2. thank you Peter ,, sorry my English is not good enough.
      I have tried your solution and it works fine , to make it easy for me I used a config file of raw data without buttons then i used -d irrecord "/path/of/that/config.file" then started recording my buttons after that I used -a -d irrecord.
      I tried with two remotes one give this code and successfully converted with -a :

      6073 7411 525 1662 530 1715
      473 1689 518 1671 526 1696
      457 1725 517 1672 525 1717
      473 658 476 607 533 599
      523 609 519 641 488 645
      473 652 477 637 500 1714
      475 1693 514 1696 500 1714
      474 1689 521 1694 501 1714
      476 1688 521 638 485 622
      501 657 475 606 525 604
      527 607 528 659 467 587

      the other remote gives to long code that wont be converted !
      i try a small touch ,but can't get smaller than this

      6036 7418 512 1679 535 1681
      511 1674 520 1669 529 1687
      495 1694 552 1634 538 1679
      465 715 448 584 549 609
      525 581 551 608 517 615
      510 633 484 637 515 1673
      569 1621 531 1683 511 1679
      514 1673 540 1673 469 1726
      505 1678 583 561 517 608
      515 588 542 616 463 709
      426 669 464 654 507 615
      530 1682 499 1690 526 1659
      502 1712 465 1725 535 1653
      493 1722 468 1721 532 600
      558 574 506 626 496 636
      466 644 487 644 489 642
      521 614 515 1671 488 1727
      510 1677 580 556 517 1666
      526 582 549 645 454 1696
      558 590 536 624 482 643
      487 1669 523 623 505 1696
      466 1722 520 612 582 555
      459 1724 518 1643 566 653
      461 1696 463 641 539 1673
      513 1676 528 1698 455 661
      502 619 481 1726 463 623
      555 1678 516 599 481 634
      498 650 485 1723 512 636
      453 1719 547 588 539 1648
      521 608 523 610 520 1668
      523 661 470 1694 465 646
      556 1651 513 621 465 1724
      539 1648 495 7443 498

    3. Your English seems good enough to me! So I tried plotting the numbers from your longer sequence to see if there's a repeated pattern (I think the timings can be off by a small amount so just looking at the raw numbers is not too helpful). I don't see a repeated pattern, so maybe the code really is that long.

      If you just leave your config file in raw_codes format, does it work to control the device? Converting with -a is just a cosmetic improvement as far as I'm aware.

  11. I don't know if it works when leaving it in a raw code.Because I borrow the remote from my friend. I assume that the raw code is the base of all remote protocol. Actually I am working on a project that allows me to record any new remote in a raw mode then convert it using -a . I am not sure if my assumption is correct . so what do you think about it ?!

  12. That sounds useful. I'm not sure how much header information needs to be in the template that you paste the raw_codes into. Perhaps the raw_codes are fully specified such that the header is really unnecessary, but I had the impression some of that header info stuff (eps, aeps, ptrail, etc.) might still need to be set approximately correctly. Unfortunately I don't remember what any of that stuff really does/means.

    I could imagine that the condensed format coming out of -a is not powerful enough to describe every possible raw_code, so there might be some raw_codes that just don't work with -a.

    I would definitely test your raw_codes with the device the remote is supposed to control to confirm that the device responds to the raw_codes. If not, then there's a problem with the raw_codes recorded and you shouldn't go on to the next steps yet.

    Also, looking back at the plots of your long raw code, there are some pretty big gaps in there, so it definitely looks a little weird to me. Try putting it into Google Docs or Octave as 1 column and looking at a plot.

  13. thank you Peter for your respond .
    There is something weird to me . when i pressed a button on that remote while running irrecord. the signal length was 197 but i read in irrecord.c that the max signal is 48 bit (that equal signal length 192) !
    then when using -a a message says "Unknown encoding found" !

  14. There is some issue on some RPI when using LIRC.
    The pulse measured is 15% bigger than reallity.
    read this for détails :

    In short, dont' forget to update, this help a lot to make it work !
    Update as follows:
    $ sudo apt-get update
    $ sudo rpi-update

    Check the software version on the Pi:
    $ uname -rv

  15. Hi Peter,

    Thanks to your tutorial I was able to send raw IR-signals to my Samsung AC unit. Every button I add to my lircd.conf file works perfectly and with irsend SEND_ONCE SAMSUNG "button name" I can send it to the AC. Except for ONE button! The "off" button. I did everything exactly the same as I did with the other buttons. Receiving the code, converting it to understandable line for the lircd.conf file. But whenever I add the off button to the lircd.conf file I get this error:

    irsend: command failed: SEND_ONCE SAMSUNG MODEAUTO
    irsend: unknown remote: "SAMSUNG"

    no matter what button I try to send with irsend I get this error. Even the buttons that worked before I put in the "off" button.
    Can you please help? If you're still active and seeing this message that is...



  16. It's hard for me to tell what the issue is, but it sounds like there is a syntax error in the code for the off button that is breaking your whole conf when you paste it in. If not a syntax error, then perhaps the code has a character that the conf parser is not able to handle. Can you post a version of your conf that works with just the on button, and then a version that doesn't work with on and off?

    1. Hi Peter,

      Sorry for the late response. I uploaded the lircd.conf files to my drive. One working, the other with the OFF button that's not working. This one is just the same as the one working but with OFF added... If I do so, none of my previous buttons works anymore and I get that error.

      Here's the link:

  17. Hmm, so I don't see anything clearly wrong. Obviously, the OFF code seems to be significantly longer than the others. Ahmed above also had trouble getting longer codes to convert from RAW to a more compact format, but I don't think he had the issue that one code was messing up the whole conf file.

    I don't have a clear idea what to do. A few hacks you could try:
    * Name it STOP instead of OFF, in case this is a protected word
    * Retry recording the button
    * Try parsing all the other codes into compact format using -a. If that works, copy some of the header settings in the compact version to try to help LIRC understand the long OFF RAW code

    If I get a chance, I'll try messing with your conf files. I don't have LIRC set up at the moment (just moved house).

  18. This comment has been removed by the author.

    1. 1. Renaming it to another name didn't work
      2. I already tried rerecording the OFF button... didn't work. So I tried it again... didn't work! :p
      3. irrecord -a dind't work either, it fails everytime for every raw code I try.
      4. I even have a knx module (zennio IRSC) that can send IR-signals to my AC, and this works perfect. Even the OFF button. So I recorded the signals of this module too because they look different. Guess what? The exact same problem occurs. Everything works, except when I try the OFF button.
      5. You said the OFF code seems longer, I thought that was odd, because I put every raw code in excel to try and understand them but every button was the same length. So I looked again, and I learned that using vim shortened my raw code. So I did it again (right this time) for every button and now they all have the same length as the OFF button you saw. But guess what? Still the same weird problem... This OFF button somehow messes with the conf file so lirc doesn't work anymore I guess... But I have no clue how to get this code to work.

    2. I also put the excel file I made in my drive. You should be able to access it through the same link. Maybe this helps, I don't know, but I'm really grateful that you're willing to help me!

  19. Hi Peter and Wout,

    I am not sure if that may help or not . Regarding the long cods, I solved my problem by increasing the signal length to 200 instead of 192 in irrecord.c file then I rebuild the source through the make file.

    1. Hi Ahmed,

      I can't seem to find the irrecord.c file you speak of. Can you tell me where to find it?

  20. I have a RasPi set up again, so I'll try to play a bit with source patches.

  21. Hi Peter
    If you have found a solution for Samsung AC please share your lircd.conf, I am also woring to find a solution If I do find it I will send you a link and what I did to make it work.
    Cheers and good luck

  22. Just solved the problem, working fine here for the OFF for the Samsung AC

    1. Hi Yovan! That sounds amazing! I'm still struggling to get it to work. Can you send the lircd.conf file? And tell us how you did it? Thanks in advance!

    2. Hi Yovan

      This is just a friendly reminder in the hope you get a notification and see this message... I hope you'll post your solution to the "OFF" button soon.

  23. Hi Peter. I've tried your method on LG AC. Work great with tricky angle. Now, i try your method using Panasonic AC, I dont know why it's not works now. Any suggestion?

  24. HI,

    I have the same problem with the Samsung AC! The OFF button gives error! Can you post the lircd.conf and tell us how did you fix the OFF button?

    Thank you

  25. This comment has been removed by a blog administrator.

  26. Hi all, I finally played around with this a bit. I'm not able to get irrecord -a to convert any of the raw codes Wout posted. However, I am able to get it to handle the STOP raw_code at least a little better just by reducing the amount of whitespace. I posted the file to the GDrive folder Wout linked above and I'll paste it below; see if it works for you. Ideally we would get the raw codes converted to concise codes, but none of the versions of irrecord -a I tried seem to handle this. I may poke into it more, but don't have much spare time. Hopefully at least the new raw STOP will work for you.

    I will note I had trouble tracking down the logging of the latest Git pull of lirc (0.9.4) on Fedora; didn't seem to show up in /var/log or journalctl; if anyone knows where to look let me know. I ended up just hacking the logprintf function to spit to the console and then ran irrecord with --loglevel 10 which made things a bit clearer.

    1. # Please make this file available to others
      # by sending it to
      # this config file was automatically generated
      # using lirc-0.9.0-pre1(default) on Fri Mar 27 13:01:21 2015
      # contributed by
      # brand: SAMSUNG
      # model no. of remote control: MR-DH00
      # devices being controlled by this remote: A/C-unit

      begin remote

      name SAMSUNG
      flags RAW_CODES
      eps 30
      aeps 100

      ptrail 0
      repeat 0 0
      gap 40991

      begin raw_codes

      name STOP
      637 17812 3005 8899 551 442 554 1440 545 434 554 440 555 442 551 438 558 438 553 442 554 465 525 1458 468 522 547 451 548 1433 556 1428 564 433 561 1421 561 1426 562 1433 556 1429 555 1427 557 445 550 464 529 466 471 519 475 517 550 443 557 439 593 398 552 439 559 434 559 438 556 434 556 439 557 440 555 434 557 440 553 438 586 412 552 439 552 463 533 459 476 518 518 478 543 449 566 424 557 438 555 439 557 435 559 436 556 435 557 438 555 434 559 441 555 454 540 1429 556 1455 552 2904 3067 8886 486 1498 540 452 553 443 577 413 582 412 556 434 558 437 557 434 558 438 554 1438 569 421 558 437 552 1434 552 443 552 1451 471 1534 533 1441 550 1432 556 1425 559 1433 556 438 557 436 555 438 588 409 554 444 572 414 553 442 552 465 529 467 524 465 470 524 544 448 552 442 587 405 553 439 560 434 560 435 558 438 551 439 557 438 551 440 556 440 553 437 556 443 552 464 526 465 530 465 526 464 476 520 522 473 554 433 555 440 552 437 563 438 550 434 563 433 563 2935 3026 8895 543 1441 545 442 583 413 550 443 555 466 526 465 529 462 473 523 518 472 543 1444 557 435 555 439 556 438 555 1435 553 1431 552 1434 554 438 558 1435 551 1441 566 1434 473 1520 609 1376 548 1438 546 1434 560 1434 551 439 550 439 559 454 534 1433 550 1445 543 1451 538 462 535 463 470 524 471 518 544 448 557 1436 552 435 560 1436 547 438 560 1425 551 435 554 1442 552 1440 547 465 531 461 561 428 532 470 465 519 549 453 541 445 553 440 558 437 558 432 629 1368 551 1434 552

      end raw_codes

      end remote

    2. Hi Peter! Cool! Your "STOP" code is working perfect for me on Samsung Triangle Good AR5000 AC. Many thanks!

  27. Hello sir how can i implement multiple remote in single lirc.conf file?

    1. You probably already figured this out, but as I came to this thread looking for an answer to your same question, I'll post what I did to make it work. I had a remote for my AC unit working in the lira.conf file (using -f raw codes, I've not tried to mess with nice-ifying them as they seem to work as-is), and I wanted to also control an LED IR lightbulb. I used irrecord to make a separate .conf file for the lightbulb, then after trying for a bit to figure out how to define multiple remote configuration files, I just appended the new one after the "end remote" line at the end of the existing one.

    2. Forgot to post the bit that was tripping me up in the first place... Once you edit the lirc.conf file you have to restart lirc:
      sudo /etc/init.d/lirc stop
      sudo /etc/init.d/lirc start
      Otherwise it does not see the changes.

      Once that is done you just specify the remote name in the irsend command as it appears in the lirc.conf file. I.e:
      irsend send_once the_name_of_remote KEY_POWER

      Also useful is this command which lists all the buttons defined for a given remote:
      irsend LIST the_name_of_remote ""

      If you find this to be basic/obvious info, know that I'm not trying to patronize, just speaking from a relatively deep well of ignorance myself :)

  28. i also tried lirc i am getting raw codes and they work if i am sending command by irsend but i want to use that in a c code so how can i send signal through my c code

    1. I'm not that familiar with the codebase, but you can probably find a way to do this directly via the project lib:

      Otherwise, your C program can make a linux system call to irsend.

    2. I'm not that familiar with the codebase, but you can probably find a way to do this directly via the project lib:

      Otherwise, your C program can make a linux system call to irsend.

  29. is there any way to restart the lirc service without restart the PI?

    1. I believe that the commands "sudo /etc/init.d/lirc stop" and "sudo /etc/init.d/lirc start" will restart lirc

  30. I am able to switch OFF my ac but switch ON is not working.. I generated raw codes by mode2 to fill my conf file.. any clues ?

    1. You'll see above that other people had issues with some long codes. You could try removing as much whitespace as possible as that seemed to fix the issue for OFF code on Samsung ACs.