OK we are now going to look at an HDC1080 attached to the STM32 Nucleo and all development will be done on the Arduino IDE – Install STM32 support in the Arduino IDE
The HDC1080 is a digital humidity sensor with integrated temperature sensor that provides excellent measurement accuracy at very low power. The HDC1080 operates over a wide supply range, and is a low cost, low power alternative to competitive solutions in a wide range of common applications. The humidity and temperature sensors are factory calibrated.
Features
Relative Humidity Accuracy ±2% (typical)
Temperature Accuracy ±0.2°C (typical)
Excellent Stability at High Humidity
14 Bit Measurement Resolution
100 nA Sleep Mode Current
Connection
This was connected to an STM32
STM32 Nucleo connection | Module connection |
3v3 | 3v3 |
GND | GND |
SDA – A4 | SDA |
SCL – A5 | SCL |
Just like this
Code
You will need to download the following library and install it from https://github.com/closedcube/ClosedCube_HDC1080_Arduino , this is the default example
[codesyntax lang=”cpp”]
#include <Wire.h> #include "ClosedCube_HDC1080.h" ClosedCube_HDC1080 hdc1080; void setup() { Serial.begin(9600); Serial.println("ClosedCube HDC1080 Arduino Test"); // Default settings: // - Heater off // - 14 bit Temperature and Humidity Measurement Resolutions hdc1080.begin(0x40); Serial.print("Manufacturer ID=0x"); Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments Serial.print("Device ID=0x"); Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device printSerialNumber(); } void loop() { Serial.print("T="); Serial.print(hdc1080.readTemperature()); Serial.print("C, RH="); Serial.print(hdc1080.readHumidity()); Serial.println("%"); delay(3000); } void printSerialNumber() { Serial.print("Device Serial Number="); HDC1080_SerialNumber sernum = hdc1080.readSerialNumber(); char format[12]; sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast); Serial.println(format); }
[/codesyntax]
Output
Open the serial monitor window and you should expect to see something like this
T=24.90C, RH=40.74%
T=28.24C, RH=0.00%
T=29.56C, RH=66.76%
T=28.53C, RH=54.55%
T=28.12C, RH=45.72%
T=27.80C, RH=41.20%
T=27.50C, RH=39.14%
Links
http://www.ti.com/lit/gpn/hdc1080
http://www.ti.com/lit/pdf/snau189