Home Code Raspberry Pi and HDC1008 temperature sensor

Raspberry Pi and HDC1008 temperature sensor

by shedboy71

The HDC1008 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 HDC1008 is placed on the bottom part of the device, which makes the HDC1008 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






Save the following as HDC1008.py

[codesyntax lang=”python”]

import smbus
import time

# Get I2C bus
bus = smbus.SMBus(1)

# HDC1000 address, 0x40
bus.write_byte_data(0x40, 0x02, 0x30)

# Send temp measurement command
bus.write_byte(0x40, 0x00)


# Read temp data
data0 = bus.read_byte(0x40)
data1 = bus.read_byte(0x40)

# Convert the data
temp = (data0 * 256) + data1
celsTemp = (temp / 65536.0) * 165.0 - 40
fahrTemp = celsTemp * 1.8 + 32

# Send humidity measurement command
bus.write_byte(0x40, 0x01)

# Read humidity data
data0 = bus.read_byte(0x40)
data1 = bus.read_byte(0x40)

# Convert the data
humidity = (data0 * 256) + data1
humidity = (humidity / 65536.0) * 100.0

# Output data
print "Relative Humidity : %.2f %%" %humidity
print "Temperature in Celsius : %.2f C" %celsTemp
print "Temperature in Fahrenheit : %.2f F" %fahrTemp



Run the following from the command line using sudo python HDC1008.py



HDC1008 Temperature Humidity Sensor Breakout Board for Arduino

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More