Beaglebone and HDC1080 humidity and temperature sensor python example

In this article we look at another sensor – this time its the HDC1080 and we will connect it to our Beaglebone and we will have a python example

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
  • Average Supply Current:
    • 710 nA @ 1sps, 11 bit RH Measurement
    • 1.3 µA @ 1sps, 11 bit RH and Temperature
      Measurement
  • Supply Voltage 2.7 V to 5.5 V
  • I2C Interface

Parts Required

Name Link
Beaglebone BeagleBone Black TI AM335x Cortex-A8 development BB-Black Rev.C
HDC1080 HDC1080 Sensor Module Temperature Humidity Sensor High precision Module
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Connection

Beaglebone Module
3.3v – P9.3 Vcc
Gnd – P9.1 Gnd
SDA – P9.20 SDA
SCL – P9.19 SCL

 

Code

Navigate to https://github.com/switchdoclabs/SDL_Pi_HDC1000 and create a folder using Cloud9 on your beaglebone. One of these files is the library – SDL_Pi_HDC1000.py

This is the example

[codesyntax lang=”python”]

import sys          
import time
import datetime
import SDL_Pi_HDC1000



# Main Program

print ""
print "Test SDL_Pi_HDC1000 Version 1.1 - SwitchDoc Labs" 
print ""
print "Sample uses 0x40 and SwitchDoc HDC1000 Breakout board "
print "Program Started at:"+ time.strftime("%Y-%m-%d %H:%M:%S")
print ""

hdc1000 = SDL_Pi_HDC1000.SDL_Pi_HDC1000()

print "------------"
print "Manfacturer ID=0x%X"% hdc1000.readManufacturerID()  
print "Device ID=0x%X"% hdc1000.readDeviceID()  
print "Serial Number ID=0x%X"% hdc1000.readSerialNumber()  
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()
# turn heater on
print "turning Heater On" 
hdc1000.turnHeaterOn() 
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()
# turn heater off
print "turning Heater Off"
hdc1000.turnHeaterOff() 
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()

# change temperature resolution
print "change temperature resolution"
hdc1000.setTemperatureResolution(SDL_Pi_HDC1000.HDC1000_CONFIG_TEMPERATURE_RESOLUTION_11BIT)
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()
# change temperature resolution
print "change temperature resolution"
hdc1000.setTemperatureResolution(SDL_Pi_HDC1000.HDC1000_CONFIG_TEMPERATURE_RESOLUTION_14BIT)
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()

# change humdity resolution
print "change humidity resolution"
hdc1000.setHumidityResolution(SDL_Pi_HDC1000.HDC1000_CONFIG_HUMIDITY_RESOLUTION_8BIT)
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()
# change humdity resolution
print "change humidity resolution"
hdc1000.setHumidityResolution(SDL_Pi_HDC1000.HDC1000_CONFIG_HUMIDITY_RESOLUTION_14BIT)
# read configuration register
print "configure register = 0x%X" % hdc1000.readConfigRegister()

while True:
        
        print "-----------------"
        print "Temperature = %3.1f C" % hdc1000.readTemperature()
        print "Humidity = %3.1f %%" % hdc1000.readHumidity()
        print "-----------------"

        time.sleep(3.0)

[/codesyntax]

 

Output

You can see the results below – you could get rid of the non temperature and humidity readings

debian@beaglebone:/var/lib/cloud9/iain/HDC1080$ python testHDC1000.py

Test SDL_Pi_HDC1000 Version 1.1 – SwitchDoc Labs

Sample uses 0x40 and SwitchDoc HDC1000 Breakout board
Program Started at:2020-04-05 14:01:36

————
Manfacturer ID=0x5449
Device ID=0x1000
Serial Number ID=0x31AE900
configure register = 0x1000
turning Heater On
configure register = 0x3000
turning Heater Off
configure register = 0x1000
change temperature resolution
configure register = 0x1400
change temperature resolution
configure register = 0x1000
change humidity resolution
configure register = 0x1200
change humidity resolution
configure register = 0x1000
—————–
Temperature = 19.5 C
Humidity = 39.7 %
—————–
^[[A—————–
Temperature = 19.5 C
Humidity = 39.8 %
—————–
^[[A—————–
Temperature = 19.5 C
Humidity = 39.8 %

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here