M5Stackï¼ESP32ãã¤ã³ã³ï¼ã¨AWSãç¹ããã¹ã
ãæè¿ESP32ãã¤ã³ã³ãè²ã ãªç¨éã«ã¤ããããã§é¢ç½ããã ãªã¼ã¨æã£ã¦ãã¾ããInterface 2018å¹´9æã®ç¹éã¯ãè²ã ãªå¿ç¨ä¾ãæ¸ããã¦ãã¦ä¸ã è¯ãã£ãã§ãã
Interface(ã¤ã³ã¿ã¼ãã§ã¼ã¹) 2018å¹´ 09 æå·
- åºç社/ã¡ã¼ã«ã¼: CQåºç
- çºå£²æ¥: 2018/07/25
- ã¡ãã£ã¢: éèª
- ãã®ååãå«ãããã°ãè¦ã
ãã¨ãããããæ¬ã«æ¸ããã¦ããESP32ãã¤ã³ã³ã¨AWSãç¹ãã§ã¿ãã£ã¦ã¨ããããã£ã¦è¦ã¾ãããæ¬ã«æ¸ããã¦ããå 容ãããããã«ãå¤ãå ¬éããã¦ããå 容ãã®ã¾ã¾ãªã®ã§ããããã¤ãã®éãå®éãã£ã¦ã¿ãã¨ç´°ããã¤ã¾ã¥ãããããã®ã¨ãããã¤ã¹ã¨ãã¦M5Stackã使ã£ããããã®ã§ãèªåã¸ã®ã¡ã¢ã¨ãã¦æ¸ãã¦ããããã¨æãã¾ãã
ESP32ãã¤ã³ã³å´ã®ç°å¢è¨å®
ãESP32ãã¤ã³ã³ã®éçºç°å¢ã¨ãã¦ã¯ã以ä¸2éãã試ãã¾ããã
- M5Stack
- ESPr Developer 32
ãM5Stackã¯ãESP32ãã¤ã³ã³ã«å ãã¦ãã£ã¹ãã¬ã¤ãã»ã³ãµã¾ã§å ¨é¨å ¥ãã®ä»è©±é¡ã®ããã¤ã¹ã§ããM5Stackã§ã®ç°å¢è¨å®ã¯ã以åå®æ½ãã以ä¸å 容ã§OKã§ããã
- åºç社/ã¡ã¼ã«ã¼: ã¹ã¤ãããµã¤ã¨ã³ã¹
- ã¡ãã£ã¢: ããã¡ãï¼ããã¼
- ãã®ååãå«ãããã°ãè¦ã
ãåç´ã«ESP32ãã¤ã³ã³åä½ã®éçºç°å¢ã欲ããå ´åã¯ãESPr Developer 32ãUSBã«ç¹ãã¦ããã®ã¾ã¾Arduino IDEã§éçºãã§ããã®ã§ãè¯ãããã§ãããã¹ã¤ãããµã¤ã¨ã³ã¹ããã§è³¼å ¥ã§ãã¾ãã
- åºç社/ã¡ã¼ã«ã¼: ã¹ã¤ãããµã¤ã¨ã³ã¹(Switch Science)
- ã¡ãã£ã¢: ããã¡ãï¼ããã¼
- ãã®ååãå«ãããã°ãè¦ã
ãç§æããã§ãåããããªããã¤ã¹ãå®ãä¾¡æ ¼ã§è²·ãã¾ãããã¹ã¤ãããµã¤ã¨ã³ã¹ããã®æ¹ãé»æºå¨ãã®åè·¯ã«ãéãããã¦ããåå®å®ãã¦ãããããã§ãï¼èªåã§æ¤è¨¼ã¯ãã¦ãã¾ããï¼ã
ãESPr Developer 32ã¯ã以ä¸ã®ããã«PCã«ç¹ãã¾ããç°å¢è¨å®ã¯M5Stackã¨ã»ã¼åãã§ãããArduino IDEã®ãã¼ãå¨ãã®ç°å¢è¨å®ãç°ãªãã¾ãï¼ESP32 Dev Moduleã«ããå¿ è¦ãããã¾ãï¼ãå ·ä½çã«ã¯ã以ä¸ã®ããã«è¨å®ãã¾ããã
ããªããArduino IDEå ±éã®è©±ã§ãããArduinoã®è¨å®ã以ä¸ã®ããã«è¨å®ããã¨è©³ãããã°ãè¦ããã®ã§ããããã°ãæãã¾ããé常ã¨ã©ã¼ã§åå ãåãããè©°ã¾ã£ãæã¯è¨å®ãã¦ã¿ã¾ãããï¼å ¨ç¶ç¥ããªãã£ãã§ãï¼ã
ããã¼ã« -> Core Debug Level -> Verboseã
AWSã®æºå
ãAWSå´ã®è¨å®ã§ããAWSã®ãIoT Coreãã§æä½ãè¡ãã¾ãããã©ã¦ã¶ã¯Google Chromeã使ã£ãæ¹ãè¯ãããã§ãããAWSã®IoT Coreã®æ¦è¦ãã§ãããã¨ã«é¢ãã¦ã¯ã以ä¸è¨äºåç §ä¸ããã
ãè¦ã¯ãAWSã®ãIoT Coreãã使ã£ã¦AWSã«ã»ãã¥ã¢ã«ãã¼ã¿ãéãã¦ãå¾ã¯AWSã®æ©è½ã§ãã¼ã¿ã使ã£ã¦è²ã ã§ããã£ã¦ãã¨ã¿ããã§ãï¼AWSåå¿è ãªã®ã§ãåéããã¦ãããã¿ã¾ããï¼ã
AWSã¢ã«ã¦ã³ãã®åå¾
ã以ä¸ã®ã¢ãã¬ã¹ããæ°è¦ã¢ã«ã¦ã³ããç»é²ãã¾ãï¼æ¢ã«æã£ã¦ãã人ã¯æ¬¡ã«é²ãã§ãã ãããï¼
ã以ä¸ç»é¢ã®ãIoT ããã¤ã¹ãæ¥ç¶ããã¯ãªãã¯ãã¦ãIoT Coreãã®ç»é¢ã«é·ç§»ãã¾ãã
ããªã·ã¼ã®ç»é²
ããå®å ¨æ§ã->ãããªã·ã¼ããé¸æãã¦ãä½æããã¯ãªãã¯
ãã¢ããã³ã¹ãã¢ã¼ãã«åãæ¿ãã¦ã以ä¸ã®ããã«ã¹ãã¼ãã¡ã³ãã追å ãã¾ãã
ãã¹ãã¼ãã¡ã³ãã®ã³ã¼ãã¯ä»¥ä¸
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:*", "Resource": "*" } ] }
ã¢ãã®ç»é²
ã証ææ¸ä½æãã¦ãã¦ã³ãã¼ããã¾ãã
ã証ææ¸ãå ¨ã¦ãã¦ã³ãã¼ããã¾ããRoot CAã«é¢ãã¦ã¯ãCAãã¦ã³ãã¼ãå ã®ãªã³ã¯ã«ãè¤æ°ã®è¨¼ææ¸ãããã®ã§ãããä¸çªä¸ã®ãVeriSign Class 3 Public Primary G5 root CA certificateãã§OKã§ããã
ã証ææ¸ã«å ã»ã©ã®ããªã·ã¼ãã¢ã¿ãããã¦ããã¾ãããã
ESP32ãã¤ã³ã³å´ã®è¨å®
ãAWS IoTã¨éä¿¡ããããã®MQTTã©ã¤ãã©ãªãå ¥ãã¾ãããã¹ã±ããã-> ãã©ã¤ãã©ãªãã¤ã³ã¯ã«ã¼ãã-> ãã©ã¤ãã©ãªã®ç®¡çãããã©ã¤ãã©ãªããã¼ã¸ã£ã¼ãéãã¦ã以ä¸ã®ããã«ãPubSubClientãã§æ¤ç´¢ãã¾ããè¤æ°åºã¦ãã¾ããã以ä¸ã®èµ¤æ ã®ãã®ãã¤ã³ã¹ãã¼ã«ãã¾ãããã
ãã¾ããããã§ãã±ãããµã¤ãºãå¢ããã¦ããå¿ è¦ãããã¾ãï¼è©³ç´°ã¯æ¬è¨äºæ«å°¾ã®åèãµã¤ãã®è¨äºçãåç §ä¸ããï¼ã
ãPubSubClient.h
ã¨ãããã¡ã¤ã«ãç·¨éãã¾ããç§ã®å ´åã¯ä»¥ä¸ã®å ´æã«ããã¾ããã
~/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.h
ã以ä¸ã®éã2048ã«è¨å®ãã¾ããã
#define MQTT_MAX_PACKET_SIZE 2048
ESP32ãã¤ã³ã³ã¨AWSã®éä¿¡ã¨ã¢ãã¿ãªã³ã°
ãããã§ä¸éãæºåãã§ããã®ã§ãESP32ãã¤ã³ã³ã¨AWSãé£æºããã¦ã¿ã¾ãããã
ãã½ããã¯ãInterfaceãåèãªã³ã¯ã®ãããæ å ±ãå ã«ä½æãã¦ä»¥ä¸ã«å ¬éãã¾ããã
ãESPr Developer 32ã®å ´åã¯ãesp32-iotãã¨ãããã£ã¬ã¯ããªã®ã½ããããM5Stackã®å ´åã¯ãm5stack-iotãã¨ãããã£ã¬ã¯ããªã®ä¸ã®ã½ããã使ãã¾ãããã使ç¨åã«WiFiãAWSã®ç°å¢ã«åããã¦ä»¥ä¸ã®ç©ºæ¬ãxxxã¨ãªã£ã¦ããç®æãä¿®æ£ãã¦ããã¦ä¸ããã
// WiFi Setting const char* ssid = ""; const char* password = ""; // AWS IoT Setting const char* awsEndpoint = "xxx.xxx.xxx.amazonaws.com"; const int awsPort = 8883; const char* pubTopic = "pub01"; const char* rootCA = "-----BEGIN CERTIFICATE-----\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "-----END CERTIFICATE-----\n"; const char* certificate = "-----BEGIN CERTIFICATE-----\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "-----END CERTIFICATE-----\n"; const char* privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "-----END RSA PRIVATE KEY-----\n";
ãArduino IDEã§ãã«ããã¦ãå®è¡ããã¨AWSã¨ã®éä¿¡ãå§ã¾ãã¾ããããã°ã©ã ã¯pub01
ã¨ãããããã¯ã«æéã«å¿ãã¦ã¤ã³ã¯ãªã¡ã³ãï¼å¢å ï¼ãç¶ããæ°åãæãã¦ããã ããªã®ã§ãpub01
ã¨ãããããã¯ãAWSå´ã§ã¢ãã¿ãªã³ã°ãã¦ããã ãã§ãã
ãAWSã®MQTTã¯ã©ã¤ã¢ã³ãã§ãpub01
ã追å ãã¦ããã¾ãã
ããã¨ã¯ã以ä¸ã®ããã«å¢ãã¦ããæ°åãã¢ãã¿ãªã³ã°ã§ãã¾ã
ãM5Stackã§AWSã¨éä¿¡ãã¦ã¢ãã¿ãªã³ã°ãã¦ããæ§åã§ã
ãã©ãã«ã·ã¥ã¼ãã£ã³ã°
ãM5StackãWiFiã«æ¥ç¶ããªããªã£ã¦å°ã£ã¦ãã¾ã£ããã¨ããã£ãã®ã§ããã以ä¸ã®ã¨ããã§è§£æ±ºãã¾ããã
M5Stackã§WiFiç¹ãããããã£ã¦ããã©ãããã«æãããâ¦
— ãããã (@karaage0703) 2018å¹´9æ22æ¥
WiFiã¤ãªãåã«ä»¥ä¸2è¡å ¥ãããããã£ããç¹ãã£ã
WiFi.disconnect(true);
delay(1000); https://t.co/muoYNpKQZm
ãåæ§ã«å°ã£ã¦ãã人ã¯ãWiFi.beginã®åã«ä»¥ä¸ãå ¥ãã¦ã¿ã¾ãããã
WiFi.disconnect(true); delay(1000);
ã¾ã¨ã
ãESP32ãã¤ã³ã³ã¨AWSãé£æºããã¦ã¿ã¾ãããä»åã¯æ°åãã«ã¦ã³ããã¦ã¢ãã¿ãªã³ã°ããã ãã®ä¾ã ã£ãã®ã§ãå°å³ã§å ¨ç¶é¢ç½ãç¡ãã§ãããè²ã IoTçãªå¿ç¨ä¾ãä½ãããã§ãããIoTçãªä½¿ãæ¹ãããã¨ã課é¡ã«ãªããããªã®ã¯é»åã§ãããESP32ãã¤ã³ã³ã¯çé»åã§åããããã£ã¼ãã¹ãªã¼ãã¢ã¼ããæè¼ããã¦ããã®ã§ããã¾ã使ãã°é·æéã®ã¢ãã¤ã«é»æºã§ã®éç¨ãæå¾ ã§ãããã§ãã
ãã¾ãããã®ãããããã¾ã工夫ãã¦ãé¢ç½ãã¢ããªã±ã¼ã·ã§ã³ãä½ããããªã¨æã£ã¦ãã¾ãã
Interface(ã¤ã³ã¿ã¼ãã§ã¼ã¹) 2018å¹´ 09 æå·
- åºç社/ã¡ã¼ã«ã¼: CQåºç
- çºå£²æ¥: 2018/07/25
- ã¡ãã£ã¢: éèª
- ãã®ååãå«ãããã°ãè¦ã
- åºç社/ã¡ã¼ã«ã¼: ã¹ã¤ãããµã¤ã¨ã³ã¹
- ã¡ãã£ã¢: ããã¡ãï¼ããã¼
- ãã®ååãå«ãããã°ãè¦ã
- åºç社/ã¡ã¼ã«ã¼: ã¹ã¤ãããµã¤ã¨ã³ã¹(Switch Science)
- ã¡ãã£ã¢: ããã¡ãï¼ããã¼
- ãã®ååãå«ãããã°ãè¦ã
åèãªã³ã¯
ESP32ãã¤ã³ã³é¢ä¿ã®è¨å®
ESPr Developer 32 で WROOM-32 を Wi-Fi に繋いでみる - Tech Blog by Akanuma Hiroaki
ESP32 の Wi-Fi のみ OFF および温度・湿度・気圧センサー BME280 の再調整など | mgo-tec電子工作
ESP32 ( ESP-WROOM-32 , M5Stack )自分的 トラブルシューティング まとめ | mgo-tec電子工作
ESP32ã¨AWS IoTã¨ã®é£æº
ESP32〜AWS IoTでMQTT通信して詰んだ話【ClientID】
ESP32でAWS IoTに繋いでThing Shadowを弄る – コーヒーサーバは香炉である
ESP32でAWS IoTに繋いでThing Shadowを弄る(2) トラブルシューティング編 – コーヒーサーバは香炉である
ESP32 DeveloperでAWS IoTを動かそうとしてハマったメモ – 1ft-seabass.jp.MEMO
ä½é»åé¢é£
【ESP32】スリープモードについて - ソースに絡まるエスカルゴ