LoginSignup
0
0

More than 1 year has passed since last update.

M5StickC PlusでGrove温湿度センサ(DHT11)を試す

Last updated at Posted at 2021-08-12

1. 外観

温度と湿度を表示するだけ。

DSC_0230_2.JPG

2. 環境

3. 接続

Groveの4ピンケーブルで接続するだけ。

M5StickC Plus Grove 温湿度センサ Memo
G (GND) GND -
V OUT (5V) VCC +
G32 NC 接続なし
G33 SIG 信号

4. ライブラリのインストール

Arduino IDEのライブラリマネージャで Grove Temperature And humidity Sensor を検索し、インストールしておきます。

5. スケッチ

Temp_Humi_DHT11.ino
#include <M5StickCPlus.h>
#include <DHT.h>

DHT dht(33, DHT11);     // センサ初期化(G33使用, センサータイプはDHT11)

void setup() {
  M5.begin();
  M5.Axp.ScreenBreath(9);     // 7(2.5V) -> 12(3.0V)
  M5.Lcd.setRotation(1);      // 画面の向き
  M5.Lcd.fillScreen(BLACK);   // 黒で塗りつぶし
  M5.Lcd.setTextSize(2);      // テキストサイズを指定

  dht.begin();
}

void loop() {
  delay(5000);
  float tmp = dht.readTemperature();    // 温度Cの読み取り
  float hum = dht.readHumidity();       // 湿度%の読み取り

  M5.Lcd.setCursor(0, 0);               // 基本位置決め
  M5.Lcd.printf("\n");
  M5.Lcd.printf(" Temperature:\n");
  M5.Lcd.printf("  %4.1f 'C\n", tmp);    // 温度を表示
  M5.Lcd.printf(" Humidity:\n");
  M5.Lcd.printf("  %4.1f %%\n", hum);   // 湿度を表示
}

以上です。

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