Humidity Sensor

HDC1000

Code to interface humidity sensor(HDC1000)

#!/usr/bin/env python

from __future__ import print_function
import time, sys, atexit
from upm import pyupm_hdc1000 as HDC1000

def main():
    # Instantiate the Temperature and Humidity Sensor on I2C on bus 0
    mySensor = HDC1000.HDC1000(0)
    # Print out the humidity and temperature value every 0.5 seconds
    while(1):
        print("Humidity : "+str(mySensor.getHumidity(True)))
        print("Temperature : "+str(mySensor.getTemperature(True)))
        time.sleep(.5)
if __name__ == '__main__':
    main()

To run the program, Step 1: save the file as hdc1000.py Step 2: Run the Program in the board's terminal using python3 hdc1000.py

Last updated