17
13

More than 5 years have passed since last update.

ESP32 > M5Stack > Hello world!

Last updated at Posted at 2018-01-16

M5Stack Arduino Library

IMG_6865.jpg

Arduino用のESP32設定

arduino-esp32/mac.md at master · espressif/arduino-esp32 · GitHub


[mkdir \-p ~/Documents/Arduino/hardware/espressif && \\
cd ~/Documents/Arduino/hardware/espressif && \\
git clone https://github\.com/espressif/arduino\-esp32\.git esp32 && \\
cd esp32 && \\
git submodule update \-\-init \-\-recursive && \\
cd tools && \\
python get\.py](https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/mac.md)

結果は以下。
もしエラーがでたらXcodeを入れてない場合があるとのこと。
その後、Arduinoを再起動する。


macbook-pro:~ atsu$ mkdir -p ~/Documents/Arduino/hardware/espressif && \
> cd ~/Documents/Arduino/hardware/espressif && \
> git clone https://github.com/espressif/arduino-esp32.git esp32 && \
> cd esp32 && \
> git submodule update --init --recursive && \
> cd tools && \
> python get.py
Cloning into 'esp32'...
remote: Counting objects: 6872, done.
remote: Total 6872 (delta 0), reused 0 (delta 0), pack-reused 6872
Receiving objects: 100% (6872/6872), 103.62 MiB | 5.95 MiB/s, done.
Resolving deltas: 100% (3902/3902), done.
Submodule 'libraries/BLE' (https://github.com/nkolban/ESP32_BLE_Arduino.git) registered for path 'libraries/BLE'
Cloning into '/Users/atsu/Documents/Arduino/hardware/espressif/esp32/libraries/BLE'...
Submodule path 'libraries/BLE': checked out 'f8fe9d7cdfb20caa54b70849826d1ac6e375ff78'
System: Darwin, Info: Darwin-17.3.0-x86_64-i386-64bit
Platform: x86_64-apple-darwin
Downloading xtensa-esp32-elf-osx-1.22.0-75-gbaf03c2-5.2.0.tar.gz
Done
Extracting xtensa-esp32-elf-osx-1.22.0-75-gbaf03c2-5.2.0.tar.gz
Downloading esptool-4dab24e-macos.tar.gz
Done
Extracting esptool-4dab24e-macos.tar.gz
Downloading mkspiffs-0.2.1-osx.tar.gz
Done
Extracting mkspiffs-0.2.1-osx.tar.gz
Renaming mkspiffs-0.2.1-osx to mkspiffs
Done
macbook-pro :tools atsu$ 

Arduinoを再起動したのち、ツール>ボード>ボードマネージャーでみると、下部の方にEPS32関係がけっこうな数で増えてると思います。

その中にM5Stack-Core-ESP32 があるので選択します。

スクリーンショット 2018-01-15 22.16.07.png

Driverのインストール

以下のページからMac用のドライバをダウンロード&インストールします。

USB - UART ブリッジ VCP ドライバ|Silicon Labs

スクリーンショット 2018-01-15 22.19.29.png

解答したdmgファイルを実行します。
これでようやくインストーラーで出て来ます。

Silicon Labs VCP Drivers.pkgファイルがでるので実行します。
内容を確認しながら「続ける」ボタンを押しながら先へ進めます。
「インストールが完了しました」画面が表示されれば完了です。

スクリーンショット 2018-01-15 22.20.38.png

Kobito.tMjgOO.png

Arduinoを再起動します。

シリアルポートの選択

ツール>シリアルポート> /dev/cu.SLAB_USBtoUART を選びます。
スクリーンショット 2018-01-16 20.27.28.png

シリアルポートに現れない場合は、セキュリティでブロックされている場合があります。
Kobito.Bfi6RQ.png

シリアルモニタを表示してM5Stackを起動すると、以下のように表示されます。

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:11904
entry 0x40078a3c
M5Stack initializing...OK
Lines                    119133
Horiz/Vert Lines         15814
Rectangles (outline)     10469
Rectangles (filled)      369251
Circles (filled)         78863
Circles (outline)        67381
Triangles (outline)      26526
Triangles (filled)       135928
Rounded rects (outline)  32705
Rounded rects (filled)   393283
Done!
MPU9250 I AM FF I should be 71

scan start
scan done
4 networks found
1: IODATA-7c5a71-2G (-64)*
2: G2-E1 (-66)*
3: BBIQRT-397f61d-gw (-67)*
4: BBIQRT-397f61d-g (-70)*

Listing directory: /
Failed to open directory
Writing file: /hello.txt
Failed to open file for writing
Reading file: /hello.txt
Failed to open file for reading

3つのボタンを押すとそれぞれA,B,Cとシリアルモニタに反応があります。

ライブラリ

Using the Arduino IDE Library Manager

Choose Sketch -> Include Library -> Manage Libraries...
Type m5stack into the search box.
ライブラリマネージャーの検索BOXERSで「m5stack 」と入力すると候補が出来てきます。

スクリーンショット 2018-01-15 22.28.13.png

インストールをボタンを押して、ライブラリマネージャーを閉じ、

ファイル>スケッチ例>M5Stackがメニューに追加されています。
スクリーンショット 2018-01-15 22.29.54.png

出荷状態でM5Stackに入っているのは 
スケッチブック例>M5Stack> Basics > FactoryTestが入っているようです。

Hello world!

スケッチブック例>M5Stack> Basics>Hello を選択します。

スクリーンショット 2018-01-16 21.05.46.png

#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // Initialize the M5Stack object
  M5.begin();

  // LCD display
  M5.Lcd.printf("hello world");
}

// the loop routine runs over and over again forever
void loop() {

}

マイコンボードに書込むボタンを押すとしばらくすると書き込みが完了します。
書き込みログは以下です。

Archiving built core (caching) in: /var/folders/7d/z26fd_mn7zd4tf3rs2196rf40000gn/T/arduino_cache_85147/core/core_espressif_esp32_m5stack-core-esp32_FlashMode_qio,FlashFreq_80,UploadSpeed_921600,DebugLevel_none_f099e8e13606c2545c83d5359bb75f2a.a
最大1310720バイトのフラッシュメモリのうち、スケッチが207563バイト(15%)を使っています。
最大294912バイトのRAMのうち、グローバル変数が12076バイト(4%)を使っていて、ローカル変数で282836バイト使うことができます。
esptool.py v2.1
Connecting........__
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 18586.6 kbit/s)...
Hash of data verified.
Compressed 14128 bytes to 9213...

Writing at 0x00001000... (100 %)
Wrote 14128 bytes (9213 compressed) at 0x00001000 in 0.1 seconds (effective 913.7 kbit/s)...
Hash of data verified.
Compressed 208704 bytes to 115371...

Writing at 0x00010000... (12 %)
Writing at 0x00014000... (25 %)
Writing at 0x00018000... (37 %)
Writing at 0x0001c000... (50 %)
Writing at 0x00020000... (62 %)
Writing at 0x00024000... (75 %)
Writing at 0x00028000... (87 %)
Writing at 0x0002c000... (100 %)
Wrote 208704 bytes (115371 compressed) at 0x00010000 in 2.0 seconds (effective 819.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 122...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (122 compressed) at 0x00008000 in 0.0 seconds (effective 5262.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...

M5Stackに目を移すと、hello world と表示されています。
IMG_6865.jpg

初期状態(出荷状態)に戻すには
スケッチブック例>M5Stack> Basics > FactoryTest を書き込みます。

今回はこれまでです。

17
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
13