0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ESP32入門】CO2モニターを作る #1 環境構築編

0
Last updated at Posted at 2026-05-26

【はじめに】
電子工作初心者の私がESP32を使ってCO2モニターを自作した記録です。
プログラミング経験はほぼゼロからのスタートです。同じように初心者の方の参考になれば嬉しいです。
このシリーズでは以下のものを最終的に作ります。

1.CO2濃度をリアルタイムで計測
2.LCDにレベル表示(Good/Caution/Warning/Danger)
3.RGB LEDで色表示
4.ブラウザでグラフ表示(時刻付き)
5.1000ppm超えたらGmailで通知

【使用環境】
PC:MacBook Air M4
OS:macOS
Arduino IDE:2.3.8
マイコン:ESP32-WROOM-32E

Arduino IDEのインストール
① Arduino公式サイトからダウンロード
https://www.arduino.cc/en/software
macOS用のインストーラーをダウンロードしてインストールします。

② ESP32ボードを追加する
Arduino IDEだけではESP32に書き込めません。ESP32用のボードパッケージを追加する必要があります。
Arduino IDE → 環境設定 を開き、「追加のボードマネージャURL」に以下を入力します。
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
次に ツール → ボード → ボードマネージャ を開き、esp32 と検索してインストールします。

③ ボードを選択する
ツール → ボード → ESP32 Arduino → ESP32 Dev Module を選択します。

【動作確認(Lチカ)】
環境構築ができたら、まずLEDを点滅させて動作確認します。
配線:
ESP32LEDGPIO2LED + 側GNDLED − 側(抵抗経由)
【コード】

void setup() {
  pinMode(2, OUTPUT);
}

void loop() {
  digitalWrite(2, HIGH);
  delay(1000);
  digitalWrite(2, LOW);
  delay(1000);
}

書き込んでLEDが1秒ごとに点滅すれば環境構築完了です!

【つまずいたポイント】
1.ポートが認識されない
USBケーブルが充電専用だと書き込みできません。データ転送対応のケーブルを使いましょう。
2.ボードが表示されない
USBケーブルを抜き差しして ツール → ポート で再確認しましょう。

【まとめ】
Arduino IDEをインストールした
ESP32ボードパッケージを追加した
Lチカで動作確認できた

次回はMH-Z19C CO2センサーを接続してデータを取得します!

#2 CO2センサー編へ続く

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?