About HDC2010 - temperature and humidity sensor
Texas Instruments HDC2010 it's an high accuracy digital temperature and humidity sensor. Main measurement characteristics:
- relative humidity range 0% - 100%
- humidity accuracy +-2% (factory calibrated)
- temperature from -40C to +125C (functional) and -40C to +80C (operational)
- typical temperature accuracy +-0.2C (factory calibrated)
- embedded heating element to burn away condensation
More info on: HDC2010 datasheet
In June 2019 we've realeased 6 new environmental and air quality sensors, including HDC2010 I2C sensor breakout and HDC2010+CCS811 I2C combo sensors breakout, all being part of the s-Sense I2C sensor breakout family.
s-Sense HDC2010 sensor breakout by itbrainpower.net


PN: SS-HDC2010#I2C SKU: ITBP-6005 HDC2010 I2C sensor breakout info
s-Sense HDC2010+CCS811 sensor breakout by itbrainpower.net


PN: SS-HDC2010+CCS811#I2C SKU: ITBP-6006 HDC2010+CCS811 I2C combo sensor breakout info
Next, let's kickstart with HDC2010 sensor I2C breakout - around 10-15 minutes. Same hardware and software approach may be used for CCS811 + HDC2010 bundle sensors I2C breakout.
Arduino HDC2010 sensor hardware integration (basic wiring)
First, identify if your Arduino it's 5V or 3.3V compliant!
The HDC2010 I2C sensor breakout it's shipped in default auto 3-5V compliant configuration. In a nut shell, wire as bellow:
HDC2010 breakout | Arduino 5V [Eg.: UNO] | Arduino 3.3V [Eg.: Zero] |
---|---|---|
Vin PAD | 5V | 3.3V |
Vdd PAD (3V3) | do not connect | do not connect |
SDA PAD | SDA | SDA |
SCL PAD | SCL | SCL |
GND PAD | GND | GND |
HINT, for some ARDUINO boards:
* SDA (Serial Data) --> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro
* SCK (Serial Clock) --> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro
Bellow, sensor wiring examples, left to right, with Arduino UNO and xyz-mIoT shield [AT SAMD21G, 3.3V compliant, with or without modems]:

![HDC2010 sensor breakout xyz-mIoT [Arduino zero like] shield wiring :: CLICK TO SEE FULL SIZE HDC2010 sensor breakout xyz-mIoT [Arduino zero like] shield wiring](/images/HDC2010_Arduino_wiring_xyz-mIoT.jpg)
Arduino HDC2010 sensor software
a. download HDC2010 Arduino library from: here.
b. unzip the library and install in Arduino libraries folder. Restart Arduino.
c. Make a folder named "ssense_HDC2010_example".
Copy the code bellow, paste it one new file and save the file as "ssense_HDC2010_example.ino" in the folder created in previously or, you may
download it from here (right click & save as): HDC2010 - read sensor data Arduino code
1 | /* s-Sense I2C HDC2010 I2C sensor breakout example - v1.0/20190524. |
2 | * |
3 | * This library it's compatible with: |
4 | * s-Sense HDC2010 I2C sensor breakout [PN: SS-HDC2010#I2C, SKU: ITBP-6005], info https://itbrainpower.net/sensors/HDC2010-TEMPERATURE-HUMIDITY-I2C-sensor-breakout |
5 | * s-Sense CCS811 + HDC2010 I2C sensor breakout [PN: SS-HDC2010+CCS811#I2C, SKU: ITBP-6006], info https://itbrainpower.net/sensors/CCS811-HDC2010-CO2-TVOC-TEMPERATURE-HUMIDITY-I2C-sensor-breakout |
6 | * |
7 | * HDC2010 temperature and humidity (pulling at 2 second) reading example - based on HDC2010 library written |
8 | * by Brandon Fisher and provided by TI. Thank you Brandon! Great job! Read credits bellow and inside the class. |
9 | * We've just add add some variables, functions and functionalities. |
10 | * |
11 | * Mandatory wiring: |
12 | * Common for 3.3V and 5V Arduino boards: |
13 | * sensor I2C SDA <------> Arduino I2C SDA |
14 | * sensor I2C SCL <------> Arduino I2C SCL |
15 | * sensor GND <------> Arduino GND |
16 | * For Arduino 3.3V compatible: |
17 | * sensor Vin <------> Arduino 3.3V |
18 | * For Arduino 5V compatible: |
19 | * sensor Vin <------> Arduino 5V |
20 | * |
21 | * Leave other sensor PADS not connected. |
22 | * |
23 | * SPECIAL note for some ARDUINO boards: |
24 | * SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro |
25 | * SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro |
26 | * |
27 | * WIRING WARNING: wrong wiring may damage your Arduino board MCU or your sensor! Double check what you've done. |
28 | * |
29 | * READ HDC2010 documentation! https://itbrainpower.net/downloadables/hdc2010.pdf |
30 | * |
31 | * You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH s-Sense HDC2010 I2C sensors DEVICES USAGE. Modifications, derivates and redistribution |
32 | * of this software must include unmodified this COPYRIGHT NOTICE. You can redistribute this SOFTWARE and/or modify it under the terms |
33 | * of this COPYRIGHT NOTICE. Any other usage may be permited only after written notice of Dragos Iosub / R&D Software Solutions srl. |
34 | * |
35 | * This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
36 | * or FITNESS FOR A PARTICULAR PURPOSE. |
37 | * |
38 | * |
39 | * itbrainpower.net invests significant time in design phase of our IoT products and in associated software and support resources. |
40 | * Support us by purchasing our environmental and air quality sensors from here https://itbrainpower.net/order#s-Sense |
41 | * |
42 | * |
43 | * |
44 | * Dragos Iosub, Bucharest 2019. |
45 | * https://itbrainpower.net |
46 | */ |
47 | |
48 | /* |
49 | * HDC2010.ino |
50 | * Created: August 1st 2017 |
51 | * This sketch is released AS-IS into the public domain, no guarantee or warranty is given. |
52 | * This Code is not supported by Texas Instruments. |
53 | * |
54 | * Description: This sketch configures the HDC2010 to monitor for a specific temperature |
55 | * and humidity range, with regular one second samples. The temperature and humidity readings |
56 | * of the device are printed to a standard 16x2 LCD display. When the threshold values are |
57 | * exceeded, the LCD will also have "ALT" printed in the bottom right corner. The schematic |
58 | * for this example is included alongside the HDC2010 Arduino Source Code. |
59 | * |
60 | * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ |
61 | * |
62 | * Redistribution and use in source and binary forms, with or without |
63 | * modification, are permitted provided that the following conditions |
64 | * are met: |
65 | * |
66 | * Redistributions of source code must retain the above copyright |
67 | * notice, this list of conditions and the following disclaimer. |
68 | * |
69 | * Redistributions in binary form must reproduce the above copyright |
70 | * notice, this list of conditions and the following disclaimer in the |
71 | * documentation and/or other materials provided with the |
72 | * distribution. |
73 | * |
74 | * Neither the name of Texas Instruments Incorporated nor the names of |
75 | * its contributors may be used to endorse or promote products derived |
76 | * from this software without specific prior written permission. |
77 | * |
78 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
79 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
80 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
81 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
82 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
83 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
84 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
85 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
86 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
87 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
88 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
89 | * |
90 | */ |
91 | |
92 | #define SERIAL_SPEED 19200 |
93 | |
94 | #include <sSense-HDC2010.h> |
95 | |
96 | HDC2010 ssenseHDC2010(HDC2010_I2C_ADDR); |
97 | |
98 | |
99 | float temperature = 0, humidity = 0; |
100 | |
101 | void setup() { |
102 | pinMode(LED_BUILTIN, OUTPUT); |
103 | DebugPort.begin(SERIAL_SPEED); |
104 | delay(5000); |
105 | DebugPort.println("s-Sense HDC2010 I2C sensor."); |
106 | |
107 | // Initialize HDC2010(THS) I2C communication |
108 | ssenseHDC2010.begin(); |
109 | |
110 | // Begin with a HDC2010(THS) reset |
111 | ssenseHDC2010.reset(); |
112 | |
113 | // Set up HDC2010(THS) temperature offset, if required |
114 | //ssenseHDC2010.setTemperatureOffset(0b11010111); //-6.64 degrees Celsius - determine and set your, see definitions and HDC2010 datasheet |
115 | |
116 | // Configure Measurements |
117 | ssenseHDC2010.setMeasurementMode(TEMP_AND_HUMID); // Set measurements to temperature and humidity |
118 | ssenseHDC2010.setRate(ONE_HZ); // Set measurement frequency to 1 Hz |
119 | ssenseHDC2010.setTempRes(FOURTEEN_BIT); |
120 | ssenseHDC2010.setHumidRes(FOURTEEN_BIT); |
121 | |
122 | |
123 | delay(1000); |
124 | |
125 | //begin HDC2010 sensor measuring |
126 | ssenseHDC2010.triggerMeasurement(); |
127 | } |
128 | |
129 | void loop() { |
130 | // read temperature and humidity |
131 | temperature = ssenseHDC2010.readTemp(); |
132 | humidity = ssenseHDC2010.readHumidity(); |
133 | |
134 | DebugPort.print("TEMP(C): "); |
135 | DebugPort.println(temperature); |
136 | |
137 | DebugPort.print("%RH: "); |
138 | DebugPort.println(humidity); |
139 | |
140 | // Wait 2 second for the next reading |
141 | delay(2000); |
142 | } |
143 |
c'. The very same code it's available in Arduino "File-> Examples", under "ssense-HDC2010" library.
d. Compile and upload the code to your Arduino shield. The sensor data may be seen on Arduino Serial Monitor (set to 19200bps).
Advanced HDC2010 Arduino feature [windowed mode]
HDC2010 have some interesting features (read datasheet) - one of them being the temperature and humidity "comfort zone" monitoring.
In a nut shell, the HDC2010 firmware compare the temperature and humidity sampled data with defined comfort zone temperature and humidity upper and lower limits. If sampled data are outside the defined window one interrupt it's generated. Window threshold values and IRQ behavior are user programmable.
HDC2010 - windowed mode Arduino code - written to be compatible with Arduino Zero and xyz-mIoT shields - do this job. As hardware preliminary, just wire the shields as shown in basic wiring, up-here, and add wire between sensor PAD9 [placed on sensor bottom] to D6 on Arduino Zero/xyz-mIoT shield.
1 | /* s-Sense I2C HDC2010 I2C sensor breakout example with confort zone by IRQ - v1.0/20190524. |
2 | * |
3 | * IMPROTANT! IRQ should work for Arduino Zero and xyz-mIoT [AT SAMD21G in Arduino Zero like configuration] |
4 | * |
5 | * This library it's compatible with: |
6 | * s-Sense HDC2010 I2C sensor breakout [PN: SS-HDC2010#I2C, SKU: ITBP-6005], info https://itbrainpower.net/sensors/HDC2010-TEMPERATURE-HUMIDITY-I2C-sensor-breakout |
7 | * s-Sense CCS811 + HDC2010 I2C sensor breakout [PN: SS-HDC2010+CCS811#I2C, SKU: ITBP-6006], info https://itbrainpower.net/sensors/CCS811-HDC2010-CO2-TVOC-TEMPERATURE-HUMIDITY-I2C-sensor-breakout |
8 | * |
9 | * HDC2010 temperature and humidity (pulling at 2 second and confort zone -interrupt based) reading example - based on HDC2010 library written |
10 | * by Brandon Fisher and provided by TI. Thank you Brandon! Great job! Read credits bellow and inside the class. |
11 | * We've just add add some variables, functions and functionalities. |
12 | * |
13 | * Mandatory wiring: |
14 | * Common for 3.3V and 5V Arduino boards: |
15 | * sensor I2C SDA <------> Arduino I2C SDA |
16 | * sensor I2C SCL <------> Arduino I2C SCL |
17 | * sensor GND <------> Arduino GND |
18 | * For Arduino 3.3V compatible: |
19 | * sensor Vin <------> Arduino 3.3V |
20 | * For Arduino 5V compatible: |
21 | * sensor Vin <------> Arduino 5V |
22 | * |
23 | * Optional wiring (only for INTERRUPT detection): |
24 | * sensor PAD9 <------> Arduino D6 |
25 | * |
26 | * Leave other sensor PADS not connected. |
27 | * |
28 | * SPECIAL note for some ARDUINO boards: |
29 | * SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro |
30 | * SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro |
31 | * |
32 | * WIRING WARNING: wrong wiring may damage your Arduino board MCU or your sensor! Double check what you've done. |
33 | * |
34 | * READ HDC2010 documentation! https://itbrainpower.net/downloadables/hdc2010.pdf |
35 | * |
36 | * You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH s-Sense HDC2010 I2C sensors DEVICES USAGE. Modifications, derivates and redistribution |
37 | * of this software must include unmodified this COPYRIGHT NOTICE. You can redistribute this SOFTWARE and/or modify it under the terms |
38 | * of this COPYRIGHT NOTICE. Any other usage may be permited only after written notice of Dragos Iosub / R&D Software Solutions srl. |
39 | * |
40 | * This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
41 | * or FITNESS FOR A PARTICULAR PURPOSE. |
42 | * |
43 | * |
44 | * itbrainpower.net invests significant time in design phase of our IoT products and in associated software and support resources. |
45 | * Support us by purchasing our environmental and air quality sensors from here https://itbrainpower.net/order#s-Sense |
46 | * |
47 | * |
48 | * |
49 | * Dragos Iosub, Bucharest 2019. |
50 | * https://itbrainpower.net |
51 | */ |
52 | |
53 | /* |
54 | * HDC2010.ino |
55 | * Created: August 1st 2017 |
56 | * This sketch is released AS-IS into the public domain, no guarantee or warranty is given. |
57 | * This Code is not supported by Texas Instruments. |
58 | * |
59 | * Description: This sketch configures the HDC2010 to monitor for a specific temperature |
60 | * and humidity range, with regular one second samples. The temperature and humidity readings |
61 | * of the device are printed to a standard 16x2 LCD display. When the threshold values are |
62 | * exceeded, the LCD will also have "ALT" printed in the bottom right corner. The schematic |
63 | * for this example is included alongside the HDC2010 Arduino Source Code. |
64 | * |
65 | * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ |
66 | * |
67 | * Redistribution and use in source and binary forms, with or without |
68 | * modification, are permitted provided that the following conditions |
69 | * are met: |
70 | * |
71 | * Redistributions of source code must retain the above copyright |
72 | * notice, this list of conditions and the following disclaimer. |
73 | * |
74 | * Redistributions in binary form must reproduce the above copyright |
75 | * notice, this list of conditions and the following disclaimer in the |
76 | * documentation and/or other materials provided with the |
77 | * distribution. |
78 | * |
79 | * Neither the name of Texas Instruments Incorporated nor the names of |
80 | * its contributors may be used to endorse or promote products derived |
81 | * from this software without specific prior written permission. |
82 | * |
83 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
84 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
85 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
86 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
87 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
88 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
89 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
90 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
91 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
92 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
93 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
94 | * |
95 | */ |
96 | |
97 | #define SERIAL_SPEED 19200 |
98 | |
99 | #include <sSense-HDC2010.h> |
100 | |
101 | HDC2010 ssenseHDC2010(HDC2010_I2C_ADDR); |
102 | |
103 | |
104 | float temperature = 0, humidity = 0; |
105 | int alarmTHS = 0; |
106 | |
107 | void setup() { |
108 | pinMode(LED_BUILTIN, OUTPUT); |
109 | DebugPort.begin(SERIAL_SPEED); |
110 | delay(5000); |
111 | DebugPort.println("s-Sense HDC2010 I2C sensor test w. confort zone."); |
112 | DebugPort.println("this code was writen for Arduino Zero and xyz-mIoT [AT SAMD21G in Arduino Zero like configuration]"); |
113 | |
114 | // Initialize HDC2010(THS) I2C communication |
115 | ssenseHDC2010.begin(); |
116 | |
117 | // Begin with a HDC2010(THS) reset |
118 | ssenseHDC2010.reset(); |
119 | |
120 | // Set up HDC2010(THS) temperature offset, if required |
121 | //ssenseHDC2010.setTemperatureOffset(0b11010111); //-6.64 degrees Celsius - determine and set your, see definitions and HDC2010 datasheet |
122 | |
123 | |
124 | // Set up HDC2010(THS) comfort zone |
125 | ssenseHDC2010.setHighTemp(28); // High temperature of 28C |
126 | ssenseHDC2010.setLowTemp(24); // Low temperature of 22C |
127 | ssenseHDC2010.setHighHumidity(85); // High humidity of 55% |
128 | ssenseHDC2010.setLowHumidity(20); // Low humidity of 40% |
129 | |
130 | |
131 | // Configure HDC2010(THS) interrupt mode |
132 | ssenseHDC2010.enableInterrupt(); // Enable the Interrupt/DRDY pin |
133 | ssenseHDC2010.enableThresholdInterrupt(); // Enable Interrupt triggering based on comfort zone |
134 | ssenseHDC2010.setInterruptPolarity(ACTIVE_HIGH); // Set Interrupt pin to Active High |
135 | ssenseHDC2010.setInterruptMode(COMPARATOR_MODE); // Set Interrupt to return to inactive state when in bounds |
136 | |
137 | |
138 | // Configure Measurements |
139 | ssenseHDC2010.setMeasurementMode(TEMP_AND_HUMID); // Set measurements to temperature and humidity |
140 | ssenseHDC2010.setRate(ONE_HZ); // Set measurement frequency to 1 Hz |
141 | ssenseHDC2010.setTempRes(FOURTEEN_BIT); |
142 | ssenseHDC2010.setHumidRes(FOURTEEN_BIT); |
143 | |
144 | |
145 | // Configure HDC2010(THS) Interrupt Pin |
146 | pinMode(HDC2010_IRQ_PIN, INPUT); // HDC2010_IRQ_PIN will be the interrupt input |
147 | attachInterrupt(digitalPinToInterrupt(HDC2010_IRQ_PIN), alertTHS, CHANGE); //ISR "alert" will be triggered by changes in HDC2010_IRQ_PIN |
148 | |
149 | |
150 | delay(1000); |
151 | |
152 | //begin HDC2010 sensor measuring |
153 | ssenseHDC2010.triggerMeasurement(); |
154 | } |
155 | |
156 | void loop() { |
157 | // read temperature and humidity |
158 | temperature = ssenseHDC2010.readTemp(); |
159 | humidity = ssenseHDC2010.readHumidity(); |
160 | |
161 | DebugPort.print("TEMP(C): "); |
162 | DebugPort.println(temperature); |
163 | |
164 | DebugPort.print("%RH: "); |
165 | DebugPort.println(humidity); |
166 | |
167 | // Wait 2 second for the next reading |
168 | delay(2000); |
169 | } |
170 | |
171 | // ISR to print alert on "CONFORT ZONE" |
172 | void alertTHS(void) { |
173 | //Load the current state of the THS Alert Pin to the alarmTHS variable |
174 | alarmTHS = digitalRead(HDC2010_IRQ_PIN); |
175 | |
176 | //If the alert pin was high, print ALT |
177 | if (alarmTHS) |
178 | { |
179 | DebugPort.println("OUTSIDE"); |
180 | digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) |
181 | } |
182 | //Otherwise overwrite "ALT" with spaces |
183 | else |
184 | { |
185 | DebugPort.println("INSIDE"); |
186 | digitalWrite(LED_BUILTIN, LOW); // turn the LED on (LOW is the voltage level) |
187 | } |
188 | } |
189 |
This code it's available also in Arduino "File-> Examples", under "ssense-HDC2010" library.
HINT - to port previous code to other Arduino shields (let's say for Arduino UNO):
* step1. identify one IO INTERRUPT capable pin - Arduino UNO you may like chose D2 or D3.
* step2 -variant a. adapt the alertTHS ISR function and attachInterrupt call in a way to be compatible with your board or,
* step2 -variant b. remove the attachInterrupt call in setup() and pull the alertTHS() function in loop(). In this case you may use any available digital IO.
TUTORIAL PROVIDED WITHOUT ANY WARRANTY!!! USE IT AT YOUR OWN RISK!!!!