Introduction: Air Conditioning Web Controlled by Arduino

Hello there

The high temperature of this summer, make me think to this project. May be there are similar on the internet, but I didn't find.

This project is based on arduino, and runs well on boards bigger than UNO, which has not so much memory. With this you can switch ON or OFF, your home's air conditioning system, checking the ambient temperature and humidity, and all this, through your phone's browser away from home. ... of course, if you have a internet connection at home and on your cell phone (not just smartphones).

Step 1: Hardware

  1. Arduino Mega
  2. Ethernet shield
  3. 5v(USB), 6v or 9v power plug for arduino
  4. LAN ethernet cable
  5. DHT22(or DHT11) sensor for temperature/humidity
  6. Infra Red (IR) LED from a remote control or less than 1€ in electronics shop
  7. temporary: an IR receiver
  8. temporary: a breadboard with three wires

Step 2: Getting the Codes

The remote control of the air conditioning systems have always an lcd screen with settings. When you press any button, the IR led sends ALL the configurations which are shown on the remote's lcd, plus the modification by pressing that button.

All the other remotes (TV, DVD, HiFi...) are different -> every time you press the same button, you get the same short code. But that's another nice story.

To make the receiver, we can use our arduino (UNO is good enough) and the IR receiver. Please see the photo above with few models and pinout. Just look at the housing and the pins. In my case, is the first on the list.
Put the receiver on the breadboard and connect + to 5V, - to GND and S to arduino's Digital 2. Connect the arduino to the computer and download the arduino sketch "Long_IR" down here and load it on the arduino.

To get the codes for OFF, DRY, COOL or even HEATING, we need to set the lcd on the remote with the configuration that we need, for example DRY/25°C/no Swing/Fan auto . Then open the terminal, arduino will wait for data from the remote. Now put the remote in the front of the arduino receiver and press "ON/OFF". After you see on the terminal the code coming, press again "ON/OFF".

In this way, the first code you get on the terminal is OFF and the second one is DRY/25°C/no Swing/Fan auto .

You can copy this codes to a text file.

Now, you can do the same for COOL, and you can copy only the code for COOL.

In the text file with the codes cancel all the "-" (minus) sign and put it in the sketch

Step 3: First Test in the Home Network

First I tried with arduino UNO, but I get out of memory (only 2kb) for the variables. Uno is ok if you want to just activate the air conditioning (one code). If you need buttons to switch OFF!, switch ON cooling, switch ON drying, switch ON heating, you definitely need an arduino Mega.
DHT22 is an option. But is nice to see the temperature and humidity in your house, one hour before your arrival.

Mount the ethernet shield on the arduino. Connect DHT22 to +, GND and digital pin 2. Please refer to DHT22 connection: here Connect the IRtransmitter led to GND and digital pin 9. Note that I did not use a resistor. I see that with the resistor, the IR light is werry weak (AC did not receive), and without the resistor is better. How did I "see"? take a look at: this instructable . Then connect arduino to network.

Libraries used for this are most of them located by default il the arduino IDE. Libraries which you may need are DHT and IRremote, witch you can also, get it here. Download the sketch down here and load it on your arduino.

Change the network configuration with yours > mac, IP ... < .

Codes may be different because we're using a different AC manufacturer. Just change my codes, with your codes, keeping the same meaning of the codes: my OFF with your OFF, my DRY with your DRY and so on...

Load the new sketch and from the pc conected to your home network, just tipe in the browser the arduino's IP.

Keep the IR led straight to the AC not more than 5 meters away. Then check if you can see in the browser the temp/humidity values, and looking at the AC press the commands OFF, DRY, COOL.

In this case, you can use this to control the AC from inside your home network.

Step 4: Setting Up Router

For this you need to refer to your router manufacturer and open the ports that arduino can be seen from outside.
If you have a dynamic IP, you must use a free service like noip.com or dyndns.org. With static IP, just open ports on router and use it.

Example:

internal IP: 192.168.1.100

external IP: 2.230.yyy.xxx find your's here

You need to open a port on external IP to go on port 80 of the internal IP. We chose port 7000.
The address you will need to call in the browser from outside, look's like this: http://2.230.yyy.xxx:7000

If you use a dynamic IP service: http://user.noip.com:7000

_________________________________________________

Hope you enjoy this instructable.

Cristian

Comments

author
ParaschivL (author)2017-08-01

Buna MoniCris,

Foarte bun si constructiv, insa te rog daca poti sa pui un sketch pentru un arduino uno, pe partea de receive data si send data, ar fi mult mai usor pentru un incepator sa faca sistemul, si apoi sa treaca la partea cu webserver?

Incearca sa explici putin mai bine cum se face receptia datelor, si apoi ce se pune mai exact in "unsigned" dupa ce s-au receptionat datele.

author
InnaC1 (author)2017-04-21

Great tutorial, thank you! :)

author
snadeem5 (author)2017-01-27

we will try with ac remote as nodemcu

author
Gökhan Türkeli (author)2017-01-03

Great instructable!

Is it not possible to use the Uno alone(without ethernet) and send simple on/off signals? I receive data from my remote but I couldn't figure out to send data.

author

we will try nodemcu to send ac code

author
snadeem5 (author)snadeem52017-01-26

we will send codes with uno they cant receive it

how to operate ac remote with arduino

author
MoniCris (author)snadeem52017-01-27

I don't get your problem. Please explain better

author
MoniCris (author)snadeem52017-01-27

I will try with ESP07(ESP8266) I will write a review.

author

@snadeem5, I just received my nodemcu package yesterday. Please let me know if you succeed:)

author

Hi
Yes you can use only UNO, but where's the fun.
Maybe can be something like this: uno, DHT22 and IRled, you can use an thermostat. UNO is switching on or off the AC if the condition "temperature" is high or low.
If you have problems with ir codes, please explane more information about it.
Thanks

author

The fun is to be able to control the AC:) That's enough for me.

I tried to do what you said but I couldn't do it. I couldn't make the code work

As far as I understand code consist several parts:

1- define the signals

2- define the output pin

3- operate selected signal

So I modified your code as attached. But it doesn't work. I made something wrong I guess. I checked the led with phone cam but it doesn't work.

I can get the signals with your scheme but I cannot send them.

Screenshot_2.jpg
author
snadeem5 (author)2017-01-26

i will send raw and nec codes from arduino but ac cannot ON

what will do to ON AC

author
hail15 (author)2016-10-08

Hi Cristian

Can this project receive all code of air-conditioner? i need to receive a lot air-conditioner because i learn graduate thesis and i need you project

thank you very much, Cristian

author
siddiquek (author)2016-09-18

Hello Monichris,

I am going with the wifi sheild in my implementation. Please support me to add the sketch for wifi purpose.

author
MoniCris (author)siddiquek2016-09-30

Hi. I do not have a wifi shield to test it, but please my sketch with this on in the link: www.arduino.cc/en/Tutorial/WiFiWebServer

author
SufianS (author)2016-08-10

Hi MoniChris, it awesome project. I have some question.

Can i using arduiono genuino? and how i want to link the ardiuno to the web pages?

Thankss :)

author
MoniCris (author)SufianS2016-09-30

Hi. Thanks.

There is no "arduino genuino". Arduino is the name in USA, and Genuino is the name in Italy (or Europe I think).

So, "Genuino UNO" is the same board like "Arduino UNO"

When I write the instructables there was no Genuino.

What do you mean with "link the ardiuno to the web pages"?

To create the web pages (web server), please check playground.arduino.cc/Code/WebServer

Cheers

author
JohnD466 (author)2016-05-23

Hi Chris

Im totally new to html.

What part of html code sets the text size and font of most of the text on the web page.

I can see the font size of the "STATUS" but where is the rest of it set.

Thanks for the article

author
MoniCris (author)JohnD4662016-09-30

I'm not good in html too. Please Google for that.

author
Dm87 made it! (author)2015-11-08

Thanks for this project, Cris so helpfull person and really awesome. Hope anyone else can be made it also...

temp_-828886625.jpg
author
MoniCris (author)Dm872016-09-30

Great. Thank

author
MoniCris (author)Dm872015-11-10

Great! That's nice to see. I'm proud. Thank you.

author
PanagiotisS8 (author)2016-07-29

Hi MoniCris! Very nice project! I have 2 questions:

1) Can I do it with a wifi shield? Cause the A/C is not on the same room of the router.

2) The adress for the remote, will it work from everywhere or only on my house's network?

Thanks!!!

author
MoniCris (author)PanagiotisS82016-08-01

Hi. Thanks.
1) Shure youcan do it. You only need to modify the sketch according to the wifi shield.
2) in your home, normally you type in the internal IP like 192.168.1.35 , but when you are outside or in 3G, you need to open some ports on your router. Than you must find your "external" IP from here whatismyipaddress.com and then you must tipe on your smartphone the IP and the port. You need to check with your InternetServiceProvider if is possible to open some ports on your router.
Cheers

author
RizkiA16 (author)2016-04-04

hello cris, i very interest with your project, i get some problem when i try to get ir signal with your code, but i get the other code in other site finaly i can record my remote signal, but when i record a signal i get a difference raw code although i try with a same button its always defference, i thinks it's ok the signal i record for turn off my ac like this [Raw (101): 8828 3050 -1650 450 -1150 450 -1150 450 -350 450 -400 450 -350 500 -1100 450 -400 450 -450 400 -1150 450 -1100 450 -400 450 -1100 500 -400 400 -400 450 -1100 500 -1150 450 -350 500 -1100 450 -1150 450 -400 450 -350 450 -1200 400 -400 450 -350 500 -1150 400 -450 400 -350 500 -350 450 -400 450 -400 450 -350 450 -400 450 -350 450 -450 400 -400 450 -350 450 -400 450 -350 500 -350 500 -350 450 -350 500 -350 450 -400 450 -400 450 -350 450 -1150 450 -400 450 -350 450 -1150]

and i try to convert it to : [unsigned OFF[] = {3050,1650,450,1150,450,1150,450,350,450,400,450,350,500,1100,450,400,450,450,400,1150,450,1100,450,400,450,1100,500,400,400,400,450,1100,500,1150,450,350,500,1100,450,1150,450,400,450,350,450,1200,400,400,450,350,500,1150,400,450,400,350,500,350,450,400,450,400,450,350,450,400,450,350,450,450,400,400,450,350,450,400,450,350,500,350,500,350,450,350,500,350,450,400,450,400,450,350,450,1150,450,400,450,350,450,1150};]

like your intructions , but when i try to send it to my ac , my ac don't give a respond like nothing happen, i check with my ir transmitter is send a light with my phone camera, but why my ac don't give a respond for that signal ? , can you advice me ? help me cris, thanks

author
Dm87 (author)2015-11-05

hi Cris, I have problem to get code from IR receiver. when I follow your step, on my terminal always give code without stop, even when Im not pressed any button. is that something wrong I miss it. Please advice

author
Dm87 (author)Dm872015-11-06

my last problem fixed by replacing with another type IR receiver.
But now I have abother problem because I cant connect from browser with my IP configuration, can you please give some advice... Thanks before

author
MoniCris (author)Dm872015-11-07

Ok. So it was another type of Ir receiver. Please look at the picture with the typer of ir receivers. Now, if you installed the ethernet library, please run the simple web server example where you can see the analog inputs on the web page. Also please check if all the device are conected to the same interbal network (not 3G)

author
Dm87 (author)MoniCris2015-11-07

thanks for your advice Cris, I was able to connect with browser now, its seems because I have an IP conflict with another computer after make double cross check as your stated. Now I can see my DHT result its valid compare to my other temperature stuff in my room, but I have inaccurate status for AC, arduino said it OFF even actually it is ON and I failed to controll it with the button because when I try to pressed DRY or COOL, then it wouldnt do anything to the AC, do you have any suggest advice for this troubleshoot.. thanks before for this amaze project

author
MoniCris (author)Dm872015-11-08

Great. A tip for IP: set an IP from the end of the list (192.168.0.200)

For the state of the AC, arduino for now, is not able to check the state. What you see in the browser, is the last comand sended to the AC. You can see something real, by looking at the temperature and humidity to understand better what is active.

You have checked all three codes by sending one by one to see if the AC is accepting it?

Please look in the other comments. I posted an photo with an ideea to better check if the AC is running or not.

author
Dm87 (author)MoniCris2015-11-08

I made it, Thanks for your advice and help Cris... Your project is awesome for me.... Next I wanna try to implement CT. Wish you all the best

author
MoniCris (author)Dm872015-11-10

That's very kind of you. Thank you. So, soon, I will see an instructable about this CT sensor. Good luck.

author
ihabosman (author)2015-10-27

Hi cristian thanks for that great project ,I'm trying it but i'am stuck in many thing so could u please help me;

first thing the codes I get from the remote what I should do with it or where I should put them?

author
MoniCris (author)ihabosman2015-10-28

Thanks. So! After you get the codes in the terminal, you need to copy them to a text file, and then need to cancel all "-" signs. After this copy this code to the "send" sketch. Please tell me exactly where are you blocking at? Please look also in my examples. Need to be nearly the same.

author
bingdo72 (author)2015-09-22

This is good.
I have been searching some application references in which WIZnet solution is applied, and found your project using Ethernet Shield.
In the Ethernet Shield WIZnet's W5100 chip is embedded.
If you are O.K. I'd like to post this article in WIZnet Museum (http://wiznetmuseum.com) for others.

author
MoniCris (author)bingdo722015-09-22

Would be a pleasure for me. Thanks.
Could you please send me an link to this article when you post it?

author
nice_man_36 (author)2015-09-01

really nice work i think to do the same project i will

author
MoniCris (author)nice_man_362015-09-01

Thank you

author
mnowak7 (author)2015-09-01

Where did you got your mega from? like the design with the sd card

author
MoniCris (author)mnowak72015-09-01

There's no sd on mega. The sd is on the ethernet shield witch is on arduino mega.

author
frank984 (author)2015-08-31

https://www.instructables.com/id/A-comfortable-smar...

Have you seen this ^^^ other similar project?

author
MoniCris (author)frank9842015-08-31

Wow! That's the same. I know why I did not find it before. Smart lamp in the title did not make me think to the air condition. Anyway, is a good project too.

author
frank984 (author)MoniCris2015-08-31

Probably "smart lamp" as name of the project can mislead. This justify the differences in the counter of visualizations... ;)

author
gcheintz (author)2015-08-25

Sorry to be ignorant but where do you keep the arduino-unit? I assume it has to be within reach of the AC but plugged into a power socket? Is there any reliable battery for arduino that works during a longer set of time? would be nice to have a not-ugly solution for renting out my apartment to make sure the AC is not on 100% and cost 1000€+ per month

author
MoniCris (author)gcheintz2015-08-27

Nobody's ignorant. I did not think at the enclosure of the arduino, but any box, big enough for arduino+ethernet, can be good and you can hide somewhere. Important is that the IR led must "see" the AC.
And for battery: when you have the possibility to use the normal power, is better to use it. I check the power consumption of arduino+ethernet, and is verry low 2W, so you will not have relevant costs for it.

author
MoniCris made it! (author)MoniCris2015-08-29


I made a drawing thinking of your request. Near by the AC, you can put an electrical box, where you can put all in it. If is not possible to get there a LAN cable, you need to add a WiFi module. With a cable, put the IR LED internally of the AC in the front of the AC receiver. You can take 220v from the power suply of the AC. In the box, a small transformer(electronic is smaller) to power up the arduino. DHT sensor, you must put it lower than the AC to measure the right temperature. Then, you can add an CT sensor to measure the power of the AC. When is 0W(0A) mean the AC is OFF. When is 1100W(5A), mean is ON. In this way you know if the AC is On or Off.

Thank you for your questions. Makes me get more ideas.

image.jpg
author
gcheintz (author)MoniCris2015-08-30

Thats so kind! Thank you so much!

author
Mjtrinihobby (author)2015-08-22

This is a remarkable project! Awesome.

author
MoniCris (author)Mjtrinihobby2015-08-27

Thanks