[아두이노 부품사용법] 아두이노 호환 HTU21D 온습도 센서 모듈

이노팹 2017-01-20 (금) 16:20 1년전 1023  

개요 (Overview)

 

9b33426b5d29e9a23e96d15110d579d3_1484896

 

 

스펙 (Specification)

  • 통신방법: I2C 인터페이스 

  • 습도 정확도:  ±2%

  • 온도 정확도: ±0.3C

  • 습도 측정 범위: 0~100%

  • 3.3V 센서이기 때문에 5V 사용시 10K 저항 사용

 

 

하드웨어 연결 (Wiring)

 

9b33426b5d29e9a23e96d15110d579d3_1484896

 

라이브러리 다운로드: https://github.com/sparkfun/SparkFun_HTU21D_Breakout_Arduino_Library/
 

9b33426b5d29e9a23e96d15110d579d3_1484896

 


 

 

아두이노 코드 (Arduino source code) 

 

 /* 
 HTU21D Humidity Sensor Example Code
 By: Nathan Seidle
 SparkFun Electronics
 Date: September 15th, 2013
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 Uses the HTU21D library to display the current humidity and temperature
 
 Open serial monitor at 9600 baud to see readings. Errors 998 if not sensor is detected. Error 999 if CRC is bad.
  
 Hardware Connections (Breakoutboard to Arduino):
 -VCC = 3.3V
 -GND = GND
 -SDA = A4 (use inline 10k resistor if your board is 5V)
 -SCL = A5 (use inline 10k resistor if your board is 5V)

 */

#include 
#include "HTU21D.h"

//Create an instance of the object
HTU21D myHumidity;

void setup()
{
  Serial.begin(9600);
  Serial.println("HTU21D Example!");

  myHumidity.begin();
}

void loop()
{
  float humd = myHumidity.readHumidity();
  float temp = myHumidity.readTemperature();

  Serial.print("Time:");
  Serial.print(millis());
  Serial.print(" Temperature:");
  Serial.print(temp, 1);
  Serial.print("C");
  Serial.print(" Humidity:");
  Serial.print(humd, 1);
  Serial.print("%");

  Serial.println();
  delay(1000);
} 
.h>

 

 

참고 링크 (Links)

 

 


모바일 버전으로 보기