LoginSignup
0
0

More than 1 year has passed since last update.

ESP32-WROOM-32とSHTC3高精度デジタル温度および湿度センサー測定モジュール(I2C通信)

Last updated at Posted at 2022-07-18

外見

SHTC3.jpg

ピン説明

1.VDD(3.3~5.5v DC)
2.GND
3.SDA
4.SCL

性能

1.湿度の測定範囲:0~100% rh
2.湿度測定の精度:±2% rh
3.温度測定範囲:-40~125℃
4.温度測定の精度:±0.2℃
5.動作電圧:3.3~5.5V DC
6.I2Cインターフェイス出力(デフォルトアドレス0x70)

開発環境

・Visual Studio Code(ver 1.69.2)
・PlatformIO(Core 6.1.1 home 3.4.2)
 [追加ライブラリ]Adafruit SHTC3 Library

ソースコード(ほぼサンプルコードのまま)

・使用するピン
 21:SDA(i2c)
 22:SCL(i2c)

#include <Arduino.h>
#include <Adafruit_SHTC3.h>

TwoWire i2c(1);
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();

void setup() {
  Serial.begin(115200);

  while (!Serial)
    delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("SHTC3 test");
  i2c.begin(21, 22);
  if (! shtc3.begin(&i2c)) {
    Serial.println("Couldn't find SHTC3");
    while (1) delay(1);
  }
  Serial.println("Found SHTC3 sensor");
}


void loop() {
  sensors_event_t humidity, temp;
  
  shtc3.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  
  Serial.print("Temp:"); Serial.print(temp.temperature); Serial.print("C ");
  Serial.print("Humi:"); Serial.print(humidity.relative_humidity); Serial.print("%\n");

  delay(1000);
}

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