In this example we will show the temperature and humidity readings from a HDC100x series sensor and display this on a 16×2 LCD.
First lets take a look at the sensor
The HDC1000 is a digital humidity sensor with integrated temperature sensor that provides excellent measurement accuracy at very low power. The device measures humidity based on a novel capacitive sensor. The humidity and temperature sensors are factory calibrated.
The sensing element of the HDC1000 is placed on the bottom part of the device, which makes the HDC1000 more robust against dirt, dust, and other environmental contaminants. The HDC1000 is functional within the full –40°C to +125°C temperature range.
Key Features
- Relative Humidity (RH) Operating Range 0% to 100%
- 14 Bit Measurement Resolution
- Relative Humidity Accuracy ±3%
- Temperature Accuracy ±0.2°C
- Supply Voltage 3 V to 5 V
- I2C Interface
Connection information
The easiest way is to purchase some sort of breakout like the one pictured earlier
Connect Vin to 5VDC
Connect GND to ground
Connect SCL to A5 on UNO
Connect SDA to A4 on UNO
I used the headers on the LCD keypad shield, here is a picture of this
Parts
1 x Arduino Uno
1 x LCD Keypad shield
1 x HDC1008 breakout
Dupont hookup cable x 4
Code
The good folks at Adafruit have done the hard work and produced a library for this device – https://github.com/adafruit/Adafruit_HDC1000_Library . If you are using Arduino IDE 1.6.5 or later you can easily import this library by going to Sketch -> Include Library -> Manage Libraries
[codesyntax lang=”cpp”]
#include <Wire.h> #include "Adafruit_HDC1000.h" #include <LiquidCrystal.h> //setup for the LCD keypad shield LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // Connect Vin to 5VDC // Connect GND to ground // Connect SCL to A5 on UNO // Connect SDA to A4 on UNO Adafruit_HDC1000 hdc = Adafruit_HDC1000(); void setup() { Serial.begin(9600); Serial.println("HDC100x test"); //lcd setup lcd.begin(16,2); lcd.setCursor(0,0); lcd.print("Temp: "); //line 2 - humidity lcd.setCursor(0,1); lcd.print("Humidity: "); if (!hdc.begin()) { Serial.println("Couldn't find sensor!"); while (1); } } void loop() { Serial.print("Temp: "); Serial.print(hdc.readTemperature()); Serial.print("\t\tHum: "); Serial.println(hdc.readHumidity()); lcd.setCursor(7,0); lcd.print(hdc.readTemperature()); lcd.setCursor(11,1); lcd.print(hdc.readHumidity()); delay(500); }
[/codesyntax]
Links
Adafruit HDC1008 Temperature & Humidity Sensor Breakout Board
1602 LCD Keypad Shield for Arduino