loading
Arduino really allows you to do many things concerning the Internet of things, just have a little 'desire and intuition to create any type of project.
In this post we will see how to remote control your air conditioner at home, through the Arduino, which is connected to the Internet. Yes, you just read that right!

Requirements hardware

• 1 x Arduino Uno + 1 x or 2 x Arduino Mega Arduino Uno
• IR receiver TSOP1738
• IR LED
• 1 x 330 Ohm resistor
• Some flexible cable

Requirements software

Library iRemote Arduino
Programs available in my Github repo


Step 1: How Does the System Work ?

As many will know , the mechanism of regulation of various settings between user and conditioner , is via a remote control , which is based on sending infrared signals . To investigate the function of these signals , I recommend you look at the post in reference to Chapter 10 of the Arduino design becomes simple (in Italian).
Obviously , the code of an air conditioner , vary depending on the model and according to the manufacturer. For this reason, as the first phase of the work , you must do the procedure that is called reverse engineering , that is to obtain the codes for your device , using the sensor TSOP1738 .
Once you have obtained the codes for your air conditioner, we're almost to complete "the work ." You need to use a small program that simplifies setting the code to insert into the Arduino , and you can send the various encodings . These codes can be set by the user through a simple web page , with or without protection.
As you have read in the " Hardware requirements " , I wrote that you need two Arduino , the main reason is that the sequences of bits to be sent to the air conditioners are too large to be contained in a single device , which among other things should also take care of the part of management commands that will be transmitted via the Internet.
In practice there will be a device that will take care of the part webserver and the other to send IR signals . The other reason that prompted me to do this project with two device , is that you can safely use Raspberry PI for the management of the webserver , so definitely improve the look and feel of the web page.

Step 2: How to Set Up the Various Data

As stated in the previous rows, you must obtain encodings of our remote control to retransmit them to the Arduino. To do this we will make use of the library for Arduino iRemote, in particular this code:

/* Modified by Chris Targett
* Now includes more protocols
* Novemeber 2011

* IRremote: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*
* Modified by Chris Targett to speed up the process of collecting
* IR (HEX and DEC) codes from a remote (to put into and .h file)
*
*/

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

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

// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
//  decode_results *results = (decode_results *)v
void dump(decode_results *results) {
  int count = results->rawlen;
  if (results->decode_type == UNKNOWN) {
    Serial.print("Unknown encoding: ");
  }
    else if (results->decode_type == NEC) {
    Serial.print("Decoded NEC: ");
  }
  else if (results->decode_type == SONY) {
    Serial.print("Decoded SONY: ");
  }
  else if (results->decode_type == RC5) {
    Serial.print("Decoded RC5: ");
  }
  else if (results->decode_type == RC6) {
    Serial.print("Decoded RC6: ");
  }
  else if (results->decode_type == SAMSUNG) {
    Serial.print("Decoded SAMSUNG: ");
  }
  else if (results->decode_type == JVC) {
    Serial.print("Decoded JVC: ");
  }
  else if (results->decode_type == PANASONIC) {
    Serial.print("Decoded Panasonic: ");
  }
  Serial.print(results->value, HEX);
  Serial.print("(");
  Serial.print(results->bits, DEC);
  Serial.println(" bits)");
  Serial.print("#define Something_DEC ");
  Serial.println(results->value, DEC);
  Serial.print("#define Something_HEX ");
  Serial.println(results->value, HEX);
  Serial.print("Raw (");
  Serial.print(count, DEC);
  Serial.print("): ");
  for (int i = 0; i < count; i++) {
    if ((i % 2) == 1) {
      Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
    }
    else {
      Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
    }
    Serial.print(" ");
  }
  Serial.println("");
}

void loop() {
  if (irrecv.decode(&results)) {
    dump(&results);
    irrecv.resume(); // Receive the next value
  }
}

You can see in the picture how to link Arduino with the device.

After loading the code on the Arduino, we should press the buttons on the remote control and copy somewhere the results shown by the serial.
In my case, I got the following sequence of encodings:

Accensione 20 C° Caldo
Raw (150): -5320 3000 -3000 3000 -4400 550 -1600 600 -550 550 -1650 550 -550 550 -550 550 -1650 550 -550 550 -1650 500 -550 550 -1650 550 -550 550 -500 600 -500 600 -550 550 -550 550 -1650 500 -550 550 -600 500 -1700 500 -550 550 -550 550 -550 550 -600 500 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -1650 500 -1650 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -500 550 -550 550 -1700 500 -1650 550 -550 550 -500 600 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 500 -1700 500 -550 550 -550 550 -550 550 -550 550 -550 550 -600 500 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -500 550 -1700 500 -550 550 -550 550 -550 550 -1650 550

Spegnimento
Raw (150): -3276 3100 -2900 2950 -4400 700 -1500 700 -400 700 -1500 700 -400 650 -450 550 -1650 550 -550 650 -1500 600 -500 600 -1600 600 -500 600 -500 600 -450 650 -450 600 -550 550 -550 550 -550 550 -600 500 -1600 600 -500 600 -500 600 -550 550 -500 600 -500 600 -550 550 -550 550 -1600 600 -500 600 -500 600 -500 550 -1650 550 -1600 600 -500 600 -500 600 -550 550 -550 550 -1600 600 -1600 550 -550 550 -550 550 -1650 550 -1600 600 -550 550 -500 600 -500 600 -550 550 -550 550 -500 600 -500 600 -1600 600 -1600 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -500 600 -550 550 -550 550 -500 600 -500 600 -500 600 -1600 600 -500 600 -1600 550 -550 550 -1600 600 -550 550 -550 550

Accensione 23 C° Freddo 2 FAN
Raw (150): -16044 3050 -3000 3000 -4400 550 -1600 600 -550 550 -1650 550 -550 550 -550 550 -1650 550 -500 600 -1600 550 -550 550 -1650 550 -1650 550 -1650 550 -550 550 -550 550 -500 600 -1600 550 -550 550 -550 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -500 600 -1650 500 -550 550 -600 500 -1700 500 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -550 550 -500 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -500 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1600 600 -550 550

Accensione 20 C° Caldo e Swing
Raw (150): 18566 3000 -3000 3000 -4400 550 -1650 550 -500 600 -1600 600 -500 600 -500 600 -1600 550 -550 550 -1650 550 -500 600 -1600 600 -550 550 -550 550 -550 550 -1600 600 -500 600 -500 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -550 550 -1600 550 -550 550 -600 500 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -550 550 -550 550 -1600 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -550 550 -550 550 -550 550 -550 500 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -1650 500 -1650 550 -550 550 -1700 500

Accensione 23 C° Freddo 2 FAN e Swing
Raw (150): 2084 2950 -3050 2950 -4400 550 -1600 600 -550 550 -1650 550 -550 550 -550 550 -1600 600 -500 600 -1600 550 -500 600 -1650 550 -1650 550 -1600 600 -500 600 -1600 600 -500 600 -500 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -500 600 -550 550 -500 600 -1650 550 -550 550 -1600 600 -500 600 -1600 550 -1600 600 -500 600 -500 600 -550 550 -500 600 -1650 550 -1600 600 -500 600 -500 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -500 600 -500 600 -500 600 -500 600 -500 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -1600 600 -1600 550 -550 600 -500 550 -550 550 -550 550

As reported in the library iRemote, in order to retransmit these data, it is necessary to make some changes, in particular, need to replace the hyphens, delete the first value and place among the various values​​, a comma, as in the Arduino code will be inserted in a vector of integers.
To facilitate this, I created a small program in Java that can do these tasks automatically.
Also this program is available in the Github repo and is called AcToolArduino. In this first version, the program automates the process by entering the information in the TextField. In the next version, you can load from file, the results obtained from the serial Arduino.

Step 3: Sending IR Command to A/C

With the following code, you will be able to send IR command to A/C via Arduino:

#include "IRremote.h"

IRsend irsend;

void setup()
{
  Serial.begin(9600);
}

int khz=38; //NB Change this default value as neccessary to the correct modulation frequency
// ON and 2O C° with 1 FAN heat
unsigned heat[] = {3000,3000,3000,4400,550,1600,600,550,550,1650,550,550,550,550,550,1650,550,550,550,1650,500,550,550,1650,550,550,550,500,600,500,600,550,550,550,550,1650,500,550,550,600,500,1700,500,550,550,550,550,550,550,600,500,550,550,550,550,550,550,550,550,1650,550,1650,550,1650,500,1650,550,1650,550,550,550,550,550,550,550,550,550,1650,550,1650,550,500,550,550,550,1700,500,1650,550,550,550,500,600,550,550,550,550,550,550,550,550,550,550,1650,500,1700,500,550,550,550,550,550,550,550,550,550,550,600,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,500,550,1700,500,550,550,550,550,550,550,1650,550};
// OFF the A/C
unsigned OFF[] = {3100,2900,2950,4400,700,1500,700,400,700,1500,700,400,650,450,550,1650,550,550,650,1500,600,500,600,1600,600,500,600,500,600,450,650,450,600,550,550,550,550,550,550,600,500,1600,600,500,600,500,600,550,550,500,600,500,600,550,550,550,550,1600,600,500,600,500,600,500,550,1650,550,1600,600,500,600,500,600,550,550,550,550,1600,600,1600,550,550,550,550,550,1650,550,1600,600,550,550,500,600,500,600,550,550,550,550,500,600,500,600,1600,600,1600,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,500,600,550,550,550,550,500,600,500,600,500,600,1600,600,500,600,1600,550,550,550,1600,600,550,550,550,550};
// ON and 23° with 2 FAN cold
unsigned cold[] = {3050,3000,3000,4400,550,1600,600,550,550,1650,550,550,550,550,550,1650,550,500,600,1600,550,550,550,1650,550,1650,550,1650,550,550,550,550,550,500,600,1600,550,550,550,550,550,1650,550,550,550,550,550,550,550,550,550,550,550,550,550,500,600,1650,500,550,550,600,500,1700,500,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1650,550,550,550,500,550,1650,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,550,550,550,550,550,550,550,550,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1600,600,550,550};
// ON and 20 C° with 1 FAN heat and SWING
unsigned heat_with_swing[] = {3000,3000,3000,4400,550,1650,550,500,600,1600,600,500,600,500,600,1600,550,550,550,1650,550,500,600,1600,600,550,550,550,550,550,550,1600,600,500,600,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,550,550,1600,550,550,550,600,500,550,550,550,550,550,550,550,550,550,550,1650,550,1650,550,550,550,550,550,1600,550,1650,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1650,550,550,550,550,550,550,550,550,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1650,550,1650,500,1650,550,550,550,1700,500};
// ON and 23° with 2 FAN cold and SWING
unsigned cold_with_sqwing[] = {2950,3050,2950,4400,550,1600,600,550,550,1650,550,550,550,550,550,1600,600,500,600,1600,550,500,600,1650,550,1650,550,1600,600,500,600,1600,600,500,600,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,500,600,550,550,500,600,1650,550,550,550,1600,600,500,600,1600,550,1600,600,500,600,500,600,550,550,500,600,1650,550,1600,600,500,600,500,550,1650,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,500,600,500,600,500,600,500,600,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1650,550,1600,600,1600,550,550,600,500,550,550,550,550,550};

void loop() {

irsend.sendRaw(heat, sizeof(heat)/sizeof(int), khz);
delay(10000);
irsend.sendRaw(OFF, sizeof(OFF)/sizeof(int),khz);
delay(10000);
}

If we went out to operate the air conditioner at home, we are well on track to complete the project!
As indicated previously, it is necessary to use two Arduino, one that manages the webserver, the other that handles the communication with the air conditioner.
To connect the two Arduino in a correct way, care should be taken to the below image.
On the device connected to the Ethernet Shield is necessary to load the program that takes the name of AC_Webpage_Controller.ino, while nell'Arduino that will send IR commands, you must load the program that takes the name of AC_Sender_Code.ino. You can find the software on my Github repo https://github.com/jackbell16/AC-Progetto-Arduino/tree/master/Arduino_Code

Now that we have completed the loading process, we just have to do some work to improve the project, the most useful, is to make it accessible from a remote webserver. To do that we should "open the doors" of our router to properly route requests that are made outside of our local network.
It should be stated that in the version of the code on Github reported, there is no level security password, to simplify a bit 'the project. However, with some modifications to the code AC_Webpage_Controller.ino, you can also implement this feature.

Step 4: Port Forwarding, to Put the Arduino and A/C on the WEB

The operation of port forwarding, it varies from router to router, but in general, you can proceed as follows:

• Identify the IP address of the webserver Arduino
• Identify the IP address of the gateway
• Open your browser and type the IP address of your router and enter the credentials
• Open the port forwarding section and enter data such as the IP port as the Arduino and 80.

Now we could also access outside of our local network, simply by opening a web page with the public IP of your ADSL connection (to retrieve this value, simply type on Google.com "my ip").
Now we can finally test our project!



Step 5: Download the Android Application !

If you don't want to use the webpage, you can download the application for Android !

You can do this by typing RemoteAC from the Play Store, or use this link:

https://play.google.com/store/apps/details?id=com....

Remember that once you open the application you need to set the IP of Arduino in the preferences !

<p>Hi everyone I&acute;ve made it but not at all , i have found an issue when i try to send the signal to McQuay air conditioner doesn&acute;t work, I have tried everything as change the frequency, i have been searching on internet hex codes for Mc Quay brand but i haven&acute;t found them. Have someone found the same issue? because I used this instructable to control televisions , air conditioner (other brands),projectors and works. </p>
<p>I receive code but I cannot send any. I also bough this: <a href="https://www.aliexpress.com/item/5V-IR-Infrared-Remote-Decoder-Encoding-Transmitter-Receiver-Wireless-Module/32580582483.html?spm=2114.01010208.3.1.3ixAbz&ws_ab_test=searchweb0_0,searchweb201602_1_116_10065_117_10068_114_115_113_10000009_10084_10083_10080_10082_10081_10060_10062_10056_10055_10037_10054_10033_10059_10032_10099_10078_10079_10077_10000012_426_10103_10073_10102_10000015_10096_10052_10053_10107_10050_10106_10051,searchweb201603_3,afswitch_5,single_sort_0_default&btsid=9e4f2f4e-7c09-4545-9956-d75340b63535" rel="nofollow">https://www.aliexpress.com/item/5V-IR-Infrared-Rem...</a> but still no luck. I have been trying for weeks. I don't know what I am doing wrong.</p>
<p>Hello,</p><p>How should I fix the code to send only on/off signals? With them only 1 Uno will be enough I guess.</p>
<p>Many thanks <a href="https://www.instructables.com/member/Rossos" rel="nofollow">Rossos</a> for &quot;RAWBUF&quot; hint as for my A/C (Sharp) code length is (212) so I increased RAWBUF to 255 then got it worked.</p><p>Main thanks for auther jackbell16.</p>
<p>hi jackbell,</p><p>I'm trying to emulate your project. </p><p>I can successfully receive, record and then send the RAW data (my AC is Hitachi). </p><p>However, during the receive / record phase, I noticed that the RAW code changes EVERY time, even if the command is always the same (e.g. I switch on the AC with the same setting, and the code is everytime different).</p><p>I also tried to intercept wih another Arduino what the first Arduino is sending (I send the same string every 10 sec), and changes everytime....</p><p>Is it normal in your opinion? maybe there is some problem in the IR receiver?</p><p>thanks</p>
<p>Hi,</p><p>I&rsquo;m irinakim and I&rsquo;m work in the Wiznet.</p><p>Thank you for using our product.</p><p>We are collecting so much data using ourproduct.</p><p>And I will post the this project on our Web site.( <a href="http://wiznetmuseum.com/" rel="nofollow">http://wiznetmuseum.com</a>)</p><p>Can I post your product on our Web site?</p>
<p>Hello, very cool project!!</p><p>I have a problem sending the code with arduino uno.</p><p>With IRrecv Dump and the original remote control I get:</p><p>D010020A<br>Decoded NEC: D010020A (32 bits)<br>Raw (74): -7402 9000 -4350 750 -1500 750 -1550 750 -450 750 -1500 750 -450 750 -450 750 -450 700 -450 750 -450 750 -450 750 -450 700 -1550 750 -450 750 -450 750 -450 700 -450 750 -450 750 -450 700 -500 700 -500 700 -450 750 -450 700 -1600 700 -450 750 -450 700 -500 700 -500 700 -500 700 -1550 700 -500 700 -1600 700 -450 700 -500 700 -1600 700 -450 700 </p><p>Loading in other Arduino Uno this code:</p><p><a href="http://www.youtube.com/results?search_query=include" rel="nofollow">#include</a> &quot;IRremote.h&quot;</p><p>IRsend irsend;</p><p>void setup()<br>{</p><p>Serial.begin(9600);<br>}</p><p>void loop()<br>{<br>//Replace for your IR Code here. <br>irsend.sendNEC(0xD010020A, 32); //irsend.send(IRTYPE)(0x(IRCODE), (BITS)); <br>delay(10000);<br>}</p><p>And reading with IRrecvDump which sends the Arduino I get:</p><p>D010020A<br>Decoded NEC: D010020A (32 bits)<br>Raw (68): -6696 9100 -4350 700 -1550 700 -1550 650 -450 650 -1600 700 -450 650 -450 650 -450 650 -500 650 -450 650 -450 650 -500 650 -1550 700 -450 650 -450 650 -450 700 -450 650 -450 650 -450 700 -450 650 -450 650 -450 700 -450 650 -1600 650 -450 650 -450 650 -500 600 -500 650 -450 650 -1600 650 -450 650 -1600 650 -500 600 </p><p>I do not understand the difference Raw (74) and Raw (68)</p><p>The original remote control is NEC code. Disassemble and inside has the NEC chip.<br>It is an Air-conditioner, but the air conditioner unresponsive. The original remote control sends the code only once.</p><p>I forgot to say that the same code works correctly for samsung led tv. Of course, replacing void loop () with this:</p><p>void loop() {<br> delay(10000);<br> for (int i = 0; i &lt; 3; i++) {<br> irsend.sendSAMSUNG(0xE0E040BF, 32); //SAMSUNG TV LED on/off (capturado con IRrecvDumpV2.ino)<br> delay(40);<br> }<br> delay(10000);</p><p> <br>}</p><p> <br>Thanks and sorry for my English.</p>
Hi,<br>I've not clearly understand your problem. <br>If you want to make a kind of reverse engineering with your A/C, you need first to decode the signal and then try to send if everything works correctly. <br>If you use the RAW version, you need to ignore the first value of the array when you send it. I hope this info will help you in your project.
<p>I will test with senRAW. I tell you later.</p><p>Thanks again</p>
<p>Thank you very much for the comment.</p><p>I meant this</p>
<p>my A/C can't seem to detect the IR codes sent via TR LED can someone help ?</p>
<p>I've Made it! (sry no pictures)</p><p>One small remark: if you have Sony or some other R5/R6 protocol Infrared remote control, which apparently sends their signal 3 times instead of using checksum last bits, you may need to open up &lt;IRremote.h&gt; file manually and go all the way down and adjust the RAWBUF constant. By default it is 100, but my codes were of the size 182. I've set the constant to 192 (higher values were causing crashes on my Arduino Nano) and everything started working.</p>

About This Instructable

79,495views

80favorites

License:

Bio: I'm an Arduino Maker, I like technology, playing tennis
More by jackbell16:How to let comunicate Arduino with KeyPad to DB MySQL. Arduino water system to wet your plant How to make an alarm system with Arduino 
Add instructable to: