Arduinoã«åºã¥ããŠå€ãã®habro-articlesãèŠããšãEnergia Launchpadã®äžçããã®èå³æ·±ãã¯ã€ã€ã¬ã¹ãœãªã¥ãŒã·ã§ã³ãå°ãå¥åŠã«æ¬ ããŠããããã«æããŸããã ãã®æ®éçãªäžæ£çŸ©ãæ£ãæã§ãïŒ
ä»æ¥ã¯CC3200-launchpadãããã°ããŒãã玹ä»ããESP8266ã«å¯Ÿããå©ç¹ã«ã€ããŠèª¬æããç¡ç·ã§ã©ã³ãããããã¢ãæ¥ç¶ãã倧ããªãœããšããªã¬ãŒãã¯ãªãã¯ããŸãã è¡ããïŒ
CC3200-LAUNCHXL倧æåã®ã©ã³ãããã
ä»æ¥ã¯ãTexas Instrumentsã®CC3200 [1]ãã€ã¯ãã³ã³ãããŒã©ãŒããå§ããŸãã
ãã®ã³ã³ãããŒã©ãŒã¯ãTIVA-C Cortex-M4ã³ã¢ãšSimplelink Wi-Fiããã»ããµãŒCC3100ã®1ã€ã®ã±ãŒã¹ã®å ±çã§ã
å³1ïŒã³ã³ãããŒã©ãŒã®ãããã¯å³
çµã¿èŸŒã¿ãã€ã¯ããã¯ãŒãœãªã¥ãŒã·ã§ã³ã«é©çšã§ããããã®ç³ã®å¿«é©ã§èå³æ·±ãç¹æ§ã«ã€ããŠå°ã説æããŸã[2]ïŒ
- 80 MHzã³ã¢Cortex-M4;
- RAM 256KB;
- ROMã®ããªãã§ã©ã«ãã©ã€ããŒãçµã¿èŸŒã¿ã®ãã©ãã·ã¥ããã°ã©ã ã¡ã¢ãªã¯ãããŸããã
- å€éšãããã·ãªã¢ã«ãã©ãã·ã¥ã¡ã¢ãªã®ãµããŒã-å¿ èŠãªã ããã³ã°ããŸãã
- ããŒããŠã§ã¢æå·åAESãDESãSHA2ãMD5ãCRCã
- 2xI2Sã1xSDã«ãŒãã2xUARTã1xSPIã1x2Cã8ãããã«ã¡ã©ã€ã³ã¿ãŒãã§ãŒã¹;
- 16ãããPWMãåãã4ã€ã®ã¿ã€ããŒã
- 4ãã£ãã«12ãããADC
- WEPãWPA2-PSKãããã³WPA-Enterpriseæå·åããµããŒãããèªå®802.11g / b / n Wi-Fiã¢ãžã¥ãŒã«ã ããã€ã¹ã¢ãŒããšãã¹ãã¢ãŒãã®äž¡æ¹ã§åäœãã
- SSLv3ããã³TSLv1çšã®256ãããAESã ã¯ããã¯ããSSLããã©ãã°ããŸãïŒ
- ãã€ã¯ãé»åæ¶è²»ãšè€æ°ã®é»å管çã¢ãŒã
CC3200察ESP8266
äžæ¹ã§ã¯ãESP8266ã«ã¯æ¬¡ã®å©ç¹ããããŸãã
第äžã«ãããã¯éåžžã«å°ãããçµ±åãããŠããŸã-ã³ã€ã³ã®ãµã€ãºãšã³ã¹ãã®ã³ã€ã³ã«ã¯æ°åã®ããããªãŒãå¿ èŠã§ããããã§ã«éããããã«è©°ãŸã£ãŠããŸãã
第äºã«ã圌ã¯ããçºéããé£äºçæ³ãæã£ãŠããŸã-ããªããè³¢æã«è¿ã¥ããªãã°ãããªãã¯é£ç©è£œåãæã«å ¥ããŸãã
第äžã«ãããã¯ç°¡åãªã¹ã¿ãŒãã§ã-ãããã³ã³ãã¥ãŒã¿ãŒã«æ¥ç¶ããArduinoç°å¢ãéãã ãã§äœæ¥ã§ããŸãã
äžæ¹ãCC3200ã¯ãå€ãã®ã¢ã¯ãã£ããªã¿ã¹ã¯ãä¿æã§ãã匷åãªããã»ããµã§ãã ããã«ã圌ã¯ã¯ããã«è±å¯ãªåšèŸºæ©åšãæã£ãŠããŸã-ããªãã¯ã«ã¡ã©ãæ¥ç¶ããããªãã¯ãªãŒãã£ãªããã€ã¹ïŒI2Sçµç±ïŒãŸãã¯SDã«ãŒããå¿ èŠã§ãã å¿ èŠã«å¿ããŠ-ä»ã®å€ãã®ãã®ãšäžç·ã«-éãšãã¡ãŒã ãŠã§ã¢ã®äž¡æ¹ã«èããŸãã ãããŠãã¡ãããSSLã ããã§ãç§ã®å°ããªåŠæ³ã¯ãã 幞çŠã«åã³ãŸãã
ãããããã®åŸããã¬ãšã«ãç®ãèŠãŸããè¬èãªå¬äœ¿ãçµãå§ããŸã-ã¡ãŒã«ãŒã¯30ãã«/åã®ã©ã³ãããããæã£ãŠããŸãã ãã·ã¢ã§ã¯ã40ã50ãã«+éæã§è³Œå ¥ããæ©äŒããããŸãã TIã®éæç¡æã¯çµäºããŸããã
ãããã«ãããåãªãã·ã§ã³ã«ã¯ç¬èªã®çšéããããŸãã
CC3200-LAUNCHXLã¯ã€ãã¯ã¹ã¿ãŒã[3]
å³2ïŒæ©åš
ã©ã³ããããã«é©ããCC3200ã¯ãåºæ¬çãªæ©åšïŒããŒãèªäœããã€ã¯ãUSBã±ãŒãã«ããžã£ã³ããŒãããã¯ã¬ããïŒãåãããã¡ããšãã段ããŒã«ç®±ã«å ¥ã£ãŠããŸãã
ãã®ããŒãã¯40ãã³ã©ãŠã³ããããã®ä»£è¡šçãªãã®ã§ã64ãã£ãŒãQFNã±ãŒã¹ã«CC3200ã³ã³ãããŒã©ãŒãæèŒããŠããŸãã æåã¯ãã ä»ãã®ææªã®ã±ãŒã¹ã§ã¯ãããŸããã ãŸããããŒãã«ã¯FT2232ãããã«åºã¥ãããã°ã©ããŒãããŸãïŒå ¬åŒã®openOCDãµããŒãïŒã 8MbpsããŒã¿çšã®ãã©ãã·ã¥ã¡ã¢ãªãããã
ãŸãã3軞+ -16Gå é床èšBMA222 [4]ããã³éæ¥è§ŠIR枩床ã»ã³ãµãŒTMP006 [5]ã«ã€ããŠãèšåããå¿ èŠããããŸãã
å³3ïŒã©ã³ããããã®è©³çŽ°
äžèšã§èšãã°-æé·ããIoTéçºè ãå¿ èŠãšãããã¹ãŠã
ããŒããé»æºã«æ¥ç¶ãã䜿çšå¯èœãªãã¢ãã¡ãŒã ãŠã§ã¢ã調ã¹ãŸãã
ãã¡ãŒã ãŠã§ã¢ã¯ãããã€ãã®ããŒã¿ã·ãŒã«ããš4ã€ã®ãã€ã¯ããã¢ãæäŸããŸãã ãããŠããã¯ãã¹ãŠãã¢ã¯ã»ã¹ãã€ã³ãã¢ãŒãã§ãããŒãã«httpãµãŒããŒããããŸãã
åé·ã«ãªããªãããã«ãçããããªã¬ãã¥ãŒïŒ
CC3200 SDK [6]
CCS UniFlash [7]ã䜿çšããŠãSDKãæŽæ°ããŸãã
å³4ïŒCCS UniFlashã®å€èŠ³
ãŸããããŒãããã©ãã·ã¥ããã°ã©ãã³ã°ã¢ãŒãã«åãæ¿ããå¿ èŠããããŸãããã®ããã«ã¯ãSOPã³ãã¯ã¿ã®ãã³2ã䜿çšããŸãã ãã®åŸãUARTããŒãã«æ¥ç¶ãããã©ãã·ã¥ã¡ã¢ãªã1 MBã®å®¹éã§ãã©ãŒãããããŸãã 次ã«ãServicePackãžã®ãã¹ãæå®ããŸãã å·çæç¹ã§ãçŸåšã®ãµãŒãã¹ããã¯ïŒ1.0.0.10.0ãSDKïŒ1.1.0ã
Code Composer Studio 6.0.1ã䜿çšããããã°ã©ãã³ã°[8]
倧èŠæš¡ãªãããžã§ã¯ããéåžžã®ãããã°ã®å Žåãçæ³çãªãªãã·ã§ã³ã¯Code Composer Studioç°å¢ã§ããã°ã©ã ãéçºããããšã§ãïŒãã¹ãã¹ã®å ŽåãGCCã³ã³ãã€ã©ãŒã䜿çšããå ŽåãCCS6ã¯ã©ã®ã¢ããªã±ãŒã·ã§ã³ã§ãç¡æã§ãïŒã ã¡ãŒã«ãŒã¯IARããµããŒãããŠããŸãã
CCS IDEã®ã€ã³ã¹ããŒã«ãšæ§æ
ãŸããå³ã«ç€ºãããã«ãžã£ã³ããŒãæ§æããŸãã
å³5ïŒCCSã§ã®ããã°ã©ãã³ã°çšã®ãžã£ã³ããŒã®åãä»ã
ããã«ãCode Composer Studioãã€ã³ã¹ããŒã«ãããšãã¯ã察å¿ããããã±ãŒãžã«ãã§ãã¯ãå ¥ããããšãå¿ããªãã§ãã ããïŒ
å³6ïŒCC3200ãµããŒãã䜿çšããCCSã®ã€ã³ã¹ããŒã«
TI-RTOSã®ãã¡ã³[9]ã¯ãã¹ãã¢ã«æ¡åŒµæ©èœãã€ã³ã¹ããŒã«ããåŸãSImplelinkããã±ãŒãžã«TI-RTOSãã€ã³ã¹ããŒã«ããããšãæšå¥šããŸã
å³7ïŒCC3100ããã³CC3200çšã®TI-RTOSã®ã€ã³ã¹ããŒã«
å³5ïŒCCSã§ã®ããã°ã©ãã³ã°çšã®ãžã£ã³ããŒã®åãä»ã
ããã«ãCode Composer Studioãã€ã³ã¹ããŒã«ãããšãã¯ã察å¿ããããã±ãŒãžã«ãã§ãã¯ãå ¥ããããšãå¿ããªãã§ãã ããïŒ
å³6ïŒCC3200ãµããŒãã䜿çšããCCSã®ã€ã³ã¹ããŒã«
TI-RTOSã®ãã¡ã³[9]ã¯ãã¹ãã¢ã«æ¡åŒµæ©èœãã€ã³ã¹ããŒã«ããåŸãSImplelinkããã±ãŒãžã«TI-RTOSãã€ã³ã¹ããŒã«ããããšãæšå¥šããŸã
å³7ïŒCC3100ããã³CC3200çšã®TI-RTOSã®ã€ã³ã¹ããŒã«
ãã¢ãããžã§ã¯ãã®1ã€ãã€ã³ããŒãããŸãã HTTPãµãŒããŒãéžæããŸãã[10]ã
ç§ãã¡ã®ã¿ã¹ã¯ã¯ãããŒãã«æ¥ç¶ããã¿ãŒã²ãããè¿œå ããããšã§ãã ãããè¡ãã«ã¯ãã¡ãã¥ãŒé ç®[衚瀺]-> [ã¿ãŒã²ããèšå®]ã«ç§»åãããã¡ã€ã«Cãã€ã³ããŒãããŸãã\ TI \ CC3200SDK_1.1.0 \ cc3200-sdk \ tools \ ccs_patch \ cc3200.ccxmlãã®åŸããã®ã³ã³ããã¹ãã¡ãã¥ãŒã§ããã©ã«ãã§äœ¿çšãããããšã瀺ããŸãã
å³7ïŒãããã°ã€ã³ã¿ãŒãã§ã€ã¹ã®ã»ããã¢ãã
F11ãæŒããŠãããã°ã¢ãŒããèµ·åããF8ãæŒããŠããã°ã©ã ãèµ·åããAndroid [11]ãŸãã¯iOS [12]ã®Wi-Fi Starterã¢ããªã±ãŒã·ã§ã³ã«ç§»åããŸã
Wi-Fiã¹ã¿ãŒã¿ãŒ
ã¢ã¯ã»ã¹ãã€ã³ãã®ååãšãã¹ã¯ãŒããæå®ããããã¹ã¿ãŒããã¿ã³ãæŒããŸã
å³8ïŒããã€ã¹ã®æ€çŽ¢ãšæ§æ
ããã€ã¹ãèŠã€ãããšã[ããã€ã¹]ã¿ãã«è¡šç€ºãããŸã
å³9ïŒæ¥ç¶ãããããã€ã¹ã®ãªã¹ã
ãããã¿ããããŠããã©ãŠã¶ã§ãã¹ãŠãæ©èœããŠãããšããããŒãžã«ç§»åããŸãã ããã§ãWi-Fiæ¥ç¶çšã®ããŒã¿ãåæ§æããããã€ã¹ãã¢ã¯ã»ã¹ãã€ã³ãã¢ãŒãã«ããããšãã§ããŸãã
å³10ïŒãã¢ã¢ããªã±ãŒã·ã§ã³
å³8ïŒããã€ã¹ã®æ€çŽ¢ãšæ§æ
ããã€ã¹ãèŠã€ãããšã[ããã€ã¹]ã¿ãã«è¡šç€ºãããŸã
å³9ïŒæ¥ç¶ãããããã€ã¹ã®ãªã¹ã
ãããã¿ããããŠããã©ãŠã¶ã§ãã¹ãŠãæ©èœããŠãããšããããŒãžã«ç§»åããŸãã ããã§ãWi-Fiæ¥ç¶çšã®ããŒã¿ãåæ§æããããã€ã¹ãã¢ã¯ã»ã¹ãã€ã³ãã¢ãŒãã«ããããšãã§ããŸãã
å³10ïŒãã¢ã¢ããªã±ãŒã·ã§ã³
ããã«ãå¿ èŠãªå Žæãšå¿ èŠã§ãªãå Žæã«ç»ããç¬èªã®ã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸãã
é»åããã¯ã®äœæ
æåŸã«ç·Žç¿ã«ç§»ããŸãããïŒ
ãã¢ãªãŒãããŒãšå¶åŸ¡çšã®ããŒãã©ããåããé»åããã¯ãäœæããŠã¿ãŸããããããããã°ãäžæ£ã¢ã¯ã»ã¹ã§äžåãªSMSãå±ããŸãã
ããã«ã¯æ¬¡ã®ãã®ãå¿ èŠã§ãã
- Wi-Fiã²ãŒããŠã§ã€ãšããŠã®CC3200ã©ã³ãããã
- TIVA-Cã©ãŠã³ãããã[13]é»åããã¯å¶åŸ¡ããŒããšããŠ
- ããŒãã©ãããŒããšããŠã®MSP430F5529 [14]ã©ã³ãããã
- ç¡ç·ã¢ãžã¥ãŒã«ãšããŠã®3ã€ã®Anaren CC110LããŒã¹ã¿ãŒããã¯ç¡ç·ã¢ãžã¥ãŒã«[15]ã
åäœåçã¯æ¬¡ã®ãšããã§ãã
ã¢ã¯ãã¥ãšãŒã¿ã«ã¯ã2äœçœ®ãœã¬ãã€ããšå¢çã»ã³ãµãŒãè£ åãããŠããŸãã ç§ãã¡ã®å Žåããœã¬ãã€ãã®åœ¹å²ã¯2ããžã·ã§ã³ã®ãœããšããªã¬ãŒRP-12 [16]ãšããœããšãå°äžéãžã®èšªåè ã®å¿ã«éŠŽæã¿ã®ãããã©ããªã¬ãŒRF-8300ã®å¢çã»ã³ãµãŒã®åœ¹å²ïŒåäžã®å転åŒæ¹æå£ã§ã¯ãªãïŒã«ãã£ãŠè¡ãããŸãã äœæ¥ã®ããžãã¯ã¯æ¬¡ã®ãšããã§ããradioã³ãã³ãã䜿çšããŠãã¹ã¿ã³ãã€ã¢ãŒããŸãã¯ã»ãã¥ãªãã£ã¢ãŒããèšå®ã§ããŸãã ã¢ãŒãã³ã°ã¢ãŒãã§ã¯ããœã¬ãã€ãããã¢ããããã¯ãããã»ã³ãµãŒãã¢ã©ãŒã ãããªã¬ãŒããŸãã ã¹ã¿ã³ãã€ã¢ãŒãã«åãæ¿ãããšããã¢ã®ããã¯ã解é€ãããŸãã ã¹ããŒã¿ã¹ã¯ãç¡ç·ãã£ãã«ãä»ããŠWi-Fiã²ãŒããŠã§ã€ã«å®æçã«éä¿¡ãããŸãã
ããŒãã©ãã«ã¯2ã€ã®ãã¿ã³ããããŸã-ã¢ãŒã /ã¢ãŒã 解é€ã ã³ãã³ãã®è»¢éã¯ãã¢ã¯ãã¥ãšãŒã¿ã«çŽæ¥å®è¡ãããŸãã UDPããŒã¿éä¿¡ã®ã¿ã€ããã€ãŸã ããã±ãŒãžãèªèããã«ïŒåãå²ããŸãïŒã åãçç±ã§ãããŒã¿ã¯æå·åãããã«éä¿¡ãããŸãã ã¢ã¯ãã¥ãšãŒã¿ã¯ããã®ã¹ããŒã¿ã¹ãwi-fiã²ãŒããŠã§ã€ã«è»¢éããŸãã Wi-Fiã¢ã©ãŒã ãçºçããå Žåãã²ãŒããŠã§ã€ã¯SMSéä¿¡ãéå§ããŸãã
ã³ãã³ããä¿®æ£ããŸãã
enum {IDLE=0x01, ACTIVE, ALERT};
Energiaã䜿çšããããã°ã©ãã³ã°[17]
Arduinoã®ãã¡ã³ã«ãšã£ãŠãã©ã³ããããã«ã¯Energiaããã°ã©ãã³ã°ç°å¢ãšãã圢ã§çŽ æŽãããåå²ç¹ããããŸãã ã³ãã¥ããã£ã«ãã£ãŠç©æ¥µçã«ãµããŒããããŠããŸãã
å³11ïŒEnergia-15ããŒãžã§ã³ã§ãµããŒããããŠããããŒãã®ãªã¹ã
EnergiaããCC3200ãããã°ã©ã ããã«ã¯ãå°ããªããã¯ãè¡ãå¿ èŠããããŸã-TCKã®äžéšãã³ãSOP-2ã®äžéšãã³ã«æ¥ç¶ããŸãã
å³12ïŒèªåããã°ã©ãã³ã°æ¥ç¶
ããŒãã«ããŒ
ããã§ã¯ãã¹ãŠãç°¡åã§ãã 圌ãã¯ãã¿ã³1ãæŒããŸãã-圌ãã¯ACTIVEã³ãã³ããã¡ã«ããºã ã«éä¿¡ããŸããã
æŒããããã¿ã³2-IDLEã³ãã³ããã¡ã«ããºã ã«æž¡ããŸããã
å³13.ããŒãã§ãŒã³ã®ã³ã³ããŒãã³ã
äŸããç°¡åãªããã°ã©ã ãä¿åããŸãããïŒ
ããŒãã§ãŒã³ããã°ã©ã ãªã¹ã
#include <SPI.h> #include <AIR430BoostETSI.h> //define addresses. #define ADDRESS_LOCAL 0x02 #define ADDRESS_REMOTE 0x03 //FSM states. And commands enum { IDLE=0x01, ACTIVE, ALERT}; unsigned char txData[60] = { "\0" }; const int setButton = PUSH1; //set to active mode const int releaseButton = PUSH2;//set to idle mode const int ledPin = GREEN_LED; const int redPin = RED_LED; void setup() { //define pinouts and add serial outputr pinMode(ledPin, OUTPUT); pinMode(redPin, OUTPUT); Serial.begin(9600); pinMode(setButton, INPUT_PULLUP); pinMode(releaseButton, INPUT_PULLUP); Radio.begin(ADDRESS_LOCAL, CHANNEL_1, POWER_MAX); Serial.println("RF start"); txData[0] = ADDRESS_LOCAL;//set zer0 byte as our address } void loop(){ //check set button if (digitalRead(setButton) == LOW){ //if button is pressed, send command Serial.println("Active mode"); digitalWrite(redPin, HIGH); txData[1] = ACTIVE;//Set command txData[2] = 0x00; Radio.transmit(ADDRESS_REMOTE, (unsigned char*)&txData, 2); } else{ digitalWrite(redPin, LOW); } //check release button if (digitalRead(releaseButton) == LOW){ Serial.println("IDLE mode"); digitalWrite(ledPin, HIGH); txData[1] = IDLE;//Set command txData[2] = 0x00; //send packet Radio.transmit(ADDRESS_REMOTE, (unsigned char*)&txData, 2); } else{ digitalWrite(ledPin, LOW); } sleepSeconds(1);//Low-power mode delay delay(50);//to Clock stabilization }
ã¢ã¯ãã¥ãšãŒã¿
ã¢ã¯ãã¥ãšãŒã¿ã®ã¿ã¹ã¯ã¯ãåå®å®ãœã¬ãã€ããå¶åŸ¡ããããšã§ãã ãã®ãããªãœã¬ãã€ãã«ã¯2ã€ã®å·»ç·ãããã1ã€ã®å·»ç·ã«é»å§ãå°å ããã³ã¢ãåŒãããã1ã€ã«è§£æŸããŸãã å·»ç·ã®é»å§ãåžžã«ç¶æããå¿ èŠã¯ãããŸããã RP-12ãªã¬ãŒã¯å°ãç°ãªããŸãã1ã€ã®å·»ç·ããããåäœã®éžæã¯æ¥µæ§ã«ãã£ãŠæ±ºãŸããŸãã ããã€ãã®ãã€ãªãŒãã管çããŸãã
å³14ïŒã«ããã®ãªããœããšãã®å€§åãªã¬ãŒã é»ç£ç³ãš2äœçœ®ã®ã³ã¢ãèŠããŸãã ã³ã¢ã«ç°ãªã極æ§ã®ä¿¡å·ãé©çšããããšã«ããããªã¬ãŒã¹ã€ãããå®çŸããŸãã
次ã®ã¹ããŒã ã«åŸã£ãŠããã©ã€ã¢ãã¯MOC3052ãä»ããŠæ¥ç¶ããŸãã
å³15ïŒãã©ã€ã¢ãã¯ã®æ¥ç¶å³ã
ç§ã¯zasharnikã§2ã€ã®ãã©ã€ã¢ãã¯ã®ã¹ã«ãŒããèŠã€ããã®ã§ãåœã®ã¬ã€ã¢ãŠããäœæããå¿ èŠã¯ãããŸããã§ããã
RF-8300ãã©ããªã¬ãŒã®å¢çå¶åŸ¡ã»ã³ãµãŒã¯ãã¢ã¯ãã¥ãšãŒã¿ã«ä¿¡å·ãäŸçµŠããã¡ã€ã¯æ¥ç¹ã®ã°ã«ãŒãã«ãã£ãŠèªåŸçã«åäœããŸãã
ã°ãŒã°ã«æ®µããŒã«ã®ãã¡ã³
ãããã®ãªã¬ãŒã®ãããã®ã¬ã³ãºã¯ãä»®æ³çŸå®ã®çŒé¡ã«ç«ã€ããã«ç°¡åã«äœæãããŸãã
ãªã¢ãŒãã³ã³ãããŒã«ããã³ãã³ããåãåã£ããããããå®è¡ããŠãwi-Fiã§ã²ãŒããŠã§ã€ãè€è£œããŸãã
ããã°ã©ã ãã³ããŒããŠè²Œãä»ããŸãã
ã¢ã¯ãã¥ãšãŒã¿ã®ããã°ã©ã ãªã¹ã
#include <SPI.h> #include <AIR430BoostETSI.h> #define ADDRESS_LOCAL 0x03 #define ADDRESS_REMOTE 0x01 unsigned char rxData[60] = { "\0" }; unsigned char txData[60] = { "\0" }; /* Finite state machine: 1. IDLE mode 2. Action Mode 3. Alert mode 1 -> 2 Received command 0x01 2 -> 1 received command 0x02 2 -> 3 sensor triggered. Send alert */ enum {IDLE=0x01, ACTIVE, ALERT}; unsigned int fsm = IDLE; static unsigned char sensor = 11; static unsigned char releopen = 9; static unsigned char releclose = 10; static unsigned char releopenled = BLUE_LED; static unsigned char relecloseled = GREEN_LED; // ----------------------------------------------------------------------------- // Main example void setup() { pinMode(sensor, INPUT_PULLUP); pinMode(releopen, OUTPUT); digitalWrite(releopen, HIGH); pinMode(releopenled, OUTPUT); pinMode(relecloseled, OUTPUT); pinMode(releclose, OUTPUT); digitalWrite(releclose, HIGH); pinMode(12, OUTPUT); pinMode(12, LOW); //return pin for sensor Radio.begin(ADDRESS_LOCAL, CHANNEL_1, POWER_MAX); // Setup serial for debug printing. Serial.begin(9600); txData[0] = ADDRESS_LOCAL;//set zer byte as our address } uint8_t length = 0; void loop() { switch (fsm){ case IDLE: length = Radio.receiverOn(rxData, sizeof(rxData), 1000); if (length > 0){ if (rxData[1] == ACTIVE){ //change state stage fsm = ACTIVE; txData[1] = ACTIVE;//Set command txData[2] = 0x00; Radio.transmit(ADDRESS_REMOTE, (unsigned char*)&txData, 2); //send 500ms inpuls to actuator digitalWrite(releclose, LOW); digitalWrite(relecloseled, HIGH); delay(500); digitalWrite(releclose, HIGH); digitalWrite(relecloseled, LOW); } else{ fsm = IDLE; } } else{ } break; case ACTIVE: length = Radio.receiverOn(rxData, sizeof(rxData), 100); if (length > 0){ if (rxData[1] == IDLE){ //change state stage fsm = IDLE; txData[1] = IDLE;//Set command txData[2] = 0x00; Radio.transmit(ADDRESS_REMOTE, (unsigned char*)&txData, 2); //send 500ms inpuls to actuator digitalWrite(releopen, LOW); digitalWrite(releopenled, HIGH); delay(500); digitalWrite(releopen, HIGH); digitalWrite(releopenled, LOW); } else{ fsm = ACTIVE; } } else{ } checkperimeter(); break; case ALERT: length = Radio.receiverOn(rxData, sizeof(rxData), 1000); if (length > 0){ if (rxData[1] == IDLE){ //change state stage fsm = IDLE; txData[1] = IDLE;//Set command txData[2] = 0x00; Radio.transmit(ADDRESS_REMOTE, (unsigned char*)&txData, 2); //send 500ms inpuls to actuator digitalWrite(releopen, LOW); digitalWrite(releopenled, HIGH); delay(500); digitalWrite(releopen, HIGH); digitalWrite(releopenled, LOW); } else{ fsm = ALERT; } } else{ } break; default: break; } } void checkperimeter(){ uint8_t sensorstate = digitalRead(sensor); if (sensorstate == LOW){ Serial.println("Alert!"); //alert!! fsm = ALERT; txData[1] = ALERT;//Set command txData[2] = 0x00; Radio.transmit(ADDRESS_REMOTE, (unsigned char*)&txData, 2); } }
ã²ãŒããŠã§ã€
ã²ãŒããŠã§ã€ã®ã¿ã¹ã¯ã¯ãã以äžé£ãããããŸãããã·ã¹ãã ã¹ããŒã¿ã¹ïŒãã¹ãçšïŒãLEDã§è€è£œããã¢ã©ãŒã ãçºçããå Žåã«é»è©±ã«ã¡ãã»ãŒãžãéä¿¡ããŸãã
å³15ïŒã²ãŒããŠã§ã€ã¢ã»ã³ããª
Temboo + NEXMO
ããããæåã«ãAPIã°ã©ãŠã³ããæºåããŸãã ãããè¡ãã«ã¯ãTemboo [18]ããã³Nexmo [19]ã®ãµãŒãã¹ã«ç»é²ããŸãã Nexmoã®äœ¿åœã¯ãäžçäžã®ããããæºåž¯é»è©±ã«æ¥ç¶ããããšã§ãã ç»é²æã«ã圌ãã¯ãã®ãµãŒãã¹ãè©Šãã®ã«ååãªéå§2ãŠãŒããæäŸããŸãã
Tembooã®ã¿ã¹ã¯ã«ã¯ãããã€ã¹ãšNexmoãµãŒãã¹éã®éä¿¡ã®ç·šæãå«ãŸããŸãã ããã§ã¯ãéå§ã®ããã«ã250ã®ãªã¯ãšã¹ããäžããããŸããããã¯ãåã ã¡ãæåŸ ããŠ1äžäººãŸã§ç¡æã§æ¡åŒµã§ããŸãã é¢çšã«é¢ããŠã¯ãSMSã«ã¯2ãŠãŒãã»ã³ãããããŸããã
å¯èœãªAPIã®ãªã¹ãã§ãNexmoo.SMS.TextMessageãéžæããŸãã
ããŒã-CC3200ãéžæããWi-Fiæ¥ç¶ãã©ã¡ãŒã¿ãŒãæå®ããŸã
å³16ïŒWi-Fiã»ããã¢ãã
æ¥ç¶ãã©ã¡ãŒã¿ãŒãæå®ããŸãã Nexmooã¢ã«ãŠã³ãã®APIããŒãã¢ã«ãŠã³ãã«é¢é£ä»ããããŠããéä¿¡è ã®é»è©±çªå·ãåä¿¡è ã®é»è©±çªå·ãããã³ããã¹ãã¡ãã»ãŒãžãæå®ããå¿ èŠããããŸãã
å³17ïŒåä¿¡è ã®éžæãšã¡ãã»ãŒãžã®æ§æ
[å®è¡]ãã¿ã³ãã¯ãªãã¯ãããšããã¹ãŠãæ©èœããããšã確èªã§ããŸãã
ãããã¯ããã³ãŒããã³ããŒããŠè²Œãä»ãããµããŒãã«æäœã¢ãŒãããè¿œå ãããŸãã
ã²ãŒããŠã§ã€Wi-Fiã³ãŒããªã¹ã
#include <SPI.h> #include <AIR430BoostETSI.h> #include <WiFi.h> #include <WiFiClient.h> #include <Temboo.h> #include "TembooAccount.h" // Contains Temboo account information WiFiClient client; #define ADDRESS_LOCAL 0x01 unsigned char rxData[60] = { "\0" }; unsigned char txData[60] = { "\0" }; /* Finite state machine: 1. IDLE mode 2. Action Mode 3. Alert mode 1 -> 2 Received command 0x01 2 -> 1 received command 0x02 2 -> 3 sensor triggered. Send alert */ enum { IDLE=0x01, ACTIVE, ALERT}; unsigned int fsm = IDLE; // ----------------------------------------------------------------------------- // Main example void setup() { pinMode(GREEN_LED, OUTPUT); pinMode(RED_LED, OUTPUT); pinMode(YELLOW_LED, OUTPUT); digitalWrite(YELLOW_LED, LOW); digitalWrite(RED_LED, LOW); digitalWrite(GREEN_LED, LOW); Radio.begin(ADDRESS_LOCAL, CHANNEL_1, POWER_MAX); // Setup serial for debug printing. txData[0] = ADDRESS_LOCAL;//set zer byte as our address Serial.begin(9600); int wifiStatus = WL_IDLE_STATUS; // Determine if the WiFi Shield is present Serial.print("\n\nShield:"); if (WiFi.status() == WL_NO_SHIELD) { Serial.println("FAIL"); // If there's no WiFi shield, stop here while(true); } Serial.println("OK"); // Try to connect to the local WiFi network while(wifiStatus != WL_CONNECTED) { Serial.print("WiFi:"); wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD); if (wifiStatus == WL_CONNECTED) { Serial.println("OK"); } else { Serial.println("FAIL"); } delay(5000); } digitalWrite(YELLOW_LED, HIGH); Serial.println("Setup complete.\n"); } uint8_t length = 0; void loop() { length = Radio.receiverOn(rxData, sizeof(rxData), 1000); if (length > 0){ Serial.print("Get state: "); Serial.println(rxData[1], DEC); switch (fsm){ case IDLE: if (rxData[1] == ACTIVE){ fsm = ACTIVE; digitalWrite(GREEN_LED, HIGH); } break; case ACTIVE: if (rxData[1] == IDLE){ fsm = IDLE; digitalWrite(GREEN_LED, LOW); digitalWrite(RED_LED, LOW); } if (rxData[1] == ALERT){ fsm = ALERT; digitalWrite(RED_LED, HIGH); sendmessage(); } break; case ALERT: if (rxData[1] == IDLE){ fsm = IDLE; digitalWrite(GREEN_LED, LOW); digitalWrite(RED_LED, LOW); } break; } } } void sendmessage(){ Serial.println("Running SendMessage - Run #" + String(numRuns++)); TembooChoreo SendMessageChoreo(client); // Invoke the Temboo client SendMessageChoreo.begin(); // Set Temboo account credentials SendMessageChoreo.setAccountName(TEMBOO_ACCOUNT); SendMessageChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); SendMessageChoreo.setAppKey(TEMBOO_APP_KEY); // Set Choreo inputs String TextValue = "Testing! Testing! 1, 2, 3"; SendMessageChoreo.addInput("Text", TextValue); String APIKeyValue = "000"; SendMessageChoreo.addInput("APIKey", APIKeyValue); String ToValue = "000"; SendMessageChoreo.addInput("To", ToValue); String APISecretValue = "000"; SendMessageChoreo.addInput("APISecret", APISecretValue); String FromValue = "000"; SendMessageChoreo.addInput("From", FromValue); // Identify the Choreo to run SendMessageChoreo.setChoreo("/Library/Nexmo/SMS/SendMessage"); // Run the Choreo; when results are available, print them to serial SendMessageChoreo.run(); while(SendMessageChoreo.available()) { char c = SendMessageChoreo.read(); Serial.print(c); } SendMessageChoreo.close(); }
ã³ã³ãã€ã«ãããã¿ã³ãçªãããã¹ãŠãæ©èœããããšã確èªããŸãã
ãã¢ã³ã¹ãã¬ãŒã·ã§ã³
倧ããªãªãŒã«ã䜿çšããèŠèŠçãªãã¢ïŒ
èŠçŽãããšãCC3200ãããã°ããŒãã¯ãã¢ããªã±ãŒã·ã§ã³çšã®ç¬èªã®ããããæã€éåžžã«åªããããŒããŠã§ã¢ã§ãã ããã«ç€ºãããŠãããã¢ã¯ããäœããç²ç®ã«ãããããšããååã«åºã¥ããŠäœæãããŠãããEnergia lauchpadããŒãã®æ©èœã®äžéšã瀺ãããšãç®çãšããŠããŸãã èšç»-ä¿¡é Œæ§ãšé»ç£å¹²æžèæ§ãèæ ®ããŠãã»ã³ãµãŒãšã¢ã¯ãã¥ãšãŒã¿ãŒãæ¥ç¶ããæ©èœã«ã€ããŠè©³ãã説æããŸãã
ãããžã§ã¯ãã®ãœãŒã¹ã³ãŒãã¯ããªããžããª[20]ã§å ¥æã§ããŸãã
䟿å©ãªãªã³ã¯ïŒ
1. CC3200補åæŠèŠhttp://www.ti.com/product/cc3200
2. CC3200ããŒã¿ã·ãŒãhttp://www.ti.com/lit/ds/symlink/cc3200.pdf
3. CC3200-LAUNCHXLãŠãŒã¶ãŒã¬ã€ãhttp://www.ti.com/lit/ug/swru372b/swru372b.pdf
4. BMA222å é床èšããŒã¿ã·ãŒãhttps://ae-bst.resource.bosch.com/media/products/dokumente/bma222/bst-bma222-ds002-05.pdf
5. TMP006 IRãµãŒã¢ãã€ã«ã»ã³ãµãŒããŒã¿ã·ãŒãhttp://www.ti.com/lit/ds/sbos518e/sbos518e.pdf
6. CC3200 SDK http://www.ti.com/tool/cc3200sdk
7. CCS UniFlash http://www.ti.com/tool/uniflash
8. Code Composer Studio 6 IDE http://www.ti.com/tool/ccstudio
9. TI-RTOS http://www.ti.com/tool/TI-RTOS
10. CC3200 HTTPãµãŒããŒãŠãŒã¶ãŒã¬ã€ãhttp://processors.wiki.ti.com/index.php/CC32xx_HTTP_Server
11. AndroidçšWi-Fiã¹ã¿ãŒã¿ãŒã¢ããªhttps://play.google.com/store/apps/details?id=com.pandaos.smartconfig
12. iOSçšWi-Fi Starterã¢ããªhttps://itunes.apple.com/us/app/texas-instruments-simplelink/id884122493?ls=1&mt=8
13. TIVA-Cã©ãŠã³ããããhttp://www.ti.com/tool/ek-tm4c123gxl
14. MSP430F5529ã©ãŠã³ããããhttp://www.ti.com/tool/msp-exp430f5529lp
15. CC110Lãšã¢ã¢ãžã¥ãŒã«ããŒã¹ã¿ãŒããã¯https://www.anaren.com/air/cc110l-air-module-boosterpack-embedded-antenna-module-anaren
16ããªã¬ãŒRP-12ã 説æïŒ http : //www.cheaz.ru/en/production/ustroystva-releynoy-zashchity/rele-promezhutochnye-dvukhpozitsionnye-rp-8-9-11-12
17. Energia IDE http://energia.nu/
18. Temboo https://temboo.com/
19. Nexmo https://www.nexmo.com/
20.é»åããã¯GitHubãªããžããªhttps://github.com/radiolok/electronic_lock_energia