LoginSignup
20

More than 5 years have passed since last update.

posted at

updated at

ESP32に内蔵プルアップ抵抗はあるか(ある)

ESP32とArduinoと内蔵プルアップ抵抗

ESP32-DevKitC買いました.ESP-WROOM-32開発ボードです.

それはさておき,I2C通信では,SDA/SCLをプルアップする必要があります.Arduinoでは,pinMode(ピン番号, INPUT_PULLUP)とするだけで内蔵のプルアップ抵抗を有効にできます.

意外と知られていない?INPUT_PULLUP | スイッチサイエンス マガジン
Arduino便利な内部でのプルアップ機能 | プログラミングテクニック集キヤミー

では,Arduino っぽく扱える ESP32には内蔵のプルアップ抵抗はあるでしょうか? 結論から言えば,あります.

試してみた

Arduino IDEで,pinModeを切り替えるスケッチを作りました.
esp32_sketch/pullup_test.ino at master · typewriter/esp32_sketch

IO13に抵抗(220Ω)とLEDを繋ぎ,実行します.
プルアップ抵抗があれば,わずかに電流が流れ,LEDがうっすらと光るはずです.

INPUT_PULLUP (プルアップ抵抗有効)

20171128_PB280937_mini.jpg

INPUT (プルアップ抵抗無効)

20171128_PB280938_mini.jpg

OUTPUT HIGH (出力モード, HIGH)

20171128_PB280939_mini.jpg

OUTPUT LOW (出力モード, LOW)

20171128_PB280940_mini.jpg

結果

INPUT_PULLUPでは非常に弱く光り,OUTPUT HIGHでは強く光りました.期待通りです.

そのほか

公式のデータシートにも記載があります.

Most of the digital GPIOs can be configured as internal pull-up or pull-down, or set to high impedance.
(訳: デジタルGPIOの多くで,内部プルアップ・プルダウンやハイインピーダンス状態の設定が出来ます)
- ESP32 Datasheet: http://espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf (4.1.1)

IO34~IO39はプルアップしません.

These input-only pins don't have PU/PD circuits.
(訳: 入力専用ピンにはプルアップ/プルダウン回路はないよ!)
- pinMode(x, INPUT_PULLUP) does not pull up on GPIO34 ... GPIO39 · Issue #316 · espressif/arduino-esp32

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
What you can do with signing up
20