Air Conditioner IR Controller

Simplify IoT Development.

Moderators: violet, yexiaobo, seth.welday

joshuaguedalia
Pre-kindergarten
Pre-kindergarten
Posts: 7
Joined: Tue May 10, 2016 6:19 pm

Air Conditioner IR Controller

Post by joshuaguedalia » Mon May 16, 2016 9:12 pm

Hello,

I am new here, so go easy :).

I wanted to build an air conditioner IR controller, and wanted help if figuring out if I can use the Wio Link and Grove components to make this work?
The first phase would be to control the A/C to switch between COOL and FAN based on temperature. Future phases will include using my phone when away from the house to turn on A/C, and other ideas.

Components I think I would need:
- Wio Link
- Grove - Temp&Humi Sensor SKU: 101020011
- Grove - Infrared Receiver SKU: 101020016
- Grove - Infrared Emitter SKU: 101020026

The steps:
1. record from my existing remote the commands I would like to transmit to the A/C: Off, Fan, Cool.
2. code a solution that will read the temperature and based on the result transmit the correct IR.

My questions:
1 can this be done?
2 do I have the correct list of components?
3 can I use IFTTT ? or should I code a server ?

Any and all help welcome, Thanks

wassabi.time
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Thu Apr 07, 2016 10:34 pm

Re: Air Conditioner IR Controller

Post by wassabi.time » Mon May 16, 2016 11:22 pm

Is a great project. I have often thought about why smart thermostats don't come with an IR blaster for window units.

Your part list looks ok to me.

You can probably get it working with basic commands from IFTTT. For more control, you'll want a server.

Alternately, you can use the "advanced user guide" to reprogram the wio link to remove the need for a server.

joshuaguedalia
Pre-kindergarten
Pre-kindergarten
Posts: 7
Joined: Tue May 10, 2016 6:19 pm

Re: Air Conditioner IR Controller

Post by joshuaguedalia » Tue May 17, 2016 12:51 am

Great, how do I go about recording IR / playing back IR. Is there documentation?

wassabi.time
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Thu Apr 07, 2016 10:34 pm

Re: Air Conditioner IR Controller

Post by wassabi.time » Tue May 17, 2016 1:45 am

The IR modules were not on the original list of compatible grove modules. So you won't find much for wio link specific instructions.
http://www.seeedstudio.com/wiki/Grove_- ... d_Receiver

I can tell you how it "should" work.
  • Connect the IR receiver to any digital port connector
  • Load up your wio link app on your smartphone,
  • tap the corresponding port connector
  • scroll down to find and select the infrared receiver device
  • Update the firmware
  • Press the API button. You should then see some demo server commands.
  • Use the GET to read an IR number

joshuaguedalia
Pre-kindergarten
Pre-kindergarten
Posts: 7
Joined: Tue May 10, 2016 6:19 pm

Re: Air Conditioner IR Controller

Post by joshuaguedalia » Tue May 17, 2016 1:58 am

Thanks, I appreciate the advice.

I would like to have someone confirm that this _will_ work - anyone from the Wio team can comment?

sheepjms
Pre-kindergarten
Pre-kindergarten
Posts: 15
Joined: Mon May 09, 2016 5:41 pm

Re: Air Conditioner IR Controller

Post by sheepjms » Tue May 17, 2016 11:14 am

Hi joshuaguedalia! I'm one member of the Wio team.The advice wassabi gave you is quite useful! Thanks wassabi :D !

Since you are a new learner, I suggest you start with IFTTT , work with some basic function.

If you want to try further experiment, you can try the advanced user guide of wio link. Meanwhile you may encounter serveral issues, and you can ask us in this forum any time! We will answer your question as soon as possible! :)

erdtmann
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Wed Dec 12, 2012 6:22 am

Re: Air Conditioner IR Controller

Post by erdtmann » Thu May 19, 2016 6:28 pm

I managed to do exactly what are you intending, but with an arduino. The most problematic part was about getting the IR codes from the remote. The Carrier unit I have at home uses very long ir commands (somewhat non-standard, twice the usual lenght) so I made an specific software to get them from the remote and dump the timings on screen. I haven't managed to change the timings into hexadecimal codings, so I sent then to the AC unit replicating the timings. I fiddle on the Wio Link today and sought it ask for hexa. I don't know if it is possible to convert the timings into hexa (non-standard) and I don't know if it would receive the very long commands of AC control. Maybe it will require some aditional coding into the IR drive on Wio...

joshuaguedalia
Pre-kindergarten
Pre-kindergarten
Posts: 7
Joined: Tue May 10, 2016 6:19 pm

Re: Air Conditioner IR Controller

Post by joshuaguedalia » Fri May 20, 2016 12:22 am

Thanks for the information.

It sounds like you were successful with the arduino - do you have any code you can share, or specific details describing the process?

If I understand correctly, you are working on deciphering the IR code - that is why you wanted the HEX - correct?

For my project, at this phase, I do not need to decipher the code, just play it back exactly as transmitted.

Are you successful with the Wio to capture and transmit the IR code?

erdtmann
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Wed Dec 12, 2012 6:22 am

Re: Air Conditioner IR Controller

Post by erdtmann » Mon May 23, 2016 5:17 am

I just received Wio Link. Didn't try it yet (else from the trivial). I used 1 software for arduino to receive the IR codes, which I saved from serialMonitor into a txt file. Afterwards, in another sketch I use the acquired IR codes (in timings format, not Hex). I think this sounds exactly the same you want to do, but with wio... Here goes the code for reading the on-off timings on arduino (I used the code from AnalysIR ):

Code: Select all

/*
Author: AnalysIR
Revision: 1.0

This code is provided to overcome an issue with Arduino IR libraries
It allows you to capture raw timings for signals longer than 255 marks & spaces.
Typical use case is for long Air conditioner signals.

You can use the output to plug back into IRremote, to resend the signal.

This Software was written by AnalysIR.

Usage: Free to use, subject to conditions posted on blog below.
Please credit AnalysIR and provide a link to our website/blog, where possible.

Copyright AnalysIR 2014

Please refer to the blog posting for conditions associated with use.
http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/

Connections:
IR Receiver      Arduino
V+          ->  +5v
GND          ->  GND
Signal Out   ->  Digital Pin 2
(If using a 3V Arduino, you may connect V+ to +3V)
*/

#define LEDPIN 13
//you may increase this value on Arduinos with greater than 2k SRAM
#define maxLen 800

volatile  unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR

void setup() {
  Serial.begin(9600); //change BAUD rate as required
  attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println(F("Press the button on the remote now - once only"));
  delay(5000); // pause 5 secs
  if (x) { //if a signal is captured
    digitalWrite(LEDPIN, HIGH);//visual indicator that signal received
    Serial.println();
    Serial.print(F("Raw: (")); //dump raw header format - for library
    Serial.print((x - 1));
    Serial.print(F(") "));
    detachInterrupt(0);//stop interrupts & capture until finshed here
    for (int i = 1; i < x; i++) { //now dump the times
      if (!(i & 0x1)) Serial.print(F(""));
      Serial.print(irBuffer[i] - irBuffer[i - 1]);
      Serial.print(F(", "));
    }
    x = 0;
    Serial.println();
    Serial.println();
    digitalWrite(LEDPIN, LOW);//end of visual indicator, for this time
    attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal
  }

}

void rxIR_Interrupt_Handler() {
  if (x > maxLen) return; //ignore if irBuffer is already full
  irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions

}
And here goes the code to read the temperature and send commands to Carrier AC, using the txt-saved timing codes. It checks the temperature once every 60 secs, and if it is too high, it sends the on-command. If it is too low, it sends the off-command:

Code: Select all

#include "DHT.h"
#include "IRremote.h"
 
#define DHTPIN A0 // pino umidade e temperatura
 
// Grove DHT11
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
 
DHT dht(DHTPIN, DHTTYPE); 
IRsend irsend;

int khz=38; //Frequencia IR

unsigned t_off[] = {4440, 4400, 560, 1632, 556, 544, 556, 1640, 560, 1632, 556, 544, 556, 544, 568, 1624, 564, 536, 564, 540, 560, 1636, 564, 536, 564, 536, 560, 1632, 560, 1632, 564, 536, 564, 1632, 560, 544, 564, 1628, 560, 1632, 560, 1632, 556, 1632, 568, 532, 568, 1628, 560, 1636, 564, 1632, 564, 536, 564, 536, 564, 536, 564, 536, 564, 1628, 560, 540, 560, 544, 564, 1632, 560, 1632, 564, 1628, 564, 536, 564, 536, 564, 536, 560, 540, 560, 544, 556, 544, 568, 532, 564, 540, 564, 1632, 564, 1628, 560, 1632, 560, 1628, 560, 1636, 564, 5252, 4436, 4396, 564, 1628, 564, 536, 560, 1636, 564, 1624, 568, 532, 564, 536, 564, 1628, 564, 540, 560, 540, 568, 1628, 560, 540, 560, 544, 556, 1632, 568, 1624, 564, 536, 564, 1632, 568, 536, 564, 1628, 560, 1632, 568, 1624, 564, 1628, 560, 540, 560, 1636, 564, 1628, 560, 1640, 560, 540, 560, 540, 588, 512, 588, 512, 588, 1604, 584, 516, 584, 516, 596, 1604, 596, 1596, 560, 1632, 560, 540, 556, 544, 588, 512, 588, 512, 588, 512, 596, 508, 592, 508, 592, 508, 592, 1604, 564, 1628, 560, 1632, 556, 1636, 564, 1632, 608};
unsigned t_on[] = {4436, 4388, 568, 1624, 564, 536, 564, 1632, 568, 1624, 564, 536, 564, 540, 556, 1636, 564, 536, 564, 540, 560, 1636, 564, 536, 564, 536, 560, 1632, 560, 1632, 568, 532, 564, 1636, 564, 536, 564, 536, 564, 536, 564, 1628, 560, 1632, 568, 1624, 564, 1628, 564, 1656, 540, 1632, 568, 1624, 564, 1628, 560, 540, 560, 540, 560, 544, 556, 544, 564, 536, 564, 1632, 560, 1632, 564, 536, 564, 536, 564, 1628, 560, 540, 560, 540, 560, 544, 568, 532, 564, 540, 560, 1632, 560, 1632, 564, 536, 564, 1632, 560, 1632, 564, 1628, 564, 5228, 4440, 4396, 564, 1628, 564, 536, 560, 1636, 564, 1628, 564, 536, 560, 540, 560, 1632, 568, 536, 564, 540, 560, 1636, 564, 536, 560, 540, 560, 1632, 560, 1632, 564, 536, 564, 1636, 564, 540, 560, 540, 560, 540, 560, 1632, 564, 1628, 564, 1628, 560, 1632, 556, 1640, 560, 1636, 564, 1628, 560, 1632, 556, 544, 568, 532, 596, 504, 596, 504, 596, 508, 592, 1604, 592, 1600, 560, 540, 560, 540, 588, 1604, 568, 532, 588, 512, 588, 516, 592, 512, 588, 508, 592, 1604, 564, 1628, 560, 540, 560, 1636, 564, 1628, 560, 1636, 564};

int contador = 0;

int TMIN = 23;
int TMAX = 25;
void setup()
{
    Serial.begin(9600);
    Serial.println("Controle de Temperatura Carrier");
 
    dht.begin();
}
 
void loop()
{
    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to A0 seconds 'old' (its a very slow sensor)
    float h = dht.readHumidity();
    float t = dht.readTemperature();
 
    // check if returns are valid, if they are NaN (not a number) then something went wrong!
    if (isnan(t) || isnan(h))
    {
        Serial.println("Failed to read from DHT");
    }
    else
    {
        Serial.print("umidade: ");
        Serial.print(h);
        Serial.print(" %\t");
        Serial.print("temperatura: ");
        Serial.print(t);
        Serial.println(" *C");
        if (t<TMIN && contador < 1){
           Serial.print("Desligando... ");
           irsend.sendRaw(t_off, sizeof(t_off)/sizeof(int), khz);
           contador = 15;
        }
        
        if (t>TMAX && contador < 1){
           Serial.print("Ligando... ");
           irsend.sendRaw(t_on, sizeof(t_on)/sizeof(int), khz);
           delay(10000);
           contador = 15;
        }
        
        if (contador>0){
          contador--;
        }
        
        delay(10000);
        delay(10000);
        delay(10000);
        delay(10000);
        delay(10000);
        delay(10000);

    }
}

joshuaguedalia
Pre-kindergarten
Pre-kindergarten
Posts: 7
Joined: Tue May 10, 2016 6:19 pm

Re: Air Conditioner IR Controller

Post by joshuaguedalia » Mon May 23, 2016 6:22 am

Thanks erdtmann, I am currently waiting for the delivery of my Wio and other accessories for this project. Once I receive them I will let you know what happens, I may resort to getting an arduino and using your code.

Also, in reviewing your code I see that you wait 15 minutes (var contador) after sending IR (ON/OFF), I assume that is so you don't get into a loop or keep sending the IR signal multiple times?

Post Reply