M5Stackを買ってから顔表示するまで

やりたいこと

M5Stackが届いたのでまずは適当なサンプルプログラムを動かしてみたい。

2,3時間で顔表示までできた。

 

必要なもの

- M5STACK-GRAY M5Stack Gray(9軸IMU搭載)

 

5,260円。

9軸IMUはいらんかったかもしれんけど+800円くらいだったのでこっち購入。

 

開発環境整え

なにも設定せずに届いたM5StackをPCに繋いだら起動したので、ラズパイのようにSDカードにOSを書き込んだりは必要ないらしい。

なのでまず開発環境から整えることにする。

下記を参考にm5cloudの設定をする。

M5Stack −LCDとWi-Fi付きの小型マイコン− と開発環境M5Cloudをためしてみる #m5stack | Developers.IO

 

PCにインストールしたもの

- SiLabs CP2104 Driver (USBドライバー。M5Stack内部にCP2104 UART-USBブリッジがあるのでそれ用のドライバ)

- esptool (M5Stackのプログラムを削除したり書いたりするツール。M5StackのマイコンがESP32なのでそれ用の書き込みツール)

M5Cloud/firmwares at master · m5stack/M5Cloud · GitHub ( wifi設定のためのFW。とりあえず最新のm5cloud-20180516-v0.4.0.binを使う )

 

あとは手順通りesptoolでbinを書き込んで、M5Stackにwifi設定を行ってコード取得→m5cloudに登録すればクラウドから開発可能。FWアップデートもwifi経由で行けるので便利。すごい。

 

問題

動かしてみたい顔表示プログラムGitHub - meganetaaan/m5stack-avatar: An M5Stack library for rendering avatar facesc++で記述されているが、m5cloudの対応言語がPython or Luaしかない。

f:id:tango64:20180801105210p:plain

開発環境を変える必要がありそう。

 

開発環境をArduinoに変える

下記をインストール

- EPS32 Arduino Core 

- Arduino IDE側でライブラリのインクルード

M5Stack Documentation

Aruduino IDEはもとからPCに入ってた。

 

次に、顔表示プログラムのLibraryも取り込んであげる

GitHub - meganetaaan/m5stack-avatar: An M5Stack library for rendering avatar faces

 

あとはexampleのface-and-colorとかをコピペして、マイコンボードに書き込んでやる

 

結果

できた

f:id:tango64:20180801112429p:plain

ポチポチボタンを押すと顔が変わる。

 

PlatformIOって何?

M5Stack-AvastarのREADME.mdを見ると、AruduinoIDEとPlatformIOで確認済みとの記述がある。Platform IOってなんだ。

 

Different microcontrollers normally have different developing tools . For instance Arduino rely on Arduino IDE. Few more advanced users set up different graphical interfaces like Eclipse for better project management. Sometimes it may be hard to keep up with different microcontrollers and tools. You probably thought that single unified development tool could be great. Well this is what PlatformIO open source ecosystem is for. 

What is PlatformIO? — PlatformIO 3.6.0a11 documentation

 

なんかマイコンが違っても使える開発ツールらしい。最近だとAtomでも使えるって書いてた。

次はこれを試してみよう。

 

参考

開発環境の整え

M5Stack −LCDとWi-Fi付きの小型マイコン− と開発環境M5Cloudをためしてみる #m5stack | Developers.IO

内部構造の理解

M5stack ( ESP32 搭載 ) を分解したり電源を入れてみて、いろいろ思ったこと | mgo-tec電子工作

後で見る

PlatformIO is an open source ecosystem for IoT development — PlatformIO 3.6.0a11 documentation

ESP32 - Wikipedia