Temperature control air conditioning
Language | English |
---|
目录ObjectiveTo 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. PrincipleUse temperature and humidity sensor AM2321 to detect indoor temperature and then control the air conditioner by matching codes with infrared transmission sensor. Equipment
Hardware Buildup
Software Debugging
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
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);
ProgramResultWhen 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 |