Arduino UnoフォームのESP-WROOM-32 Breakout Board “Unopuino32″ (ウノっぽいの32)
2017年5月25日現在: 評価用ベータ版(v0.3)
<概要>
- ピン配置及び取り付け穴位置がUnoと同一※
- Arduino IDEからの自動書込み対応済
- IO電圧: 3.3V(裏面に5V入力時の分割用の抵抗パターン有)
- 本バージョンではUSB-SerialにCH340を使用している為、以下の制限があります
- シリアルモニタ経由でのリセット時のメッセージの文字化け
- 実行するプログラムには影響ない事は確認済
- Serialのbaud rateを設定した後の通信は問題なし
- Arduino IDEによる書込み時のUpload Speed制限
- “256000”以下を指定 (それ以上では書き込みエラーが発生)
- シリアルモニタ経由でのリセット時のメッセージの文字化け
※ESP32はArduino IDEで開発できるがライブラリレベルでの互換性はないので注意
<仕様>
CPU: ESP-WROOM-32 (技適取得済モジュール)
USB-Serial: CH340 T
Schematics
PINOUT
<開発環境の準備>
- CH340 ドライバーをインストールする
- “Arduino core for the ESP32″をダウンロードし解凍
- Arduino インストールフォルダの hardware フォルダに、espressif フォルダを作成
- espressif フォルダの中に esp32 フォルダを作成
- 解凍した”Arduino core for the ESP32″の中身を esp32 フォルダ内にコピー
- espressif\esp32\tools にある get.exe を実行しコマンドプロンプトが消えるまで待つ
- Arduino IDEを立ち上げると”ツール”->”ボード”でESP32が選択できる
<関連リンク>
Design Data (Open Source Hardware):
Schematic & Board Layout Data (KiCad)
CH340ドライバー:
ESP-WROOM-32 Information (ESPRESSIF web site)
ESP-WROOM-32 Schematic and layout
<覚書(随時更新)>
- サーボを使うときはLEDとして扱うと動くらしい(未確認)
- Neopixel(WS2812)を使う(Mr. MartyMacGyver’s code)
- I2Cを使う時は標準のwire関数の引数にピンを指定する
- int SDA32 = 22;
- int SCL32 = 23;
- Wire.begin(SDA32, SCL32);
- ESP32/ESP8266用I2C OLED(SSD1306)ライブラリ
- https://github.com/squix78/esp8266-oled-ssd1306
- Unopuino32用であればI2Cピン指定を以下の様に修正
- SSD1306 display(0x3c, 22, 23); // slvAdr, SDA, SCL
- タイマー割り込みを使う
- ESP32 example sketchの”RepeatTimer”を参考に以下をコードに追加// Timer Interrupt setting
hw_timer_t * timer = NULL;
volatile SemaphoreHandle_t timerSemaphore;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;void IRAM_ATTR onTimer(){
// Increment the counter and set the time of ISR
portENTER_CRITICAL_ISR(&timerMux);// ここにタイマー割り込みで実行するコードを記載portEXIT_CRITICAL_ISR(&timerMux);
// Give a semaphore that we can check in the loop
xSemaphoreGiveFromISR(timerSemaphore, NULL);
// It is safe to use digitalRead/Write here if you want to toggle an output
}void setup() {// Create semaphore to inform us when the timer has fired
timerSemaphore = xSemaphoreCreateBinary();// Use 1st timer of 4 (counted from zero).
// Set 80 divider for prescaler (see ESP32 Technical Reference Manual for more info).
timer = timerBegin(0, 80, true);// Attach onTimer function to our timer.
timerAttachInterrupt(timer, &onTimer, true);// Set alarm to call onTimer function every second (value in microseconds).
// Repeat the alarm (third parameter)
timerAlarmWrite(timer, 1000, true);// Start an alarm
timerAlarmEnable(timer);
}
- ESP32 example sketchの”RepeatTimer”を参考に以下をコードに追加// Timer Interrupt setting