Temperature control air conditioning

来自Microduino Wikipedia
跳转至: 导航搜索
Language English

Objective

To control air conditioner by detecting environment temperature. When temperature increases to a certain value, the air conditioner will start. On the contrary, the air conditioner will close when the outside temperature decreases to a certain value.

Principle

Use temperature and humidity sensor AM2321 to detect indoor temperature and then control the air conditioner by matching codes with infrared transmission sensor.

Equipment

Module Number Function
Microduino-CoreUSB 1 Core board
Microduino-Sensorhub 1 Sensor pin board
Microduino-Temp&Hum 1 Temperature and humidity sensor
Microduino-IR transmitter 1 Infrared transmission sensor
Microduino-Converter 1 Pin board

Hardware Buildup

  • Setup 1: Stack CoreUSB and Sensorhub.
  • Setup 2:Connect Microduino-IR transmitter via pin board to D3 pin of Sensorhub and Microduino-Temp&Hum to IIC pin of Sensorhub.
Microduino-sensorhub rule.JPG

Software Debugging

  • Air conditioner infrared remote control encoding definition. Here the conditioner adopts NEC encoding format.
IRsend irsend;       //Infrared transmission 
AM2321 am2321;       //Temperature and humidity sensor AM2321 

#define POWER_ON 0xC1602680    //Air conditioner power on/off encoding 
float temp = 0;        //Temperature value 
unsigned long runTime = 0;   //Air conditioner power on/off time
  • Detect the current temperature value every second. When the temperature is above 30℃, the air conditioner opens and when it is below 25℃, the air conditioner closes. The time interval between opening and closing is 180s for fear of frequent operation.
am2321.read();           //Acquire the current temperature value 
temp = am2321.temperature/10.0;
if(millis()>runTime+180000)    //Above 180s time interval
{
  if(temp > 30)         //Higher than 30℃ and the air conditioner opens. 

  {
    irsend.sendNEC(0xC1602680,32);
    irsend.sendCode(0x00000000,16);
    runTime = millis();
  }
  else if(temp <25)     //Lower than 30℃ and the air conditioner closes.
  {
    irsend.sendNEC(0xC1602680,32);
    irsend.sendCode(0x00000000,16);
    runTime = millis();    
   }
 }
 delay(1000);

Program

[MicroduinoAirConditioner]

Result

When the temperature is above 30℃, the air conditioner opens and when it is below 25℃, the air conditioner closes. By detecting temperature value to control other functions of the air conditioner.

Video