Martin's corner on the web

Control Daikin air conditioner over the Internet

[Edit] I now offer limited numbers of pre-built units in my shop

Here is a small home-automation project that I have been working in my free time. I wanted to control my home-made air source heat pump system (based on Daikin FTX71GV / RX71GV ) from anywhere with Internet access. That would  allow me to control my house’s heating/cooling remotely and more interestingly I could create scripts that turn the heating up/down based on outside temperature, time of day, inside average temperature and other criteria. All this to make a more efficient energy use, therefore a greener energy plan.

My Daikin uses an ARC433** series remote control, so the analysis was done for that particular IR remote.

I had a NaNode laying around, so the hardware part was pretty much figured out. Just needed an 940nm IR diode, couple resistors, a transistor and I was all set.

Next, I had to decode the IR protocol of Daikin air condifioners. That was quite a challenge as it turned out. To do this I needed to capture the IR signal and reverse-engineer it. Since I have no oscilloscope, I used my sound card as described in this article. I used audacity and  spent few days poking by eyes analyzing the waveform. There are few articles on the Internet that helped me also, but none was about the IR protocol for my specific Daikin model. As it seems, there are at least three protocols used by that manufacturer.

The IR frame is split in two parts 3000us apart. Quite strange approach, I think it it done to confuse universal IR learning devices. In fact I also tried to learn the codes using a SilverCrest universal remote, but it fails due to the gap between transmissions.

So after I had the IR protocol figured out, I had to put up the software. I used Ken Shirriff’s IR library and modified it so that it takes Daikin’s protocol.

For Ethernet connectivity I useJCW’s EtherCard library, of course modifying it a bit because of some limitations it has. Basically the restrictions I needed to avoid are the progmem based DNS lookup and no custom HTTP headers management. Another challenge was to deal with the RAM usage, the library has the TCP buffer taking most of the ATMega’s RAM plus it is a single-packet implementation. That means that a page cannot exceed 1100 bytes (that’s the buffer size).. I finally managed to squeeze in all the UI and was left with 196 bytes of RAM free. Funny when you think of the amount of functionality that 30K of compiled sketch code can hold vs modern software resource usage.

So here is what I came up with as features list:

  • IPv4 only supported; IP, Gateway and DNS configurable via the web UI.
    • The module responds to ICMP (ping)requests
    • Option to reset to default values via a button press during start up (use in case you forget the network settings)
  • HTTP server
    • Web UI, optimized for use via mobile phone by using JQuery;
    • Option for basic HTML UI
    • JavaScript is required on the client in both cases
    • HTTP listen port is configurable
    • Basic HTTP authenticatication can be enabled for password protection of the web UI. Useful to prevent unauthorized access to the module
  • Manual remote control
    • Set On/Off state
    • Set temperature
    • Set mode (heat, cool, dry, auto)
    • Set aux functions (Powerful, Silent, Normal operation)
    • Set fan (1 bar, 3 bars,5 bars, night mode, auto)
  • Schedule timers – 10 user configurable timers via the UI; This is something quite useful because my Daikin doesn’t have scheduler built in.
    • Day(s) to activate Monday-Friday, Weekends,Every day, individual day of week
    • Hour
    • Minute (in 15 min intervals)
  • Time synchronization via NTP (Network Time Protocol; Time is needed if using the schedule. I use NTP because I don’t have a RTC on the NaNode plus seems less hassle to maintain.
    • NTP server configurable (as IP or site)
    • Timezone takes positive and negative values
  • Support for DynDNS dynamic DNS service. This is a bit of feature creep, but wanted to give it a try. So I have a fully functional DynDNS client now 🙂
  • The module can generate JSON state string for external polling via PHP, JavaScript and so forth
    • {“state”:”1″,”mode”:”4″,”temp”:”24″,”fan”:”176″,”aux”:”16″}
  • The module can be controlled with HTTP GET requests. In combination with JSON feedback, you can use the module from your own web scripts

The project turned out too specific – for a particular model of AC. For the future I’d like to take a different approach – learning IR codes rather than decoding and using for a specific model. Learning a code will be simply memorizing the pulse widths and compressing them. AC remote controls send “state” in one command, therefore learning is quite useful. The user may then put a name to the learned code i.e. “heating, temp=21deg, fan=low”. The learned codes will be stored on SD card.

You may browse my code at github. It is quite dirty because I had quite some hard time to deal with the limited RAM after the TCP buffer ate 1100 bytes out of it..

If you find the code useful, you may consider a small donation 😉 [paypal-donation]

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

29 thoughts on “Control Daikin air conditioner over the Internet

  1. MrAnonymous

    What a nice project! I have one question though, did you post the IR protocol that you decoded somewhere? I would love to know a bit more about the decoding process of unknown IR protocols. Keep up the fantastic work!

  2. admin Post author

    Hi, thanks.

    Rather than giving you the protocol, I find it more educational that I give you directions how to find it out based on my experience.

    I spent many hours doing it the hard way i.e. counting the highs and lows of the signal, they are LSB first, then converting these in bytes. Then you find what parts change when you lets say increase temperature by one degree. The byte that changes carries the temperature. Repeat these for each operation you need to decode, for example fan speed, on/off and so forth. The last byte of the frame contains a checksum, so it also changes.

    When I was done, I did some more googling only to find out that this process can be automated.. phew. There is a guy that made a nice IR protocol analyzer
    http://ostan.cz/IR_protocol_analyzer/

    For unknown protocols, you can edit the XML with protocols and it does all the work that I was doing manually for many hours in seconds..

    A one is #432 then _1300
    A zero is #432 then _432

    The startbit is #3500 _1700
    The stopbit is #432

    With this information, you will be able to determine the protocol yourself in less than hour.

    1. Pedro

      Hello, my name is Pedro, I want to tell you that your idea is very usefull and interesting. I’m studying the Daikin protocol but I would like to ask you some question in relation with it. When you studied the protocol , did you get the checksum? or you only sent the same bytes depending the parameters you want to select. If you got this checksum, for me it will be very usefull to know how you got it for my project. So I hope you can help me in this issue. thank you very much.

      1. admin Post author

        This is the code I use:

        uint8_t airController_checksum()
        {
        uint8_t sum = 0;
        uint8_t i;

        for(i = 0; i <= 6; i++){ sum += daikin[i]; } daikin[7] = sum &0xFF; sum=0; for(i = 8; i <= 25; i++){ sum += daikin[i]; } daikin[26] = sum &0xFF; }

        1. Pedro

          Ok, thank you very much, you divide in two parts to calculate checksum. If you let me, i would like to ask you another question, have you analized anytime the Daikin protocol between Indoor unit and remote controller? I have analizing this kind of dates but for me is very difficult to find the checksum, I thank for you if you can help me.

  3. Pedro

    Ok, thank you very much, you divide in two parts to calculate checksum. If you let me, i would like to ask you another question, have you analized anytime the Daikin protocol between Indoor unit and remote controller? I have analizing this kind of dates but for me is very difficult to find the checksum, I thank for you if you can help me.

  4. Pingback: What is this all about? | Martin's corner on the web

  5. Stephen

    Hi,

    What a fantasic project. I’ve been looking for something like this to run on Arduino for a long time. Except I can’t get it to run. All I get on the serial monitor is “[Configuration]”. Then it appears to hang. I expect that it might be to do with the Ethernet library. Am I correct in saying that it is not compatible with the Wiznet chip? If so have you thought of modifying your code to suit the Wiznet Ethernet chip?

    Many thanks.

    1. admin Post author

      Hello,
      Yes, this code has been meant to run on the ENC28J60 based NaNode (see nanode.eu)
      I’m pretty happy how it has been working for me for the last year, I have no intention to move it to Wiznet at this point. Actually I wanted to sell pre-build such modules to end users, but never got to finalize that idea.

      1. Stephen

        Thanks. I might have to get a Nanode to try it out then. Can you tell me if the LED on pin 6 is the IR LED or is that just a status LED? Likewise, what does teh switch on pin 5 do?

        1. admin Post author

          IR led is connected to Pin 3, pin 6 is the built-in led of the Nanode, used for feedback.
          The button is to reset to default configuration (if held during start-up), or to manually send the last defined IR command (I used that for testing). Useful when you set the module to some odd IP address and then can’t find it 🙂

  6. chris

    Hi, beautiful project. I got here because I would like to start with Arduino and I was thinking to do a simple scheduler for my Daikin AC as my very first project. But the IR part seems to be the most difficult! Could you please give me a hint on how to proceed with the “state” approach you mention at the end? The sounds more feasible for my non-existent skill level.

    Cheers

  7. Stephen

    Hi Martin,

    Do I need to have an SD card on my Nanode to make this work? I’ve got a Nanode gateway which doesn’t have a SD slot. The sketch seems to hang when initialising.

    1. Martin Harizanov Post author

      Hi,
      No SD card is needed; I am running this on NanoDe v5 (the old red ones), these are now discontinued. Make sure you have the libraries set and use Arduino IDE 0021, the libraries are heavily modified and the default ones won’t work;

      1. Stephen

        Hi Martin

        Thanks for the reply. I’ve tried using IDE 0021. I’ve added your libraries from Github. The serial output gets stuck on “[Configuration]”. Maybe I’m doing something wrong or maybe one of the libraries is not compatible with the newer Nanodes. Any suggestions?

        1. Stephen

          I’ve figured out that it is hanging when starting the ethernet library, i.e., it doesn’t get passed the “ether.begin”, line. However I’m not sure what to do given the non-standard libraries. any suggestions on how I might trouble shoot it?

          1. Martin Post author

            I suggest to check if the Nanode v5 that I used in this project has a different ENC28J60 CS pin from the newer ones; if that is the case, it would be a 30 seconds effort to resolve it; otherwise you’d need to dig in further on why it fails to initialize

          2. Stephen

            Hi Martin

            I’ve finally worked out a solution to this problem. I modified your irremote and time libraries to work with IDE 1.x. This enabled me to use the latest Ethercard library. Which meant that I got the code to compile and run. So I was very happy. There are a couple of features that don’t work however. I couldn’t get the http options page to work. This was OK for me I went with hard coded values. Also the DNS resolution doesn’t work. I assume this to be due to some custom code in your Ethercard library. So this meant I had to use an IP address for the NTP server instead of a DNS name. Likewise the DDNS client didn’t work. However this was surplus to my requirements so I stripped it out. However all of the core features work. So I’m very happy. Thanks for all of your efforts.

  8. Stephen

    Hi Martin

    I’ve confirmed that digital pin 8 is still used by the ENC28J60 in the Nanode Gateway. I’ve tried running the sample DHCP sketch with your library and it hangs at the same point. So there is obviously some level of incompatibility. I might try and get a Nanode V5 and see if that works.

  9. Joaquín

    Hi Martin,
    Seems very interesting your project, but it is very complex to me.
    At the moment I simply want turn on or off Daikin AC separately by two buttons.
    I need to generate the turn ON sequence when I press a button.

    To turn on I have tried sending
    airController_on ();
    airController_setTemp (22);
    airController_setFan (160);
    airController_setMode (3);
    airController_checksum ();
    irsend.sendDaikin (daikin, 8.0);
    delay (29);
    irsend.sendDaikin (daikin, 19.8);

    But it does not work. Can you help me?
    Thank you very much.
    Joaquin

    1. Joaquín

      I’ve solved the problem.
      The problem is that the infrared LED emits underpowered. TSAL7400 in serial with 100 ohm resistor.
      If I connect it directly to the arduino output AC detects it to 3 meters, but if I put the resistance does not exceed 1m.
      The scope of the original remote ARC433 is over 5m.
      Thanks
      Joaquín

      1. Martin Post author

        Glad you have it working. I use a transistor to drive the IR Led in my setup, anyway range isn’t as much as the original remote.

  10. Pingback: Re-vamping my Daikin Internet Air-conditioner controller | Martin's corner on the web

  11. Pingback: IR Daikin: decodificare protocolli infrarossi complessi. | McMajan

  12. Pingback: Daikin Klimaanlage über Baustein "IR-Steuerung" bedienen