Home CodeArduino Microbit and HDC1080 humidity and temperature sensor example

Microbit and HDC1080 humidity and temperature sensor example

by shedboy71

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

 

 MIcrobit connection  Module connection
 3v3 3v3
 GND  GND
 SDA – 20  SDA
 SCL – 21  SCL

 

Code

I needed to modify the   https://github.com/closedcube/ClosedCube_HDC1080_Arduino library, otherwise there was compilation errors

You need to change Wire.write(0x00); to Wire.write((byte)0x00); – Modified HDC1080 library

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

ClosedCube HDC1080 Arduino Test
Manufacturer ID=0x54T=23.06C, RH=51.07%
T=23.06C, RH=51.07%
T=23.08C, RH=51.05%
T=23.08C, RH=51.15%
T=23.10C, RH=51.15%
T=23.11C, RH=51.15%
T=23.11C, RH=51.05% ClosedCube_HDC1080_Arduino-master

 

Links

1PC 2.7 V to 5.5 V HDC1080 high precision temperature and humidity sensor humidity temperature module

http://www.ti.com/lit/gpn/hdc1080

http://www.ti.com/lit/pdf/snau189

You may also like

Leave a Comment