사용하는 세서는 온 습도 센서인 HTU20D 이다. 라이브러리는 HTU21D(F) 까지도 지원한다. 데이터 북은 아래 링크를 확인한다
연결 회로는 아래 그림을 참고한다.
Digital Relative Humidity sensor with Temperature output
센서 라이브러리를 또 아름답게 만들어 주셨다. 라이브러리 주소는 아래와 같다.
https://github.com/TEConnectivity/HTU21D_Arduino_Library
라이브러리를 오른쪽 중간의 [clone or download] 버튼을 눌러 zip 파일로 다운로드를 선택한다. 다운 로드 받은 파일을 압축을 풀면 HTU21D_Arduino_Library-master 폴더 이름으로 압축을 풀고 폴더 통채로 아두이노가 설치된 폴더의 라이브러리 폴더로 복사한다. 보통 C:\Program Files (x86)\Arduino\libraries 폴더가 되겠다.
아두이노 개발환경인 sketch 를 종료하고 다시 실행시킨다. 아두이노와 포트를 확인한 후 파일 - 예제 메뉴에서 모든 아두이노 보드 항목 아래를 보면 TE Connectivity Sensor Solutions HTU21D 가 보이고 그 라애 htu21d_demo 파일을 열어서 컴파일 업로드 하여 실행시키면 결과가 아름답게 나온다.
센서와 라이브러리에 대한 설명
Sensor Description
The HTU2xD(F) sensor is a self-contained humidity and temperature sensor that is fully calibrated during manufacturing. The sensor can operate from 1.5V to 3.6V, has selectable resolution, low battery detection, and checksum capability. The HTU21D has a low current stand-by mode for power-sensitive applications.
Specifications
- Measures relative humidity from 0% to 100%
- Measures temperature from -40°C to 125°C
- Humidity resolution selectable from 8 to 12 bits
- Temperature resolution selectable from 11 to 14 bits
- 0.14 µA sleep current
- 500 µA operating current (during measurement only)
- ±3% accuracy
Library features
- Connection test
- Reset
- Select I2C master mode
- Aquisition resolution management
- Built-in heater management
- Check battery status
- Read serial number
- Temperature and Humidty measurement
- Calculate compensated humidity
- Calculate dew point
소스코드 htu21f_demo 를 아래에 나타낸다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include <htu21d.h> htu21d m_htu21d; void setup() { htu21_battery_status battery_status; htu21_status status; Serial.begin(9600); Serial.println("==== TE Connectivity ===="); Serial.println("======== HTU21D ========="); Serial.println("======== Measure ========="); m_htu21d.begin(); status = m_htu21d.get_battery_status(&battery_status); Serial.println(battery_status == htu21_battery_ok ? "Battery OK" : "Battery LOW"); m_htu21d.set_i2c_master_mode(htu21_i2c_hold); } void loop() { htu21_status status; float temperature; float humidity; boolean connected; connected = m_htu21d.is_connected(); if (connected) { Serial.println(connected ? "Sensor Connected" : "Sensor Disconnected"); status = m_htu21d.read_temperature_and_relative_humidity(&temperature, &humidity); Serial.print("---Temperature = "); Serial.print(temperature, 1); Serial.print((char)176); Serial.println("C"); Serial.print("---Humidity = "); Serial.print(humidity, 1); Serial.println("%RH"); } else { Serial.println(connected ? "Sensor Connected" : "Sensor Disconnected"); } delay(1000); } | cs |
결과화면이 아름답게 나온다.
==== TE Connectivity ====
======== HTU21D =========
======== Measure =========
Battery OK
Sensor Connected
---Temperature = 28.0캜
---Humidity = 16.7%RH
Sensor Connected
---Temperature = 28.0캜
---Humidity = 16.7%RH
Sensor Connected
---Temperature = 28.0캜
---Humidity = 16.7%RH
Sensor Connected
HTU20D(F) RH/T SENSOR IC
Digital Relative Humidity sensor with
Temperature output
u3 가 그 놈이다.
'개발자 > Arduino' 카테고리의 다른 글
| 아두이노 라이브러리 리스트 Arduino Library List 1470개의 라이브러리 모아놓은 곳 (0) | 2018.04.24 |
|---|---|
| MMA8452Q 3축 가속도 센서 모듈 아두이노 코드 digital accelerometer (0) | 2018.04.19 |
| 조도 빛 센서 TMD27723 센서 - ambient light sensing (ALS) (0) | 2018.04.19 |
| bmp180 디지털 압력센서 아두이노 라이브러리 테스트 (0) | 2018.04.19 |
| MS5637 Barometric Pressure Sensor 아두이노 라이브러리와 코드 (0) | 2018.04.19 |
| 아두이노 프로그램 블루투스로 RGB Led 색 제어하는 코드 (0) | 2018.04.17 |
| 센서 보드의 모든 센서와 액츄에이터 구동을 위한 Test 프로그램 소스 (2) | 2018.03.25 |
| 온습도 센서 씨리얼 모니터에 한 번만 표시되는 경우 에러 해결 (0) | 2018.03.25 |
취업, 창업의 막막함, 외주 관리, 제품 부재!
당신의 고민은 무엇입니까? 현실과 동떨어진 교육, 실패만 반복하는 외주 계약,
아이디어는 있지만 구현할 기술이 없는 막막함.
우리는 알고 있습니다. 문제의 원인은 '명확한 학습, 실전 경험과 신뢰할 수 있는 기술력의 부재'에서 시작됩니다.
이제 고민을 멈추고, 캐어랩을 만나세요!
코딩(펌웨어), 전자부품과 디지털 회로설계, PCB 설계 제작, 고객(시장/수출) 발굴과 마케팅 전략으로 당신을 지원합니다.
제품 설계의 고수는 성공이 만든 게 아니라 실패가 만듭니다. 아이디어를 양산 가능한 제품으로!
귀사의 제품을 만드세요. 교육과 개발 실적으로 신뢰할 수 있는 파트너를 확보하세요.
캐어랩