Home CodeArduino Micro:bit and HDC2080 sensor example using the Arduino IDE

Micro:bit and HDC2080 sensor example using the Arduino IDE

by shedboy71

In this article we look at yet another humidity and temperature sensor from TI – this time its the HDC2080 which we will connect up to a Micro:bit

Lets look at some of the technical information and data from TI

HDC2080 Information

The HDC2080 device is an integrated humidity and temperature sensor that provides high accuracy measurements with very low power consumption in a small DFN package. The capacitive-based sensor includes new integrated digital features and a heating element to dissipate condensation and moisture. The HDC2080 digital features include programmable interrupt thresholds to provide alerts and system wake-ups without requiring a microcontroller to be continuously monitoring the system. Combined with programmable sampling intervals, a low power consumption, and a support for a 1.8-V supply voltage, the HDC2080 is designed for battery-operated systems.

The HDC2080 provides high accuracy measurement capability for a wide range of environmental monitoring and Internet of Things (IoT) applications such as smart thermostats and smart home assistants. For designs where printed-circuit board (PCB) area is critical, a smaller CSP package option is available thru the HDC2010 with complete software compatibility with the HDC2080.

For applications with strict power-budget restrictions, Auto Measurement Mode enables the HDC2080 to automatically initiate temperature and humidity measurements. This feature allows users to configure a microcontroller into deep sleep mode because the HDC2080 is no longer dependent upon the microcontroller to initiate a measurement.

Programable temperature and humidity thresholds in the HDC2080 allow the device to send a hardware interrupt to wake up the microcontroller when necessary. In addition, the power consumption of the HDC2080 is significantly reduced, which helps to minimize self-heating and improve measurement accuracy.

The HDC2080 is factory-calibrated to 0.2°C temperature accuracy and 2% relative humidity accuracy.

Features

Relative humidity range: 0% to 100%
Humidity accuracy: ±2% (typical), ±3% (maximum)
Temperature accuracy: ±0.2°C (typical), ±0.4°C (maximum)
Sleep mode current: 50 nA (typical), 100 nA (maximum)
Average supply current (1 measurement/second)
300 nA: RH% only (11 bit)
550 nA: RH% (11 bit) + temperature (11 bit)

Temperature range:
Operating: –40°C to 85°C
Functional: –40°C to 125°C
Supply voltage range: 1.62 V to 3.6 V

 

Parts Required

I connected a expansion board to a Micro:bit and then the sensor via connecting wire

Schematic/Connection

This is a 3.3v rated sensor even though the pin says Vcc

microbit and hdc2080

microbit and hdc2080

Code Example

I used the library from https://github.com/tinkeringtech/HDC2080_breakout

This is the default example with a few cosmetic changes

[codesyntax lang=”cpp”]

#include <HDC2080.h>

#define ADDR 0x40
HDC2080 sensor(ADDR);

float temperature = 0, humidity = 0;

void setup() {

  Serial.begin(9600);
  Serial.println("TinkeringTech HDC2080 Test");

  // Initialize I2C communication
  sensor.begin();
    
  // Begin with a device reset
  sensor.reset();
  
  // Set up the comfort zone
  sensor.setHighTemp(48);         // High temperature of 28C
  sensor.setLowTemp(2);          // Low temperature of 22C
  sensor.setHighHumidity(95);     // High humidity of 55%
  sensor.setLowHumidity(10);      // Low humidity of 40%
  
  // Configure Measurements
  sensor.setMeasurementMode(TEMP_AND_HUMID);  // Set measurements to temperature and humidity
  sensor.setRate(ONE_HZ);                     // Set measurement frequency to 1 Hz
  sensor.setTempRes(FOURTEEN_BIT);
  sensor.setHumidRes(FOURTEEN_BIT);
  
  //begin measuring
  sensor.triggerMeasurement();
}

void loop() {

  Serial.print("Temperature (C): "); 
  Serial.print(sensor.readTemp());
  Serial.print("\t\tHumidity (%): "); 
  Serial.println(sensor.readHumidity());
  
  // Wait 1 second for the next reading
  delay(2000);
  
}

[/codesyntax]

 

Output

Open the serial monitor and you should see something like this

Temperature (C): 21.42 Humidity (%): 43.31
Temperature (C): 21.42 Humidity (%): 43.32
Temperature (C): 21.42 Humidity (%): 43.35
Temperature (C): 21.42 Humidity (%): 43.33
Temperature (C): 21.73 Humidity (%): 42.86
Temperature (C): 24.37 Humidity (%): 45.18
Temperature (C): 25.30 Humidity (%): 49.11
Temperature (C): 25.90 Humidity (%): 53.62
Temperature (C): 26.44 Humidity (%): 57.36
Temperature (C): 26.94 Humidity (%): 60.30
Temperature (C): 27.17 Humidity (%): 65.88
Temperature (C): 26.42 Humidity (%): 63.08

 

Links

https://www.ti.com/lit/gpn/hdc2080

 

Summary

A nice little sensor but at just over $8 there are cheaper sensors available which have the same functionality.

You may also like

Leave a Comment