HTU21D - Temperature and Humidity Sensor

/media/uploads/hwing91/temp._and_hum._sensor.png

This is a highly accurate, digital humidity and temperature sensor with an I2C interface. The breakout board includes built in 4.7k pull up resistors. Under references, you can find links to the sensor’s schematic, data sheet and where to purchase it.

/media/uploads/hwing91/temp._and_hum._wire_chart.png

Hello World!

Import libraryHTU21D_HELLOWORLD

This code uses a uLCD-144-G2 128 by 128 Smart Color LCD to display the humidity and temperature in celcius, kelvin, and fahrenheit.

/media/uploads/hwing91/wp_20140327_20_49_15_pro__highres.jpg /media/uploads/hwing91/zoom_on_lcd.png

API

HTU21D(PinName sda, PinName scl)

Constructor function, declares sensor.

int sample_ctemp(void)

Samples the temperature, input void, outputs an int in celcius.

int sample_ftemp(void)

Samples the temperature, input void, outputs an int in fahrenheit.

int sample_ktemp(void)

Samples the temperature, input void, outputs an int in kelvin.

int sample_humid(void)

Samples the humidity, input void, outputs and int.

Library

Import libraryHTU21D

BASIC LIBRARY TO INTERFACE WITH HTU21D TEMPERATURE AND HUMIDITY SENSOR

Reference

Link to HTU21D schematic:

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/HTU21D%20Breakout.pdf

Link to HTU21D Data Sheet:

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/HTU21D.pdf

Link to purchase the sensor:

https://www.sparkfun.com/products/12064


1 comment on HTU21D - Temperature and Humidity Sensor:

10 Feb 2016

If you come to Guadalajara, Jalisco, Mexico, I'll give you a beer, or even better a tequila

Please log in to post comments.