- Connect Vin to the power supply, 3-5V is fine. (red wire on STEMMA QT version) Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
- Connect GND to common power/data ground (black wire on STEMMA QT version)
- Connect the SCL pin to the I2C clock SCL pin on your Arduino. (yellow wire on STEMMA QT version) On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
- Connect the SDA pin to the I2C data SDA pin on your Arduino. (blue wire on STEMMA QT verison) On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2
The HTU21D-F has a default I2C address of 0x40 and cannot be changed!
Download Adafruit_HTU21DF
To begin reading sensor data, you will need to download the Adafruit HTU21DF library from the Arduino library manager.
Open up the Arduino library manager:
Search for the Adafruit HTU21DF library and install it
We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Load Demo
Open up File->Examples->Adafruit_HTU21DF->HTU21DFtest and upload to your Arduino wired up to the sensorYou can create the Adafruit_HTU21DF object with:
Adafruit_HTU21DF htu = Adafruit_HTU21DF()
Then initialize the sensor with:
htu.begin()
Once initialized, you can query the temperature in °C with
htu.readTemperature()
Reading the humidity is equally simple. Call
htu.readHumidity()