空調(diào)(空調(diào))曾經(jīng)被認(rèn)為是奢侈品,只能在大酒店,電影院,餐館等中找到...但是,現(xiàn)在幾乎每個人都在家里有空調(diào)來度過夏天/冬天,而那些擁有它的人擔(dān)心一件共同的事情。這就是他們的高耗電量和充電器。在這個項目中,我們將制作一個小型的自動溫度控制電路,該電路可以通過根據(jù)室溫自動改變交流溫度來最小化充電器。通過定期改變設(shè)定溫度,我們可以避免使交流電長時間以較低的溫度值工作,從而使其消耗更少的功率。
我們大多數(shù)人都會遇到這樣一種情況,即我們必須在一天中的不同時間將空調(diào)的設(shè)定溫度更改為不同的值,以使我們始終保持舒適。為了自動化此過程,該項目使用溫度傳感器(DHT11),該傳感器讀取房間的當(dāng)前溫度,并根據(jù)該值,它將通過類似于AC遙控器的紅外發(fā)射器向AC發(fā)送命令。AC 將對這些命令做出反應(yīng),就像它對遙控器做出反應(yīng)一樣,從而調(diào)節(jié)溫度。隨著房間溫度的變化,Arduino還會調(diào)整空調(diào)的設(shè)定溫度,以您想要的方式保持您的溫度。聽起來很酷吧?...讓我們看看如何構(gòu)建一個。
所需材料:
阿杜伊諾超級 2560
TSOP1738 (HS0038)
紅外燈
DHT11 溫度/濕度傳感器
面包板
連接線
工作方法:
我們家中用于控制電視、家庭影院、空調(diào)等的所有遙控器都在紅外發(fā)射器的幫助下工作。紅外發(fā)射器只不過是一個紅外 LED,可以通過重復(fù)脈沖來沖擊信號;該信號將由電子設(shè)備中的接收器讀取。對于遙控器上的每個不同按鈕,將發(fā)出一個獨特的信號,該信號在接收器讀取后用于執(zhí)行特定的預(yù)定義任務(wù)。如果我們能夠讀取從遙控器發(fā)出的信號,那么我們可以在需要執(zhí)行該特定任務(wù)時使用紅外 LED 模擬相同的信號。
TSOP是一種紅外接收器,可用于解碼來自遙控器的信號。該接收器將與Arduino接口,為每個按鈕發(fā)送信號,然后IR LED將與Arduino一起使用,以在需要時模擬信號。這樣,我們就可以使用Arduino控制AC。
現(xiàn)在,剩下的就是使用 DHT11 讀取溫度值,并使用 IR 信號相應(yīng)地指示 AC。為了使項目看起來更具吸引力和用戶友好性,我還添加了一個OLED顯示屏,可以顯示當(dāng)前的溫度,濕度和AC設(shè)定溫度。
交流遙控器的工作:
在我們進(jìn)入項目之前,請花一些時間并注意您的交流遙控器的工作原理。與電視、DVD 紅外遙控器相比,交流遙控器的工作方式略有不同。遙控器上可能只有 10-12 個按鈕,但它們將能夠發(fā)送許多不同類型的信號。這意味著遙控器不會每次為同一按鈕發(fā)送相同的代碼。例如,當(dāng)您使用向下按鈕降低溫度使其為 24°C(攝氏度)時,您將獲得帶有一組數(shù)據(jù)的信號,但是當(dāng)您再次按下它以設(shè)置 25°C 時,您將不會獲得相同的數(shù)據(jù),因為溫度現(xiàn)在是 25 而不是 24。同樣,25 的代碼也會因不同的風(fēng)扇速度、睡眠設(shè)置等而異。因此,我們不要擺弄所有選項,而只是將溫度值與其他設(shè)置的恒定值集中在一起。
另一個問題是每次按下按鈕發(fā)送的數(shù)據(jù)量,普通遙控器發(fā)送 24 位或 48 位,但交流遙控器最多可以發(fā)送 228 位,因為每個信號都包含大量信息,如溫度、風(fēng)扇速度、睡眠時間、擺動風(fēng)格等。這就是為什么我們需要Arduino Mega以獲得更好的存儲選項的原因。
電路圖及說明:
幸運的是,這個自動交流溫度控制項目的硬件設(shè)置非常簡單。您可以簡單地使用面包板并進(jìn)行連接,如下所示。
下表還可用于驗證連接。
S.No: | 元件引腳 | 阿杜伊諾引腳 |
1 | OLED – Vcc | 5V |
2 | OLED – Gnd | 格德 |
3 | OLED- SCK, D0,SCL,CLK | 4 |
4 | OLED-SDA, D1,MOSI, Data | 3 |
5 | OLED- RES, RST,RESET | 7 |
6 | OLED- 直流,A0 | 5 |
7 | OLED- CS,芯片選擇 | 6 |
8 | DHT11 – Vcc | 5V |
9 | DHT11 – Gnd | 格德 |
10 | DHT11 – 信號 | 13 |
11 | TSOP – Vcc | 5V |
12 | TSOP – Gnd | 格德 |
13 | 紅外發(fā)光二極管 – 陽極 | 9 |
14 | 紅外發(fā)光二極管 – 陰極 | 格德 |
連接完成后,它應(yīng)該如下所示。我使用面包板來整理東西,但您也可以直接將公對母線連接到所有組件
解碼交流遠(yuǎn)程信號:
控制交流電的第一步是使用 TSOP1738解碼交流遙控紅外代碼。按照電路圖中所示進(jìn)行所有連接,并確保已安裝所有提到的庫。現(xiàn)在打開示例程序“IRrecvDumpV2”,可以在文件 -> 示例 -> IRremote -> IRrecvDumpV2 中找到。將程序上傳到Arduino Mega并打開串行監(jiān)視器。
將遙控器指向 TSOP 并按任意按鈕,對于您按下的每個按鈕,信號將由 TSOP1738 讀取,由 Arduino 解碼并顯示在串行監(jiān)視器中。對于遙控器溫度的每次變化,您將獲得不同的數(shù)據(jù)。保存此數(shù)據(jù),以便我們將在主程序中使用它。您的串行監(jiān)視器將看起來像這樣,我還顯示了保存復(fù)制數(shù)據(jù)的Word文件。
屏幕截圖顯示了將我的交流遙控器的溫度設(shè)置為 26°C 的代碼。根據(jù)您的遙控器,您將獲得一組不同的代碼。同樣,復(fù)制所有不同溫度水平的代碼。
主要Arduino程序:
完整的Arduino主程序可以在此頁面底部找到,但您不能使用相同的程序。您必須更改我們剛剛從上面的示例草圖中獲得的信號代碼值。打開Arduino IDE上的主程序,然后向下滾動到下面顯示的該區(qū)域,您必須將數(shù)組值替換為為遙控器獲得的值。
請注意,我使用了 10 個陣列,其中兩個用于打開和關(guān)閉交流電,而其余 8 個用于設(shè)置不同的溫度。例如,Temp23 用于在交流電上設(shè)置 23°C,因此請使用該陣列中的相應(yīng)代碼。完成后,您只需將代碼上傳到Arduino并將其放在AC對面,即可享受涼風(fēng)。
代碼的解釋如下,首先我們必須使用DHT1溫度傳感器讀取溫度和濕度并將其顯示在OLED上。這是通過以下代碼完成的。
DHT.read11(DHT11_PIN); //Read the Temp and Humidity
Measured_temp = DHT.temperature + temp_error;
Measured_Humi = DHT.humidity;
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print("Temperature: "); display.print(Measured_temp);display.println("C");
display.setCursor(0,10);
display.print("Humidity: "); display.print(Measured_Humi);display.println("%");
一旦我們知道房間的溫度,我們只需要將其與所需的值進(jìn)行比較。這個期望值是一個常量值,在我的程序中設(shè)置為 27°C(攝氏度)。因此,基于此比較,我們將設(shè)置相應(yīng)的交流溫度,如下所示
if (Measured_temp == Desired_temperature+3) //If AC is ON and measured temp is very high than desired
{
irsend.sendRaw(Temp24, sizeof(Temp24) / sizeof(Temp24[0]), khz); delay(2000);//Send signal to set 24*C
AC_Temp = 24;
}
當(dāng)測量溫度為 30°C 時,此處的 AC 將設(shè)置為 24°C(因為所需溫度為 27)。同樣,我們可以創(chuàng)建許多 If 循環(huán),以根據(jù)測量的溫度設(shè)置不同的溫度級別,如下所示。
if (Measured_temp == Desired_temperature-1) //If AC is ON and measured temp is low than desired value
{
irsend.sendRaw(Temp28, sizeof(Temp28) / sizeof(Temp28[0]), khz); delay(2000);//Send signal to set 28*C
AC_Temp = 28;
}
if (Measured_temp == Desired_temperature-2 ) //If AC is ON and measured temp is very low than desired value
{
irsend.sendRaw(Temp29, sizeof(Temp29) / sizeof(Temp29[0]), khz); delay(2000);//Send signal to set 29*C
AC_Temp = 29;
}
if (Measured_temp == Desired_temperature-3 ) //If AC is ON and measured temp is very very low desired value
{
irsend.sendRaw(Temp30, sizeof(Temp30) / sizeof(Temp30[0]), khz); delay(2000);//Send signal to set 30*C
AC_Temp = 30;
}
自動交流溫控系統(tǒng)工作原理:
當(dāng)您的代碼和硬件準(zhǔn)備就緒時,將代碼上傳到您的主板,您應(yīng)該注意到 OLED 顯示與此類似的內(nèi)容。
現(xiàn)在將電路放在空調(diào)的對面,您會注意到空調(diào)的溫度會根據(jù)室溫進(jìn)行控制。
您可以調(diào)整程序以執(zhí)行任何所需的操作;您所需要的只是從示例草圖中獲取的代碼。希望您了解這個自動溫度控制器項目,并喜歡構(gòu)建非常相似的東西。
/*
* Automatic AC Temperature control using Arduino and TSOP
* Code by: Aswinth Raj B
* Dated: 25-10-2017
* Website: www.circuitdigest.com
*
S.No: Component Pin Arduino Pin
1 OLED – Vcc 5V
2 OLED – Gnd Gnd
3 OLED- SCK, D0,SCL,CLK 4
4 OLED- SDA, D1,MOSI, Data 3
5 OLED- RES, RST,RESET 7
6 OLED- DC, A0 5
7 OLED- CS, Chip Select 6
8 DHT11 – Vcc 5V
9 DHT11 – Gnd Gnd
10 DHT11 – Signal 13
11 TSOP – Vcc 5V
12 TSOP – Gnd Gnd
13 IR Led – Anode 9
14 IR Led – Cathode Gnd
*/
#include //Lib for IT Blaster and TSOP
#include // Inbuilt Lib
#include //Inbuilt Lib
#include //Lib for OLED
#include //Lib for OLED
#include //Library for dht11 Temperature and Humidity sensor (Download from Link in article)
// Assign pins for OLED (Software config.)
#define OLED_MOSI 3
#define OLED_CLK 4
#define OLED_DC 5
#define OLED_CS 6
#define OLED_RESET 7
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
#define SSD1306_LCDHEIGHT 64 //Change if you are using a Different OLED
#define DHT11_PIN 13 //Sensor output pin is connected to pin 13
dht DHT; //Sensor object named as DHT
#define Desired_temperature 27 //The desired temperature is 27*C at any time
//Decoded Remote Signals For my AC ##CHANGE IT FOR YOUR REMOTE
unsigned int ACoff[] = {2950,1750, 400,1100, 450,1050, 450,400, 400,400, 400,400, 450,1100, 400,400, 400,400, 450,1100, 400,1100, 450,350, 450,1100, 400,400, 400,400, 450,1100, 400,1100, 450,400, 400,1100, 400,1100, 450,400, 400,400, 400,1100, 450,350, 450,400, 400,1100, 450,400, 400,400, 400,400, 450,350, 450,350, 450,400, 400,400, 450,350, 450,400, 400,400, 400,400, 450,350, 450,400, 400,400, 400,400, 450,400, 400,400, 400,400, 450,350, 450,350, 450,1100, 400,400, 450,400, 400,1100, 450,1050, 450,400, 400,400, 400,400, 450,350, 450,400, 400,400, 450,350, 450,400, 400,400, 400,1100, 450,350, 450,400, 400,400, 400,400, 450,400, 400,1100, 450,350, 450,400, 400,400, 400,400, 400,1100, 450,400, 400,400, 450,350, 450,400, 400,400, 400,400, 450,350, 450,350, 450,400, 400,400, 450,350, 450,400, 400,400, 400,400, 450,350, 450,400, 400,400, 450,350, 450,400, 400,400, 400,400, 450,350, 450,350, 450,400, 450,350, 450,350, 450,400, 450,350, 450,350, 450,350, 450,400, 450,350, 450,350, 450,400, 400,1100, 450,350, 450,350, 450,400, 450,350, 450,350, 450,1100, 450};
unsigned int ACon[] = {2950,1700, 450,1100, 400,1100, 450,350, 450,350, 450,400, 450,1050, 450,350, 450,400, 450,1050, 450,1100, 400,400, 450,1050, 450,350, 450,400, 400,1100, 450,1100, 450,350, 450,1050, 450,1100, 450,350, 450,350, 450,1100, 450,350, 400,400, 450,1100, 450,350, 450,350, 450,400, 400,400, 450,350, 450,350, 450,400, 400,400, 450,350, 450,350, 450,400, 400,400, 450,350, 450,350, 450,400, 450,350, 450,350, 450,1100, 400,400, 450,350, 450,1100, 400,400, 450,350, 450,1100, 400,1100, 450,350, 450,400, 400,400, 450,350, 500,300, 450,400, 450,350, 400,400, 450,1100, 400,400, 450,350, 450,350, 450,400, 400,400, 450,350, 450,1100, 450,350, 400,400, 450,350, 450,400, 450,350, 400,400, 450,400, 450,350, 450,350, 450,350, 450,400, 400,400, 450,350, 450,400, 400,400, 400,400, 400,400, 450,350, 450,400, 450,350, 450,350, 450,400, 450,350, 450,350, 450,350, 450,400, 400,400, 400,400, 450,350, 450,400, 450,350, 400,400, 450,350, 450,400, 450,350, 450,350, 450,350, 450,400, 450,350, 450,1100, 400,400, 400,400, 450,350, 450,350, 450,1100, 400,400, 450};
unsigned int Temp23[] = {3000,1650, 550,950, 550,1000, 500,300, 550,250, 550,250, 550,1000, 500,300, 550,300, 500,1000, 550,950, 550,300, 550,950, 550,250, 550,300, 500,1000, 500,1050, 500,300, 500,1000, 550,1000, 500,300, 500,300, 550,1000, 450,350, 500,300, 500,1050, 450,350, 450,350, 450,350, 450,400, 450,350, 450,350, 450,400, 400,400, 450,350, 450,350, 450,350, 450,400, 400,400, 400,400, 450,400, 400,400, 400,400, 450,1100, 400,400, 400,400, 450,1050, 450,400, 400,400, 450,1100, 400,1100, 400,400, 450,350, 450,400, 400,400, 400,400, 450,400, 400,400, 400,400, 450,350, 450,1100, 400,400, 400,400, 450,350, 450,400, 400,400, 450,1100, 400,400, 400,1100, 450,1100, 400,1100, 450,350, 450,400, 400,400, 450,350, 450,350, 450,400, 400,400, 400,400, 450,350, 450,400, 400,400, 450,350, 450,400, 400,400, 400,400, 450,350, 450,400, 400,400, 450,350, 450,350, 450,400, 450,350, 400,400, 450,350, 450,400, 450,350, 450,350, 450,400, 450,350, 450,350, 450,350, 450,400, 400,400, 400,400, 450,350, 450,1100, 400,1100, 450,1100, 400,1100, 450,1100, 400,1100, 400,400, 450};
unsigned int Temp24[] = {3000,1650, 500,1050, 500,1000, 500,300, 500,300, 500,350, 500,1000, 500,300, 500,350, 500,1000, 500,1050, 500,300, 500,1000, 500,300, 500,350, 500,1000, 500,1050, 500,300, 500,1000, 500,1050, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,1050, 500,1000, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,1000, 500,1050, 500,1000, 500,300, 500,350, 450,350, 500,300, 500,300, 500,350, 500,1000, 500,300, 500,1050, 500,1000, 500,1050, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,300, 500,350, 500,300, 450,350, 500,350, 450,350, 450,350, 450,350, 450,400, 400,400, 400,400, 450,400, 400,400, 400,400, 400,400, 450,350, 450,400, 400,400, 450,350, 450,400, 450,350, 450,350, 450,350, 450,400, 450,350, 450,350, 450,350, 500,350, 450,1050, 500,300, 500,1050, 500,1000, 500,1050, 500,1000, 500,1000, 500,350, 550};
unsigned int Temp25[] = {3050,1650, 500,1000, 550,950, 550,300, 500,300, 500,300, 550,1000, 500,300, 500,300, 550,1000, 550,950, 550,250, 550,1000, 500,300, 550,250, 550,1000, 500,1000, 550,300, 550,950, 550,950, 550,300, 500,300, 500,1000, 550,250, 550,300, 550,950, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,250, 600,250, 500,300, 550,250, 550,250, 550,300, 550,250, 500,300, 550,300, 500,300, 500,1000, 550,250, 550,300, 500,1000, 550,250, 550,300, 500,1000, 550,1000, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,1000, 550,950, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,950, 550,300, 500,1000, 550,1000, 500,1000, 500,300, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,250, 550,300, 550,250, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 500,350, 500,1000, 500,1000, 500,1050, 500,1000, 500,1050, 500,300, 550};
unsigned int Temp26[] = {3000,1650, 500,1000, 500,1050, 500,300, 500,300, 500,350, 500,1000, 500,300, 500,350, 500,1000, 500,1050, 450,350, 500,1000, 500,300, 500,350, 500,1000, 500,1050, 500,300, 500,1000, 500,1050, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,1050, 500,300, 500,300, 500,1050, 450,350, 500,300, 500,1050, 500,1000, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,1000, 500,300, 500,1050, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,1050, 500,300, 500,1050, 450,1050, 500,1000, 500,350, 500,300, 500,300, 500,350, 450,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 450,350, 500,300, 500,350, 450,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,350, 500,300, 500,300, 500,300, 500,350, 500,300, 500,300, 500,350, 450,1050, 500,1000, 500,350, 500,1000, 500,1000, 500,1050, 500,1000, 500,350, 500};
unsigned int Temp27[] = {3050,1600, 550,1000, 500,1000, 550,300, 500,300, 550,250, 550,1000, 500,300, 550,300, 500,1000, 550,1000, 500,300, 550,1000, 550,250, 500,300, 550,1000, 500,1050, 500,300, 500,1000, 550,1000, 500,300, 550,250, 550,1000, 550,250, 550,300, 500,1000, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,300, 500,300, 500,1000, 550,300, 500,300, 550,1000, 500,300, 500,300, 550,1000, 550,1000, 500,300, 500,300, 550,250, 550,300, 500,300, 550,300, 500,300, 500,300, 550,1000, 500,300, 550,250, 550,300, 500,300, 500,300, 500,350, 500,300, 550,250, 550,1000, 500,1000, 550,1000, 500,300, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 500,300, 550,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 500,300, 500,350, 500,300, 500,350, 500,300, 500,300, 500,1050, 500,1000, 500,1050, 500,1000, 500,350, 500}; // PANASONIC C4D3:64800024
unsigned int Temp28[] = {3100,1600, 550,950, 550,1000, 550,250, 550,250, 550,250, 550,1000, 500,300, 500,300, 550,1000, 500,1000, 550,250, 550,1000, 500,300, 550,250, 550,1000, 550,950, 550,300, 500,1000, 550,950, 550,300, 550,250, 500,1000, 550,300, 500,300, 550,950, 550,300, 500,300, 500,300, 550,250, 550,300, 550,250, 500,300, 550,300, 500,300, 500,300, 550,250, 550,250, 600,250, 500,300, 500,300, 550,300, 500,300, 500,1000, 550,300, 500,300, 500,1000, 550,250, 550,300, 500,1000, 550,1000, 550,250, 550,250, 550,250, 550,300, 500,300, 550,250, 550,1000, 500,1000, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,1000, 500,300, 500,1000, 550,1000, 500,1000, 550,250, 550,300, 500,300, 550,250, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,300, 550,250, 500,300, 550,250, 550,250, 550,300, 550,250, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,250, 550,300, 500,300, 550,1000, 500,300, 500,300, 550,950, 550,1000, 500,1000, 550,1000, 500,300, 550};
unsigned int Temp29[] = {3100,1550, 600,950, 500,1000, 550,300, 500,300, 500,300, 550,950, 550,300, 550,250, 550,1000, 500,1000, 550,250, 550,1000, 500,300, 550,250, 550,950, 600,950, 550,250, 550,1000, 500,1000, 550,250, 600,250, 550,950, 550,250, 550,300, 550,950, 550,250, 550,300, 550,250, 550,250, 550,250, 550,300, 550,250, 550,250, 550,300, 500,300, 550,250, 550,250, 550,300, 500,300, 550,250, 550,250, 600,250, 550,950, 550,250, 550,300, 500,1000, 550,250, 550,300, 550,950, 550,1000, 500,300, 500,300, 550,250, 550,250, 550,300, 500,300, 550,250, 550,1000, 500,300, 550,250, 550,300, 500,300, 550,250, 550,250, 550,300, 500,1000, 550,250, 550,1000, 500,1000, 550,1000, 500,300, 500,300, 550,300, 500,300, 500,300, 550,250, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,250, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,250, 550,1000, 500,1000, 550,1000, 500,1000, 550,300, 500};
unsigned int Temp30[] = {3000,1650, 500,1000, 550,1000, 500,300, 500,300, 550,250, 550,1000, 500,300, 500,300, 550,1000, 550,950, 550,250, 550,1000, 550,250, 550,250, 550,1000, 550,950, 550,300, 500,1000, 550,950, 550,300, 500,300, 550,950, 550,300, 550,250, 550,1000, 500,300, 500,300, 550,250, 550,250, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,300, 500,300, 500,300, 550,950, 550,300, 500,300, 500,1000, 550,250, 550,300, 550,950, 550,1000, 500,300, 550,250, 550,250, 600,250, 500,300, 550,250, 550,1000, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,950, 550,300, 500,1000, 550,950, 550,1000, 500,300, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,250, 550,300, 500,300, 550,250, 550,300, 500,300, 500,300, 550,250, 550,300, 500,300, 550,950, 500,1050, 500,1000, 500,350, 500,1000, 500,1000, 500,1050, 500,300, 500};
//Change it for your remote
IRsend irsend;
int Measured_temp;
int Measured_Humi;
int AC_Temp;
char temp_error = 2;
int Pev_value;
boolean AC = false;
int khz = 38; // 38kHz carrier frequency for the NEC protocol
void setup()
{
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
}
void loop() {
DHT.read11(DHT11_PIN); //Read the Temp and Humidity
Measured_temp = DHT.temperature + temp_error;
Measured_Humi = DHT.humidity;
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print("Temperature: "); display.print(Measured_temp);display.println("C");
display.setCursor(0,10);
display.print("Humidity: "); display.print(Measured_Humi);display.println("%");
display.setCursor(0,20);
display.print("AC Temp: "); display.print(AC_Temp);display.println("C");
display.display();
delay(500);
display.clearDisplay();
if ((Measured_temp <= (Desired_temperature-3)) && AC == true) //If AC is turned on and temperature is less than 3 degree of Desired value #24 turn off?
{
irsend.sendRaw(ACoff, sizeof(ACoff) / sizeof(ACoff[0]), khz); delay(2000);//Send signal to Turn Off the AC
AC_Temp = 0; AC=false;
}
if ((Measured_temp >= Desired_temperature+4) && AC == false) //If AC is off and measured Temp is greater than Desired Temp
{
irsend.sendRaw(ACon, sizeof(ACon) / sizeof(ACon[0]), khz); delay(2000); //Send Signal to Turn On the AC
delay(2000);
irsend.sendRaw(Temp27, sizeof(Temp27) / sizeof(Temp27[0]), khz); //Send signal to set 27*C
AC_Temp = 27; AC=true;
}
if ( Measured_temp != Pev_value) //Change the temperature only if the measured voltage value changes
{
if (Measured_temp == Desired_temperature+3) //If AC is ON and measured temp is very very high than desired
{
irsend.sendRaw(Temp24, sizeof(Temp24) / sizeof(Temp24[0]), khz); delay(2000);//Send signal to set 24*C
AC_Temp = 24;
}
if (Measured_temp == Desired_temperature+2) //If AC is ON and measured temp is very high than desired
{
irsend.sendRaw(Temp25, sizeof(Temp25) / sizeof(Temp25[0]), khz); delay(2000);//Send signal to set 25*C
AC_Temp = 25;
}
if (Measured_temp == Desired_temperature+1) //If AC is ON and measured temp is very high than desired
{
irsend.sendRaw(Temp26, sizeof(Temp26) / sizeof(Temp26[0]), khz); delay(2000);//Send signal to set 26*C
AC_Temp = 26;
}
if (Measured_temp == 27 ) //If AC is ON and measured temp is desired value
{
irsend.sendRaw(Temp27, sizeof(Temp27) / sizeof(Temp27[0]), khz); //Send signal to set 27*C
AC_Temp = 27;
}
if (Measured_temp == Desired_temperature-1) //If AC is ON and measured temp is low than desired value
{
irsend.sendRaw(Temp28, sizeof(Temp28) / sizeof(Temp28[0]), khz); delay(2000);//Send signal to set 28*C
AC_Temp = 28;
}
if (Measured_temp == Desired_temperature-2 ) //If AC is ON and measured temp is very low than desired value
{
irsend.sendRaw(Temp29, sizeof(Temp29) / sizeof(Temp29[0]), khz); delay(2000);//Send signal to set 29*C
AC_Temp = 29;
}
if (Measured_temp == Desired_temperature-3 ) //If AC is ON and measured temp is very very low desired value
{
irsend.sendRaw(Temp30, sizeof(Temp30) / sizeof(Temp30[0]), khz); delay(2000);//Send signal to set 30*C
AC_Temp = 30;
}
}
Pev_value = Measured_temp;
}
-
紅外發(fā)射器
+關(guān)注
關(guān)注
0文章
46瀏覽量
16227 -
溫度控制器
+關(guān)注
關(guān)注
1文章
177瀏覽量
33816 -
Arduino
+關(guān)注
關(guān)注
188文章
6471瀏覽量
187293 -
DHT11
+關(guān)注
關(guān)注
19文章
277瀏覽量
57622
發(fā)布評論請先 登錄
相關(guān)推薦
評論