ããã«ã¡ã¯ãhabrozhiteliïŒ æ¯æ¥Habrãèªãã§ãArduinoãšããã«åºã¥ããDIYãããžã§ã¯ãã«é¢ããèšäºã«ç¹°ãè¿ãåºããããŸããã ãšã¬ã¯ãããã¯ã¹ãšã¯äœã®é¢ä¿ããªãããšã¯æ³šç®ã«å€ããŸããç§ã®çµéšã¯ãã¹ãŠã10代ã®ã¯ã©ããã¹ããŒã¯ãïŒãããã¶ãŽã©ãŒãã¯ïŒã«åºã¥ããã©ãžãªã¯ã©ãã蚪ããããšã§ãã ã²ãšãã³éãŸã£ãŠãã¹ããŒããã©ã³ïŒBTæ¥ç¶ïŒçšã®ã»ã³ãµãŒïŒæž©åºŠãå§åããã«ã¹ïŒãåããArduinoãã¬ã¹ã¬ãããäœãããšã«ããŸãããã泚ææã«ãšã©ãŒãç¯ããåŸãArduinoãšå§åã»ã³ãµãŒã®ã¿ãåãåããŸããã ããŒãããã¹ãããããã«ãLEDã®æå¯ãã®ç¡ç·ã³ã³ããŒãã³ãã¹ãã¢ã«è¡ããããã§ç£æ°ãã¢éã»ã³ãµãŒã§ç®ãåŒããŸããã 圌ã¯éšå±ã®ç掻ãå°ãæ¹åããããšãã§ããã ãããšããèããäžããŠãããŸããïŒã¢ããŒããšæ··åããªãããã«ïŒã æéãç¡é§ã«ããããšãªããç§ã¯ã¢ãªãšããããã®ã»ã³ãµãŒãšArduino Megaã泚æããŸããã
玳士çšã®ã»ã³ãµãŒã»ããïŒæž©åºŠã湿床ããªã¬ãŒãStarterKitãBTãæèšãã¬ã³ãžã¡ãŒã¿ãŒãIRã»ã³ãµãŒïŒã泚æããåŸãä»ã®äººãã©ã®ããã«ã¹ããŒãããŒã ã代衚ããããæ¢ãããšã«ããŸããã ã»ãšãã©ã¯ãã·ã£ã³ããªã¢ãšåºäžææ¿ã®å¶åŸ¡ã«éå®ãããŠããŸãããã æ¬åœã«ã¯ãŒã«ãªèšäºããããŸãã ã éšå±ã®ã¢ããŒãã«ãããµããæ©èœã®ããã€ãã¯åã«äžèŠã§ãããããšãã°ãã¬ã¹æŒããæŒãæ€åºåšãªã©ã§ãã ã¹ããŒãã«ãŒã ã§å¿ èŠãªæ©èœãèªåã§ã³ã³ãã€ã«ããããšã«ããŸããã
- 調å
- 枩床å¶åŸ¡
- å€ãã®æ¹æ³ã管çãã
- ãã¢å¶åŸ¡
- 枩床ç£èŠ
- æ°è±¡ç£èŠ
å¿ èŠãªã»ã³ãµãŒã¯ãã¹ãŠæ³šææžã¿ã§ãããåŸ ã€ããšããã§ããªãããšãå€æããŸããã ãããŠä»ããã¹ãŠã®ã»ã³ãµãŒãæ¥ãŸããïŒ
æåã®ã¹ããã
æ¢ã«LEDã§ç¹æ» ããã¹ããŒãããŒã ãæ§ç¯ããããšã«æ±ºããå Žåãéšå±ã®æãããç¹æ» ãããããšã¯è«ççãªã¹ãããã§ãããåæã®ç±ã«ãã枩床ãå¶åŸ¡ãå§ããŸããã ãŸããStarterKitaããdht11ãæ¥ç¶ããŠã¿ãŸããã ã€ã³ã¿ãŒãããã«æ瀺ãããããããå Žåãäœãããç°¡åã«ãªãã§ããããïŒ å€æããããã«ãdht11ãæ¥ç¶ããããã®å€ãã®ã©ã€ãã©ãªãããããããã®ãã¹ãŠãIDEã®ææ°ããŒãžã§ã³ãšäºææ§ãããããã§ã¯ãããŸããããæ°æéåŸã«ã³ã³ãœãŒã«ã«è¡šç€ºããã枩床ãè³è³ããæ°ååŸã«ã¯ããã«å¿ããŠLEDãç¹æ» ããŸãã ïŒã»ã³ãµãŒããªãã«ããå·èµåº«ã«å ¥ããå·èµåº«ããåãåºããæ¥ç¶ããŸã...ïŒ
æåã®åé¡ã¯ãéžæããdht11ã®ç²ŸåºŠãäœãããšã§ãããäž¡æ¹åã«2ã3床暪ããã£ãŠããããã亀æããå¿ èŠããããŸããïŒãã®åŸãããã€ãã®ããŒãžã§ã³ã§ã»ã³ãµãŒã泚æããããšããŸããïŒã
ããããç§ã¯LeroyMerlinã«è¡ããããã§æãç°¡åãªãã¡ã³ãè³Œå ¥ããŸãã ã ã¯ã€ã€ãšãã©ã°ã§æ°åééšãç«ãŠãåŸããã¡ã³ãçµã¿ç«ãŠãããŸããã é£äººãšäžç·ã«ã圌ãã¯çªãåãå€ããŠã空ããŠããå Žæã«ãããèšçœ®ããŸããïŒé£äººã§ã¯ãªããã¡ã³ïŒã ãã©ã°ããœã±ããã«å·®ã蟌ã¿ã...ãã¡ã³ãå転ãå§ããŸããã ãã£ããã ãšãŠãé ãã
èšããŸã§ããªãããã©ã°ã誀ã£ãŠåãä»ãããã¡ã³ã颚ããå転ããŸãããïŒ
ãã¡ãããæåã§ã®é»æºãªããå¯èœã§ãã ãããããªã¬ãŒãä»ããŠãã¡ã³ãå¶åŸ¡ããæè¯ã®æ¹æ³ã¯äœã§ããïŒ ãã¡ã³ã«çŽæ¥æ¥ç¶ããŸããïŒ ã³ã³ã»ã³ããä»ããŠãã¡ã³ããªã¬ãŒã«æ¥ç¶ããããšã«ããŸãããããã«ãããã·ã¹ãã ã«æè»æ§ãäžããããŸãïŒãã¡ã³ãå¥ã®ãã®ã«äº€æã§ããŸãïŒã
ææ°è©Šéš
ãããŠãããã§ã³ãŒãã¯LEDãããªã¬ãŒã«æžãæããããŸãã ãã¡ãŒã ãŠã§ã¢ãèªã¿èŸŒãŸããå¿ èŠãªéå§ãèŠè¶ããŠæž©åºŠãç£èŠããŸã-ããã§ãã®ç¬éã§ãïŒ ãªã¬ãŒãã¯ãªãã¯ãããCOMããŒããæ¶ããŸãã ã©ããããåãæ¿ãæã«ãUSBã®è² è·ãå¢å ããããŒã¿ãå¹²æžããŸãã æåã¯220Vã¯ã€ã€ããã®å¹²æžã«ãããã®ã ãšæã£ãŠããŸããããããŒãããååãªè·é¢ã«ãããŸãã ãã®åŸãããã«ããå€ãã®åé¡ãçºçããŸãããæ°ããã¹ã±ãããã¢ããããŒãããããšãããšãArduinoãåèµ·åãããªã¬ãŒãåãæ¿ããŠãCOMããŒããåé€ãããããæŽæ°ããã»ã¹ãçºçããŸãã ç§ã¯ãã®åé¡ãå æã§ããŸããã§ããã
ãªã¢ã³ã³
ãã¡ããããã¡ã³ã®çµ¶ãéãªãåäœã¯ããã«éå±ããã¹ã€ãããä»ããŠãã¡ã³ããªãã«ããããšã¯ã¯ãŒã«ã§ã¯ãããŸããã§ããïŒ ããã§ãããããã¹ã¿ãŒã¿ãŒããããšãªã¢ã³ã³ãåãåºããŸããã å®éããã®ç¬éããåé¡ãå§ãŸããŸãããåä¿¡æ©ãã©ã®ããã«èŠãããããããŸããã§ããã ããããæ°åéã®ã°ãŒã°ã«æ€çŽ¢ã§ãããèŠã€ããããšãã§ããããã«1æéåŸããªã¢ãŒãã³ã³ãããŒã«ãããã¡ã³ãå¶åŸ¡ããã®ã楜ãããªããŸããã
æåã¯ããã€ãã®ãã©ã°ãæã€è€éãªã¢ã«ãŽãªãºã ã§ããããæçµçã«ã¯å°ããªãã®ã«ãªããŸãã
ã¿ã€ããŒã¢ã«ãŽãªãºã
IfïŒã·ã°ãã«ãæ¥ãïŒ{
manual_time = 1800;
fan_mode =ïŒ fan_mode;
}
IfïŒmanual_timeïŒ= 0ïŒ{
manual_time--;
}ãã以å€ã®å Žå{
IfïŒæž©åºŠ<26ïŒ{
fan_mode = false;
}ãã以å€ã®å Žå{
fan_mode = true;
}
}
manual_time = 1800;
fan_mode =ïŒ fan_mode;
}
IfïŒmanual_timeïŒ= 0ïŒ{
manual_time--;
}ãã以å€ã®å Žå{
IfïŒæž©åºŠ<26ïŒ{
fan_mode = false;
}ãã以å€ã®å Žå{
fan_mode = true;
}
}
ããããããã§ã¯åé¡ããªãã£ãããã§ã¯ãããŸãããã¯ã€ã€ãæŽæ°ãã5VãDATAã«å°å ãããšãããã«ã¬ã·ãŒãã倱ãããŸããã ããã«ããç§ã¯æ¬¡ã®ã¹ãããã«é²ã¿ãŸãã...
BTã¢ãžã¥ãŒã«ã«ãã管ç
ããã«ãHC-06 BTã¢ãžã¥ãŒã«ãæ¥ç¶ããããã«åºåããªãã€ã¬ã¯ãããã³ãã³ãèªã¿åããè¿œå ããŸããã ãã£ãšé£ãããšæã£ãããrobocraftã®èšäºã®ãããã ã
å€æãã
é£äººãšãã¡ã³
ã¹ããŒããã©ã³ããã·ã¹ãã ãå¶åŸ¡ããæ¹æ³ãé£äººã«æããããšã§ããã¡ãã£ãšãå¯ãããšããåé¡ã解決ã§ãããšæããŸããã...ã¹ã€ããã§ãã¡ã³ã®é»æºãåãããšãã§ããã°ãçªãéããã®ã¯å€¢äžã«ãªããŸãã ãªãã§ïŒ ãã¡ã³ã¯æ°ã»ã³ãã®è·é¢ã§ã¬ã©ã¹ã«å¹ã蟌ã¿ãã²ã©ãããæžã£ãã 幞ããªããšã«ãç§ã¯ç£æ°ã»ã³ãµãŒãæ£ãã°ã£ãŠããã®ã§ãã·ã¹ãã ãäœæããããã«ä¿ãããŸããã éããã»ã³ãµãŒã¯ããã¡ã³ããªã³ã«ã§ããªãããšãArduinoã«éç¥ããŸãã æ²ããããªãæã å¹²æžããã£ãã®ã§ãç§ã¯ç°¡åãªãã§ãã¯ãããªããã°ãªããŸããã§ããïŒè¿ãä¿¡å·ãé£ç¶ããŠæ°åæ¥ãå Žå-ãŠã£ã³ããŠã¯æ¬åœã«éããŠããŸãã
調å
ããã§ãã©ã€ããå¶åŸ¡ããããšãã§ããŸããã ãã¡ã³ã®åŸãè€éãªãã®ã¯äœããããŸããïŒããã¯ã¹ãäžå¯Ÿã®ç«¯åãããã¯-ãããŠãå ã¯ãã§ã«Arduinoã«ãã£ãŠãã§ã«å¶åŸ¡ãããŠããŸãïŒãã¡ãããå€ãã¹ã€ããã§ãªãã«ããæ©èœããããŸãïŒã å¯äžå¿é ãªã®ã¯ã ãªã¬ãŒãé»çãå¶åŸ¡ããæè¯ã®æ¹æ³ã§ã¯ãªããšããããšã§ãã
é³ã®åé¡
ããŠãå©ããªãã§èª¿å ãšã¯äœã§ããïŒ ãã€ã¯ã泚æããŸããã ã ããç§ã¯æã£ã...æªçµéšãèŠããŠããŸããïŒ å®éãæåã§ãããå€ãèšå®ãããµãŠã³ããã£ãã¯ã¿ãŒã泚æããŸããã ããã¯ç§ã®ç®çã«é©ããŠããããã§ããïŒ ããããããã€ãã®ããããããçŸããŸããã
- çè·é¢ïŒãããã¯æ°åã»ã³ãããã®ã¿åŠçãããŸã
- çãä¿¡å·é ä¿¡æéïŒé·ãã³ãŒãå®è¡æéã§ã¯ãã»ã³ãµãŒããã®ä¿¡å·ã«Arduinoãä¿®æ£ããæéããããŸããã§ãã
ã³ã³ãœãŒã«ãªã¿ãŒã³
å°ãã°ãŒã°ã«ã§åºã«è¡ããšãçãå°œããVS1838Bã®ä»£ããã«ãããä¿¡é Œæ§ã®é«ãTSOP1836ãè³Œå ¥ããŸããã ä»åã¯ã€ã³ã¹ããŒã«ãæåãããã¹ãŠãããã«æ©èœããŸããã
éãã«åºã
ç§ã¯çªãç解ããŸãããããã®èåŸã«ã¯äœããããŸããïŒ ã¯ãã ããŠã§æŠè£ ããéšã»ã³ãµãŒãšå¥ã®dht11ã5ã¡ãŒãã«ã®VGAã±ãŒãã«ã«ã¯ãã ä»ãããŸããã ããã€ãã®Uååã®çãå ·ãé»ãé»æ°ããŒããã³ã±ãããã³ã·ã¹ãã ã¯èŠåãçºããŸãã
ãŸãããã·ã¢èªã®ããã¹ãã衚瀺ã§ããããšãåŠã³ãŸããã
ã«ãªã£ãŠããŸã
å°ã䟿å©
ã¹ããŒããã©ã³ã¯åžžã«æå ã«ããããã«èŠããŸããããããèŠã€ãããŸã§æ¥ç¶ããŠãã ãã...ã¹ã€ãããä»ããŠã©ã€ãããã¡ã³ããªãã«ããæ¹ãéãå ŽåããããŸãããããã«ããArduinoçµç±ã®å¶åŸ¡ãäžå¯èœã«ãªããŸãïŒãã«ã¹ãªã¬ãŒã¯é«äŸ¡ãããïŒã®ã§ã2ã€ã®æ®éã®ãã¿ã³ãè¿œå ããŸããã
ã¡ãã£ãšããã»ãã¥ãªãã£
寮ã®æè¡è ã«ç«çœèŠå ±åšããªãå Žæã¯ã©ãã§ããïŒ çµéšã®æµ ãç§ã¯ç ã§ã¯ãªããç«çœæ¢ç¥æ©ãè³Œå ¥ããŸããã 30 cmãŸã§ã®è·é¢ã§çããŠãããããã決å®ããããšã¯ããã¡ããã¯ãŒã«ã§ãããååã§ã¯ãããŸããã ãããã£ãŠããããŸã§ã®ãšããç§ã¯ãããªãã§ãã£ãã
ãã¹ãã«ã®ç«çœèŠå ±åšãšããã°......
- æã«ã¯ãµã€ã¬ã³ãã¬ã©ã¬ã©ãšé³Žãã¹ããŒã«ãŒ
- ããŒã«ã«ç æ¢ç¥æ©
- ãããã¯ãŒã¯ç æ¢ç¥åšïŒã³ã³ãããŒã«ããã«ã«æ¥ç¶ïŒ
äžè¬çãªãã¥ãŒ
ã³ã³ãã¥ãŒã¿ã±ãŒã¹ãžã®é 眮ã«ã¯ãç絡ãåŒãèµ·ããèœåãšãã倧ããªæ¬ ç¹ããããŸãã ãã®ãããããŒãã¯ãŸããªãå人ã®æ£ã«ç§»åãã段ããŒã«ã®ä»£ããã«HDDã®ã±ãŒã¹ããä»®ã®ã±ãŒã¹ããããŸãã
ã¹ã±ããã³ãŒã
çŸç¶
#include <IRremote.h>
#include <IRremoteInt.h>
#include <DS1302.h>
#include <DHT.h>
#define DHT_PIN 2 //枩床èšã®ãã³...
#define DHT2_PIN 52 //è¡è·¯æž©åºŠèšã®ãã³...
#define RAIN_PIN 53 //éšã»ã³ãµãŒã®ãã³
#define RECV_PIN 3 // IRã¬ã·ãŒããŒãæ¥ç¶ãããã³
#define FAN_PIN 4 //ãªã¬ãŒæ¥ç¶ãã³
#define LAMP_PIN 5 //ãªã¬ãŒæ¥ç¶ãã³
#define SOUND_PIN A0 //ãã€ã¯æ¥ç¶ãã³
#define WINDOW_PIN A1 //ãŠã£ã³ããŠãã³
#define LAMP_BUT_PIN 50 //ãã€ã¯æ¥ç¶ãã³
#define FAN_BUT_PIN 51 //ãŠã£ã³ããŠãã³
#define DHTTYPE DHT11
#define TIMER_FAN 0
#define TIMER_WINDOW 1
IRrecv irrecvïŒRECV_PINïŒ;
decode_resultsçµæ;
intã¿ã€ããŒ[2];
bool FAN_FLAG = false;
bool LAMP_FLAG = true;
int WINDOW_VAL = 0;
bool WINDOW_OPEN = false;
bool WINDOW_FLAG = false;
bool RAIN_FLAG = false;
char incomingByte;
DHT dhtïŒDHT_PINãDHTTYPEïŒ;
DHT dht2ïŒDHT2_PINãDHTTYPEïŒ;
DS1302 rtcïŒ49ã46ã48ïŒ;
void setupïŒïŒ{
Serial1.beginïŒ9600ïŒ;
rtc.haltïŒfalseïŒ;
rtc.writeProtectïŒfalseïŒ;
//rtc.setDOW(SUNDAYïŒ; //ææ¥ãéææ¥ã«èšå®ããŸã
//rtc.setTime(0ã37ã40ïŒ; //æéã0:37:00ã«èšå®ããŸãïŒ24æé圢åŒïŒ
//rtc.setDate(25ã5ã2014ïŒ; //æ¥ä»ã5æ25æ¥ã«èšå®ããŸã
ã¿ã€ããŒ[TIMER_FAN] = 0;
ã¿ã€ããŒ[TIMER_WINDOW] = 0;
pinModeïŒRAIN_PINãINPUTïŒ;
pinModeïŒLAMP_BUT_PINãINPUTïŒ;
pinModeïŒFAN_BUT_PINãINPUTïŒ;
pinModeïŒFAN_PINãOUTPUTïŒ;
pinModeïŒLAMP_PINãOUTPUTïŒ;
digitalWriteïŒFAN_PINãLOWïŒ;
irrecv.enableIRInïŒïŒ; //ã¬ã·ãŒããŒããªã³ã«ããŸã
dht.beginïŒïŒ;
dht2.beginïŒïŒ;
}
intããªã¥ãŒã ;
void loopïŒïŒ{
WINDOW_VAL = analogReadïŒWINDOW_PINïŒ; //ç£æ°ã»ã³ãµãŒ
ifïŒWINDOW_VAL> 950ïŒ{
ifïŒWINDOW_FLAGïŒ{
ã¿ã€ããŒ[TIMER_WINDOW] ++;
ifïŒã¿ã€ããŒ[TIMER_WINDOW]> 10ïŒ{
WINDOW_OPEN = false;
}
} else {
WINDOW_FLAG = true;
}
} else {
WINDOW_OPEN = true;
WINDOW_FLAG = false;
ã¿ã€ããŒ[TIMER_WINDOW] = 0;
}
ifïŒdigitalReadïŒRAIN_PINïŒ== HIGHïŒ{
RAIN_FLAG = true;
} else {
RAIN_FLAG = false;
}
ããªã¥ãŒã = analogReadïŒSOUND_PINïŒ;
ifïŒvolume <40ïŒ{
LAMP_FLAG =ïŒLAMP_FLAG;
}
ifïŒdigitalReadïŒLAMP_BUT_PINïŒ== HIGHïŒ{
input_signalïŒ1ïŒ;
}
ifïŒdigitalReadïŒFAN_BUT_PINïŒ== HIGHïŒ{
input_signalïŒ0ïŒ;
}
ifïŒirrecv.decodeïŒïŒçµæïŒïŒ
{
ifïŒresults.value == 16750695ïŒ//ãã¿ã³ã³ãŒã
{
input_signalïŒ0ïŒ;
}
ifïŒresults.value == 16756815ïŒ//ãã¿ã³ã³ãŒã
{
input_signalïŒ1ïŒ;
}
irrecv.resumeïŒïŒ; //次ã®å€ãååŸããŸã
}
//Serial.println(rtc.getTime().hourïŒ;
//Serial.println(rtc.getTime().minïŒ;
Serial1.printïŒrtc.getDOWStrïŒïŒïŒ;
Serial1.printïŒ ""ïŒ;
Serial1.printïŒrtc.getDateStrïŒïŒïŒ;
Serial1.printïŒ "-"ïŒ;
Serial1.printlnïŒrtc.getTimeStrïŒïŒïŒ;
ifïŒSerial1.availableïŒïŒ> 0ïŒ{
incomingByte = Serial1.readïŒïŒ;
ifïŒincomingByte == '0'ïŒ{
Serial1.printlnïŒãæåã¢ãŒãç¡å¹ãïŒ;
input_signalïŒ0ïŒ;
} else ifïŒincomingByte == '1'ïŒ{
Serial1.printlnïŒãæåã¢ãŒããã¢ã¯ãã£ãåãïŒ;
input_signalïŒ0ïŒ;
} else ifïŒincomingByte == '2'ïŒ{
input_signalïŒ1ïŒ;
}
}
float h = dht.readHumidityïŒïŒ;
float t = dht.readTemperatureïŒïŒ;
ifïŒisnanïŒtïŒ|| isnanïŒhïŒïŒ{
Serial1.printlnïŒãå éšæž©åºŠèšããã®èªã¿åããšã©ãŒãïŒ;
} else {
ifïŒã¿ã€ããŒ[TIMER_FAN] <= 0ïŒ{
ifïŒt <26ïŒ{
FAN_FLAG = false;
} else ifïŒt> 26ïŒ{
FAN_FLAG = true;
}
} else {
ã¿ã€ããŒ[TIMER_FAN]-;
}
Serial1.printïŒâ湿床ïŒâïŒ;
Serial1.printïŒhïŒ;
Serial1.printlnïŒ "ïŒ \ t"ïŒ;
Serial1.printïŒâ枩床ïŒâïŒ;
Serial1.printïŒtïŒ;
Serial1.printlnïŒâ * CâïŒ;
}
ifïŒã¿ã€ããŒ[TIMER_FAN]> 0ïŒ{
Serial1.printïŒãæåã¢ãŒãã¯ãã®ãŸãŸã§ãïŒâïŒ;
Serial1.printïŒã¿ã€ããŒ[TIMER_FAN]ïŒ;
Serial1.printlnïŒãç§ãïŒ;
} else {
Serial1.printlnïŒãæåã¢ãŒããªããïŒ;
}
ifïŒFAN_FLAG && WINDOW_OPENïŒ{
digitalWriteïŒFAN_PINãHIGHïŒ;
Serial1.printlnïŒããã¡ã³ãªã³ãïŒ;
} else {
digitalWriteïŒFAN_PINãLOWïŒ;
Serial1.printlnïŒããã¡ã³ãªããïŒ;
}
ifïŒWINDOW_OPENïŒ{
Serial1.printlnïŒããŠã£ã³ããŠãéããŠããŸããïŒ;
} else {
Serial1.printlnïŒ "Window Closed"ïŒ;
}
ifïŒLAMP_FLAGïŒ{
digitalWriteïŒLAMP_PINãHIGHïŒ;
} else {
digitalWriteïŒLAMP_PINãLOWïŒ;
}
h = dht2.readHumidityïŒïŒ;
t = dht2.readTemperatureïŒïŒ;
Serial1.printlnïŒ "çªã®å€ïŒ"ïŒ;
ifïŒisnanïŒtïŒ|| isnanïŒhïŒïŒ{
Serial1.printlnïŒãè¡è·¯æž©åºŠèšããã®èªã¿åããšã©ãŒãïŒ;
} else {
Serial1.printïŒâ湿床ïŒâïŒ;
Serial1.printïŒhïŒ;
Serial1.printlnïŒ "ïŒ \ t"ïŒ;
Serial1.printïŒâ枩床ïŒâïŒ;
Serial1.printïŒtïŒ;
Serial1.printlnïŒâ * CâïŒ;
}
ifïŒRAIN_FLAGïŒ{
Serial1.printlnïŒãéšã¯éããªããïŒ;
} else {
Serial1.printlnïŒ "Rain"ïŒ;
}
Serial1.printlnïŒ "*****"ïŒ;
é 延ïŒ100ïŒ;
}
void input_signalïŒint signalïŒ{
ã¹ã€ããïŒä¿¡å·ïŒ{
ã±ãŒã¹0ïŒ
ifïŒrtc.getTimeïŒïŒãhour> 1 && rtc.getTimeïŒïŒãhour <8ïŒ{
ã¿ã€ããŒ[TIMER_FAN] = 1800;
} else {
ã¿ã€ããŒ[TIMER_FAN] = 18000;
}
FAN_FLAG =ïŒFAN_FLAG;
Serial1.printlnïŒããã¡ã³åãæ¿ããïŒ;
äŒæ©;
ã±ãŒã¹1ïŒ
LAMP_FLAG =ïŒLAMP_FLAG;
Serial1.printlnïŒãã©ã€ãã¹ã€ãããïŒ;
äŒæ©;
}
}
#include <IRremoteInt.h>
#include <DS1302.h>
#include <DHT.h>
#define DHT_PIN 2 //枩床èšã®ãã³...
#define DHT2_PIN 52 //è¡è·¯æž©åºŠèšã®ãã³...
#define RAIN_PIN 53 //éšã»ã³ãµãŒã®ãã³
#define RECV_PIN 3 // IRã¬ã·ãŒããŒãæ¥ç¶ãããã³
#define FAN_PIN 4 //ãªã¬ãŒæ¥ç¶ãã³
#define LAMP_PIN 5 //ãªã¬ãŒæ¥ç¶ãã³
#define SOUND_PIN A0 //ãã€ã¯æ¥ç¶ãã³
#define WINDOW_PIN A1 //ãŠã£ã³ããŠãã³
#define LAMP_BUT_PIN 50 //ãã€ã¯æ¥ç¶ãã³
#define FAN_BUT_PIN 51 //ãŠã£ã³ããŠãã³
#define DHTTYPE DHT11
#define TIMER_FAN 0
#define TIMER_WINDOW 1
IRrecv irrecvïŒRECV_PINïŒ;
decode_resultsçµæ;
intã¿ã€ããŒ[2];
bool FAN_FLAG = false;
bool LAMP_FLAG = true;
int WINDOW_VAL = 0;
bool WINDOW_OPEN = false;
bool WINDOW_FLAG = false;
bool RAIN_FLAG = false;
char incomingByte;
DHT dhtïŒDHT_PINãDHTTYPEïŒ;
DHT dht2ïŒDHT2_PINãDHTTYPEïŒ;
DS1302 rtcïŒ49ã46ã48ïŒ;
void setupïŒïŒ{
Serial1.beginïŒ9600ïŒ;
rtc.haltïŒfalseïŒ;
rtc.writeProtectïŒfalseïŒ;
//rtc.setDOW(SUNDAYïŒ; //ææ¥ãéææ¥ã«èšå®ããŸã
//rtc.setTime(0ã37ã40ïŒ; //æéã0:37:00ã«èšå®ããŸãïŒ24æé圢åŒïŒ
//rtc.setDate(25ã5ã2014ïŒ; //æ¥ä»ã5æ25æ¥ã«èšå®ããŸã
ã¿ã€ããŒ[TIMER_FAN] = 0;
ã¿ã€ããŒ[TIMER_WINDOW] = 0;
pinModeïŒRAIN_PINãINPUTïŒ;
pinModeïŒLAMP_BUT_PINãINPUTïŒ;
pinModeïŒFAN_BUT_PINãINPUTïŒ;
pinModeïŒFAN_PINãOUTPUTïŒ;
pinModeïŒLAMP_PINãOUTPUTïŒ;
digitalWriteïŒFAN_PINãLOWïŒ;
irrecv.enableIRInïŒïŒ; //ã¬ã·ãŒããŒããªã³ã«ããŸã
dht.beginïŒïŒ;
dht2.beginïŒïŒ;
}
intããªã¥ãŒã ;
void loopïŒïŒ{
WINDOW_VAL = analogReadïŒWINDOW_PINïŒ; //ç£æ°ã»ã³ãµãŒ
ifïŒWINDOW_VAL> 950ïŒ{
ifïŒWINDOW_FLAGïŒ{
ã¿ã€ããŒ[TIMER_WINDOW] ++;
ifïŒã¿ã€ããŒ[TIMER_WINDOW]> 10ïŒ{
WINDOW_OPEN = false;
}
} else {
WINDOW_FLAG = true;
}
} else {
WINDOW_OPEN = true;
WINDOW_FLAG = false;
ã¿ã€ããŒ[TIMER_WINDOW] = 0;
}
ifïŒdigitalReadïŒRAIN_PINïŒ== HIGHïŒ{
RAIN_FLAG = true;
} else {
RAIN_FLAG = false;
}
ããªã¥ãŒã = analogReadïŒSOUND_PINïŒ;
ifïŒvolume <40ïŒ{
LAMP_FLAG =ïŒLAMP_FLAG;
}
ifïŒdigitalReadïŒLAMP_BUT_PINïŒ== HIGHïŒ{
input_signalïŒ1ïŒ;
}
ifïŒdigitalReadïŒFAN_BUT_PINïŒ== HIGHïŒ{
input_signalïŒ0ïŒ;
}
ifïŒirrecv.decodeïŒïŒçµæïŒïŒ
{
ifïŒresults.value == 16750695ïŒ//ãã¿ã³ã³ãŒã
{
input_signalïŒ0ïŒ;
}
ifïŒresults.value == 16756815ïŒ//ãã¿ã³ã³ãŒã
{
input_signalïŒ1ïŒ;
}
irrecv.resumeïŒïŒ; //次ã®å€ãååŸããŸã
}
//Serial.println(rtc.getTime().hourïŒ;
//Serial.println(rtc.getTime().minïŒ;
Serial1.printïŒrtc.getDOWStrïŒïŒïŒ;
Serial1.printïŒ ""ïŒ;
Serial1.printïŒrtc.getDateStrïŒïŒïŒ;
Serial1.printïŒ "-"ïŒ;
Serial1.printlnïŒrtc.getTimeStrïŒïŒïŒ;
ifïŒSerial1.availableïŒïŒ> 0ïŒ{
incomingByte = Serial1.readïŒïŒ;
ifïŒincomingByte == '0'ïŒ{
Serial1.printlnïŒãæåã¢ãŒãç¡å¹ãïŒ;
input_signalïŒ0ïŒ;
} else ifïŒincomingByte == '1'ïŒ{
Serial1.printlnïŒãæåã¢ãŒããã¢ã¯ãã£ãåãïŒ;
input_signalïŒ0ïŒ;
} else ifïŒincomingByte == '2'ïŒ{
input_signalïŒ1ïŒ;
}
}
float h = dht.readHumidityïŒïŒ;
float t = dht.readTemperatureïŒïŒ;
ifïŒisnanïŒtïŒ|| isnanïŒhïŒïŒ{
Serial1.printlnïŒãå éšæž©åºŠèšããã®èªã¿åããšã©ãŒãïŒ;
} else {
ifïŒã¿ã€ããŒ[TIMER_FAN] <= 0ïŒ{
ifïŒt <26ïŒ{
FAN_FLAG = false;
} else ifïŒt> 26ïŒ{
FAN_FLAG = true;
}
} else {
ã¿ã€ããŒ[TIMER_FAN]-;
}
Serial1.printïŒâ湿床ïŒâïŒ;
Serial1.printïŒhïŒ;
Serial1.printlnïŒ "ïŒ \ t"ïŒ;
Serial1.printïŒâ枩床ïŒâïŒ;
Serial1.printïŒtïŒ;
Serial1.printlnïŒâ * CâïŒ;
}
ifïŒã¿ã€ããŒ[TIMER_FAN]> 0ïŒ{
Serial1.printïŒãæåã¢ãŒãã¯ãã®ãŸãŸã§ãïŒâïŒ;
Serial1.printïŒã¿ã€ããŒ[TIMER_FAN]ïŒ;
Serial1.printlnïŒãç§ãïŒ;
} else {
Serial1.printlnïŒãæåã¢ãŒããªããïŒ;
}
ifïŒFAN_FLAG && WINDOW_OPENïŒ{
digitalWriteïŒFAN_PINãHIGHïŒ;
Serial1.printlnïŒããã¡ã³ãªã³ãïŒ;
} else {
digitalWriteïŒFAN_PINãLOWïŒ;
Serial1.printlnïŒããã¡ã³ãªããïŒ;
}
ifïŒWINDOW_OPENïŒ{
Serial1.printlnïŒããŠã£ã³ããŠãéããŠããŸããïŒ;
} else {
Serial1.printlnïŒ "Window Closed"ïŒ;
}
ifïŒLAMP_FLAGïŒ{
digitalWriteïŒLAMP_PINãHIGHïŒ;
} else {
digitalWriteïŒLAMP_PINãLOWïŒ;
}
h = dht2.readHumidityïŒïŒ;
t = dht2.readTemperatureïŒïŒ;
Serial1.printlnïŒ "çªã®å€ïŒ"ïŒ;
ifïŒisnanïŒtïŒ|| isnanïŒhïŒïŒ{
Serial1.printlnïŒãè¡è·¯æž©åºŠèšããã®èªã¿åããšã©ãŒãïŒ;
} else {
Serial1.printïŒâ湿床ïŒâïŒ;
Serial1.printïŒhïŒ;
Serial1.printlnïŒ "ïŒ \ t"ïŒ;
Serial1.printïŒâ枩床ïŒâïŒ;
Serial1.printïŒtïŒ;
Serial1.printlnïŒâ * CâïŒ;
}
ifïŒRAIN_FLAGïŒ{
Serial1.printlnïŒãéšã¯éããªããïŒ;
} else {
Serial1.printlnïŒ "Rain"ïŒ;
}
Serial1.printlnïŒ "*****"ïŒ;
é 延ïŒ100ïŒ;
}
void input_signalïŒint signalïŒ{
ã¹ã€ããïŒä¿¡å·ïŒ{
ã±ãŒã¹0ïŒ
ifïŒrtc.getTimeïŒïŒãhour> 1 && rtc.getTimeïŒïŒãhour <8ïŒ{
ã¿ã€ããŒ[TIMER_FAN] = 1800;
} else {
ã¿ã€ããŒ[TIMER_FAN] = 18000;
}
FAN_FLAG =ïŒFAN_FLAG;
Serial1.printlnïŒããã¡ã³åãæ¿ããïŒ;
äŒæ©;
ã±ãŒã¹1ïŒ
LAMP_FLAG =ïŒLAMP_FLAG;
Serial1.printlnïŒãã©ã€ãã¹ã€ãããïŒ;
äŒæ©;
}
}
ã³ãŒãã倱æããå Žå
ç§ã¯éåžžéãããªã¬ãŒã䜿çšããŠããŸãã ã€ãŸããããã©ã«ãã§ã¯ãã¹ãŠããªã³ã«ãªã£ãŠããŸããArduinoããããã¯ãŒã¯ããåæããç°¡åãªã¹ã€ããã䜿çšã§ããŸãã
éçºèšç»
ç§ããªã¹ãããã®ã¯ãçã«ã¹ããŒããªéšå±ã®åºç€ã«ãããŸããã çµå±ã®ãšããã圌女ã®AIã¯ãã¹ãŠã枩床ã«å¿ããŠãã¡ã³ã®ãªã³ãšãªããåãæ¿ããŠããŸãã éšå±ãããå¿«é©ã§ãèªåŸçãªããã®ã«ããããã«ã次ã®ããšãèšç»ããŠããŸãã
ç®èŠãŸãæèš
ã·ã¹ãã ã«ã¯ããã¯ãè¿œå ãããšã次ã®ã¢ã©ãŒã ãé çªã«äžŠãã§ããŸãã ã·ã°ãã«ãšããŠããã€ããã«ãŒãç¹æ» ããã©ã€ãããã¡ã³ããªã³ã«ãªã£ãŠãããšæ³å®ããŠããŸãã ãããŠãã¡ãããå±å€ã§éšãéã£ãå Žåã¯æ©æã«ç®èŠããŸãïŒç§»åé床ã¯-10ã§ãïŒã
ãã®ãããªã¢ãžã¥ãŒã«ã䜿çšããŠãSDã«ãŒãã«ã¢ã©ãŒã ãä¿åããã·ã¹ãã ãè¿œå ããŸã ïŒåé»ã®å ŽåïŒã
ã³ã³ãã¥ãŒã¿ãŒããã³ã¹ããŒããã©ã³+ãŠã£ãžã§ããäžã®ã¢ããªã±ãŒã·ã§ã³
ã¹ããŒããã©ã³ãã³ã³ãã¥ãŒã¿ãŒããå¶åŸ¡ã§ããªãã¹ããŒãããŒã ãšã¯äœã§ããïŒ
ç§ã¯ãã®ãããªãã®ã ãšæãïŒ
ãªãç¡ç·LANã§ã¯ãªãã®ã§ããïŒ é«ãããã
Arduinoèªèº«ã®é£æãæ€åãã
ã³ã¡ã³ãã¯äžå¿ èŠã ãšæããŸããUSBãçŒãåãå±éºæ§ãšãä»ã®ããã€ã¹ãžã®çµ¶ãéãªãå¹²æžã§ãã ããã«ãããŒãããç¹å¥ãªã¢ããã¿ãŒã«é»åã転éãããã§ãã
é»æºã³ã³ã»ã³ããä»ããã«ãŒã¿ãŒã®ç®¡ç
å€ãè¯ãAsus RT56Uã¯ãç¹ã«å€ã«ã¯æ¥å 济ã倧奜ãã§ãã ãã®ãããå€éã«æ°æéèªåã·ã£ããããŠã³ããŠãå·åŽã§ããããã«ããŸãã
ãã¬ãŒã³ã¹ç£èŠãè¿œå
ä»ã§ã¯ãå€ãè¯ãçŠé»åèµ€å€ç·ã»ã³ãµãŒãšããã€ãã®è¶ é³æ³¢è·é¢ã»ã³ãµãŒããããŸãã ããã¯åçŽãªãã¬ãŒã³ã¹å¶åŸ¡ã«ã¯ååãããããŸããã
éšå±ã«ã¯äºäººãäœãã§ããŸãã ãããã4ã€ã®ç¶æ ããããŸãã
- ã³ã³ãã¥ãŒã¿ãŒã§
- 䟡å€ããã
- ãããã«æšªããã£ãŠ
- è¡æ¹äžæã§ã
èµ€å€ç·ã»ã³ãµãŒã¯ãéšå±ã®ååšãšãŸãŒã³ïŒããã/ããŒãã«ïŒã®è¶ é³æ³¢ã®ååšãå€æããåºå ¥ããã人ã®æ°ãç£èŠããŸãã
ããã«ãããæãåçŽãªã·ããªãªãå®è£ ã§ããŸãã
- ç§ã¯å€æ¹ã«æ¥ãŠãé£äººã¯å¯ãŠããŸããïŒã©ã€ããã€ããŸã
- ãã¹ãŠãåºãŸãïŒã©ã€ãããªãã«ããŸã
- 誰ãã暪ã«ãªã£ãŠåããªãïŒã©ã€ããæ¶ã
æå æµæãè¿œå
ãžã£ã³ã«ã®å€å žïŒéšå±ã®èª°ãããã³ã³ãã¥ãŒã¿ãŒã®ããŸãŒã³ã«ããŠãéšå±ãæãå Žåã«èªåçã«å ãå«ããã
é»æ°æ©æ¢°çããã¯ãè¿œå ããããè¿ãã«
ç§ã¯ããªãã®ããšã¯ç¥ããŸããããç§ã¯ãã€ãããŒãæ¢ãã®ãé¢åãªã®ã§ãè¿æ¥ã«ãŒããªãŒããŒãŸãã¯æçŽã»ã³ãµãŒãšçµã¿åãããŠãé»æ°æ©æ¢°åŒããã¯ãæ¬åœã«åãä»ãããã§ãã ãã¹ãã«ãžã®å ¥å Žã¯é»åãã¹ã䜿çšããŠè¡ãããŸã-Arduinoã®åšæ³¢æ°ã¯ããã£ãŠããŠããªãŒããŒãç°¡åã«æ³šæã§ããŸãããã«ãŒãã¯éåžžã«ç°¡åã«è€è£œã§ããŸãïŒç§èªèº«ã¯ãã®ããã®ããã€ã¹ãæã£ãŠããŸãïŒã®ã§ãæéãæ¥ãããæçŽã«éäžããã§ãããæã
é£äººã¯ãã°ãã°å°æ/ãã€ã¬/颚åã«è¡ãããã¢ãéããŸããã ç§ã¯çé¢ã®åã«åº§ã£ãŠããŸãããéãéãã人
ãŠã£ã³ããŠãã¢ããã°ã¬ãŒããã
ãã§ã«æžããããã«ã枩床ãç¹å®ã®å¶éãè¶ ãããšããã¡ã³ããªã³ã«ãªããŸãã ããããéšå±ã«èª°ãããªããŠã枩床ããã§ã«20ãäžåã£ãŠããå Žåã¯ã©ãã§ããããã ãŠã£ã³ããŠã®ééã·ã¹ãã ãè¿œå ããããšæããŸãã ãããããåçŽãªã¢ãŒã¿ãŒãšé£ã糞ã§ãããã
é»çãå·ãããŠãªã³ã«ãããšãççºããå¯èœæ§ãé«ãããšãç¥ãããŠããŸãã ãããã£ãŠãããã¯ç¥çµãšçæ ¹ãç¯çŽããŸãã
枩床å¶åŸ¡ã·ã¹ãã ã«å¯Ÿå¿ããŠããªãé»ç
DHT11ã亀æããŠãã ãã
ãã§ã«æžããããã«ãã»ã³ãµãŒãªã©ã¯ç解ããŠããŸããã ã ããç§ã¯æåã«æã«å ¥ãã枩床ã»ã³ãµãŒdht11ãè²·ããŸããã ããã§ãéšå±ãdht22ãéããdht21ã«çœ®ãæããŸãã Dht22ã®èª€å·®ç¯å²ã¯å°ãããdht21ã«ã¯åçµæž©åºŠã®ãµããŒããšãè·¯äžã§éèŠãªä¿è·ã±ãŒã¹ããããŸãã Street dht11ã¯ãã§ã«è¿·åã«ãªãå§ããŠããŸããã
é»æ°èª¿å åšãè¿œå ãã
éšå±ã®ç §æã®ã¬ãã«ãã¹ã ãŒãºã«èª¿æŽããããšæããŸãã ã¹ããŒãã«ãŒã ããªãå Žåã¯ãåçŽãªèª¿å åšãè³Œå ¥ããŠåãäžããŸãããçŸåšã¯çŸåšã®ã·ã¹ãã å ã«ååšã§ãã調å åšãå¿ èŠã§ãã æ®å¿µãªããã220Vã調æŽå¯èœãª5Vã®èª¿å åšã¯èŠã€ãããŸããã§ããã ãããŸã§ã«æãã€ããã®ã¯ãåçŽãªèª¿å åšãšããã«æ¥ç¶ãããã¢ãŒã¿ãŒã ãã§ãã
é³å£°å¶åŸ¡
çŸåšã®ç®¡çæ¹æ³ã«é³å£°ãè¿œå ããããšæããŸãã 幞ããªããšã«ã ãã®ãããªã·ã¹ãã ãååšããŸãã ãã¡ãããé³å£°åå¿ã察象ã«ãªããŸããããããã¯åçŽãªè©±è ã§ãã
è³Œå ¥ããã»ã³ãµãŒãžã®ãªã³ã¯
- èµ€å€ç·ã»ã³ãµãŒ
- è¶ é³æ³¢ã»ã³ãµãŒ
- dht11
- éšéªã»ã³ãµãŒ
- ç«çœã»ã³ãµãŒ
- ç¹å¥ãªé»æºã¢ãžã¥ãŒã«
- ã¯ããã¯ã¢ãžã¥ãŒã«
- BTã¢ãžã¥ãŒã«HC-06
- ãªã¬ãŒã¢ãžã¥ãŒã«
- ã¹ã¿ãŒã¿ãŒããã
ããšãã
ããã€ãã®èšç»ã®æåŸã«æ°ããèšäºãæžãããšã¯å¯èœã ãšæããŸãããä»ã®ãšããã¯é»æ°æ©æ¢°åŒããã¯ã倢èŠãŠãã»ãã·ã§ã³ã®æºåãããŸãã
çŽ æŽãããé±æ«ãéãããŸãããïŒå©çãçãããã«éãããŸãããïŒ