Introduction: Controlling an IR Air Conditioner With Android and Arduino
For my first Arduino project I decided to control my Air Conditioner over the internet with the help of Arduino and my Android Cellphone wherever I have internet access. Video is in spanish but you'll get what I'm demonstrating.
Step 1: Requirements
- An Air Conditioner ( You don't say!)
- AC IR Control Remote (It MUST be in good working order because we need to decode the IR codes)
- Arduino MEGA 2560
- Arduino compatible Ethernet Shield
- Small breadboard
- Jumper Cables
- (1) IR Receiver Diode
- (1) IR LED
- Arduino SDK
- Android SDK
- IR Remote Arduino Library - (Library official website)
- WebDuino Library - (Library official website)
Step 2: Setting Everything Up
We are ready!
First of all we need to unzip the IR Remote and Webduino library that we just downloaded to the Arduino SDK libraries folder.
Now we have to tell the Arduino SDK which type of Arduino we are using. So we go to:
Tools > Board > Arduino Mega 2560 or Mega ADK And choose Arduino Mega.
After that choose the port where your Arduino was detected: Tools > Serial Port > "YourPort"
Step 3: Preparing the IR Receiver
Now we have to connect the IR Receiver to the Arduino. The pins are connected as follows:
Pin 1 goes to pin 19 from Arduino.
Pin 2 goes to pin from Ground.
Pin 3 goes to pin from 5V.
Now we copy this sketch to the Arduino SDK. (This sketch decodes the IR from your Remote Control) **Careful copy pasting, it might give you compilation errors.
Compile and upload to your Arduino.
Step 4: Hacking the IR Codes Out of Your Remote Control
Now we have to go to Menu > Tool to open up the Serial Monitor windows. After its open, point your AC Remote Control to the IR receiver connected to your Arduino and press each button one by one. You'll get something like the image above.
NOTE: The IR library can decode most brands of remote controls, but there's a slight chance that yours might not be supported. Go check on the library website if support was added. In my case my remote control ended up being manufactured by NEC.
My codes were:
Decoded NEC: 80FF48B7 (32 bits) - AC ON
Decoded NEC: 80FFC837 (32 bits) - TEMP UP
Decoded NEC: 80FF58A7 (32 bits) - TEMP DOWN
Decoded NEC: 80FFD827 (32 bits) - TIMER
Keep them in a safe place! We're going to need them!
Step 5: Setting Up the Webserver
We have decoded our control's codes. Now we have to create another sketch, this time to implement a webserver that will help us to communicate with the arduino over the internet. To do this I modified the Web_Demo example from the Webduino library.
In order for this to work you'll have to make sure about the following:
- You must have the ethernet shield installed in your Arduino.
- You have to define your Arduino's MAC address and IP in the sketch.
- You have to define the port where the webserver will be working.
- The IR Led should be installed in the Arduino with the anode (shortest leg) on GRD (ground) and the cathode (largest leg, positive) in pin #9.
- Replace IR codes on the sketch to yours (the ones we just found!)
Save and upload your sketch.
Step 6: Voila! Control Your AC From Anywhere!
At this very moment you can actually control your Air Conditioner from any PC connected to your Network. All you have to do is to put in your address bar http://YourIP/acon your AC should turn on. Make sure the IR is pointing to your AC.
Now, this is optional and it's all under your own risk due to security issues. In order to be able to control your AC from anywhere you have internet access you must create a Port Forwarding rule in your router. That rule should contain the IP and Port you assigned to your Arduino. I recommend using a port that's NOT port 80.After creating that Port Forwarding rule you should be able to control your AC anywhere you have internet access. (You have to know your home IP address)
The android application is not really necessary because you can actually control the AC from your cellphone's browser but its more interesting (and looks really cool!) to have an android app for that. I'm a beginner on Android so most probably there's a better way to do most of the things I did in the app, but hey, it works!
Here you can download the project for the android app.
Modify it as you like and you are done!
This is the link to my original post:
English - http://techcontostones.blogspot.com/2013/09/contro...
Spanish - http://techcontostones.blogspot.com/2013/04/arduin...
We have a be nice policy.
Please be positive and constructive.