Dragos Iosub
Published

Basic IoT - RaspberryPI HDC2010 how to

Basic IoT - RaspberryPI and HDC2010 I2C breakout by itbrainpower. net - RPI HDC2010 temperature and humidity sensor how to

IntermediateProtip18 minutes1,554
Basic IoT - RaspberryPI HDC2010 how to

Things used in this project

Story

Read more

Schematics

HDC2010 sensor wiring example with RaspberryPI

CCS811+HDC2010 breakout datasheet

s-Sense CCS811+HDC2010 I2C sensor breakout datasheet

HDC2010 breakout datasheet

s-Sense HDC2010 I2C sensor breakout datasheet

Code

HDC2010 read sensor data Python code

Python
Read and print HDC2010 [temperature and humidity] sensor data - pulling rate ~ 2 second.

Python with python-smbus2 and RPI.GPIO dependencies
"""
s-Sense HDC2010 by itbrainpower.net I2C sensor breakout example - v1.0/20200218. 

Compatible with:
		s-Sense HDC2010 I2C sensor breakout [PN: SS-HDC2010#I2C, SKU: ITBP-6005], info https://itbrainpower.net/sensors/HDC2010-TEMPERATURE-HUMIDITY-I2C-sensor-breakout
		s-Sense CCS811 + HDC2010 I2C sensor breakout [PN: SS-HDC2010+CCS811#I2C, SKU: ITBP-6006], info https://itbrainpower.net/sensors/CCS811-HDC2010-CO2-TVOC-TEMPERATURE-HUMIDITY-I2C-sensor-breakout
		all RaspberryPI, using Python 2.7

HDC2010 temperature and humidity (pulling at 2 second) reading example - based on HDC2010 library written 
by Brandon Fisher and provided by TI. Thank you Brandon! Great job! Read credits bellow and inside the class.

We've just add add some variables, functions and functionalities and port all to python.


Mandatory wiring [bellow for RPi B/B+/II/3B/3B+/3A+/4/Zero/Zero W]:
        - sensor Vin            <------> RPI pin 1 [3V3 power] *
        - sensor I2C SDA        <------> RPI pin 3 [i2c-1 SDA]
        - sensor I2C SCL        <------> RPI pin 5 [i2c-1 SCL]
        - sensor GND            <------> RPI pin 9 [GND]

Wiring notes:
        *    to spare 3V3 power - read about RPI I2C sensors 5V powering

WIRING WARNING:
        Wrong wiring may damage your RaspberryPI or your sensor! Double check what you've done.


HDC2010 definitions are placed in hdc2010_param.py


Bellow, how to set-up i2c on RPi and install requiered python packages and other utilities.

Enable I2C channel 1
        a. sudo raspi-config
                menu F5		=> 	enable I2C
                save, exit and reboot.
        
        
        b. edit /boot/config.txt and add/enable following directives:
               dtparam=i2c_arm=on
               dtparam=i2c_arm_baudrate=10000

           save and reboot.

Check i2c is loaded:
        run: ls /dev/*i2c*
        should return: /dev/i2c-1

Add i2c-tools packages:
        sudo apt-get install -y i2c-tools

Check sensor I2C connection:
        run: i2cdetect -y 1
        you should see listed the s-Sense HDC2010 I2C address [0x40]

Install additional python packages:
        a. sudo apt-get install python-setuptools
        b. wget https://files.pythonhosted.org/packages/6a/06/80a6928e5cbfd40c77c08e06ae9975c2a50109586ce66435bd8166ce6bb3/smbus2-0.3.0.tar.gz
        c. expand archive
        d. chdir smbus2-0.3.0
        e. sudo python setup.py install


You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH s-Sense HDC2010 I2C sensors DEVICES USAGE. Modifications, derivates and redistribution 
of this software must include unmodified this COPYRIGHT NOTICE. You can redistribute this SOFTWARE and/or modify it under the terms 
of this COPYRIGHT NOTICE. Any other usage may be permited only after written notice of Dragos Iosub / R&D Software Solutions srl.

This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE.


itbrainpower.net invests significant time in design phase of our IoT products and in associated software and support resources.
Support us by purchasing our environmental and air quality sensors from here https://itbrainpower.net/order#s-Sense


Dragos Iosub, Bucharest 2020.
https://itbrainpower.net
"""

from time import sleep
from hdc2010 import *



hdc2010Reset()                                                  #start with sensor reset

#hdc2010SetTemperatureOffset(0b11010111)                         #-6.64 degrees Celsius - determine and set your, see definitions and HDC2010 datasheet

hdc2010SetMeasurementsMode(HDC2010_TEMP_AND_HUMID)              #Set measurements to temperature and humidity 14bits resolution
hdc2010SetRate(HDC2010_ONE_HZ)                                  #Set measurement frequency to 1 Hz
#hdc2010SetRate(HDC2010_MANUAL)                                  #Set measurement with manual trigger

#hdc2010SetRate(HDC2010_FIVE_SECONDS)                            #Set measurement 1/5 Hz
hdc2010SetTempRes(HDC2010_FOURTEEN_BIT)                         #Set temperature resolution at 14bits
#hdc2010SetTempRes(HDC2010_NINE_BIT)                             #Set temperature resolution at 9bits

hdc2010SetHumidRes(HDC2010_FOURTEEN_BIT)                        #Set humidity resolution at 14bits


hdc2010TriggerMeasurement()                                     #trigger measurements
sleep(1)


while(1):
        temperature = hdc2010ReadTemp()
        humidity = hdc2010ReadHumidity()
        print "Temperature in Celsius : %.4f C" %temperature
        print "Relative Humidity : %.4f %%" %humidity
        #hdc2010TriggerMeasurement()
        sleep(2)
        

Credits

Dragos Iosub

Dragos Iosub

28 projects • 18 followers
Electronics & software, electronics & software, ...

Comments