Introduction: Particle Photon - HDC1000 Temperature Sensor Tutorial

About: We are a group of makers. We work in IoT, IOS app, android app, embedded design, sensor design, raspberry pi, arduino, beaglebone, particle electron, particle photon, Bluetooth.

The HDC1000 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. It is functional within the full -40°C to +125°C temperature range. Here is its demonstration with particle photon.

Step 1: What You Need..!!

Step 2: Connection:

Take an I2C shield for particle photon and gently push it over the pins of particle photon.

Then connect the one end of I2C cable to HDC1000 sensor and the other end to the I2C shield.

Connections are shown in the picture above.

Step 3: Code:

The particle code for HDC1000 can be downloaded from our GitHub repository- Dcube Store.

Here is the link for the same :

https://github.com/DcubeTechVentures/HDC1000...

The datasheet of HDC1000 can be found here:

http://www.ti.com.cn/cn/lit/ds/symlink/hdc1000.pdf

We have used two libraries for particle code, which are application.h and spark_wiring_i2c.h. Spark_wiring_i2c library is required to facilitate the I2C communication with the sensor.

You can also copy the code from here, it is given as follows:

// Distributed with a free-will license.

// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

// HDC1000

// This code is designed to work with the HDC1000_I2CS I2C Mini Module available in Dcube Store.

#include

#include

// HDC1000 I2C address is 0x40(64)

#define Addr 0x40

float cTemp = 0.0, fTemp = 0.0, humidity = 0.0;

int temp = 0, hum = 0;

void setup()

{

// Set variable

Particle.variable("i2cdevice", "HDC1000");

Particle.variable("humidity", humidity);

Particle.variable("cTemp", cTemp);

// Initialise I2C communication

Wire.begin();

// Initialise Serial Communication, set baud rate = 9600

Serial.begin(9600);

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Select configuration register

Wire.write(0x02);

// Temperature, humidity enabled, resolultion = 14-bits, heater on

Wire.write(0x30);

// Stop I2C Transmission

Wire.endTransmission();

delay(300);

}

void loop()

{

unsigned int data[2];

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Send temp measurement command

Wire.write(0x00);

// Stop I2C Transmission

Wire.endTransmission();

delay(500);

// Request 2 bytes of data

Wire.requestFrom(Addr, 2);

// Read 2 bytes of data

// temp msb, temp lsb

if (Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

}

// Convert the data

temp = ((data[0] * 256) + data[1]);

cTemp = (temp / 65536.0) * 165.0 - 40;

fTemp = cTemp * 1.8 + 32;

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Send humidity measurement command

Wire.write(0x01);

// Stop I2C Transmission

Wire.endTransmission();

delay(500);

// Request 2 bytes of data

Wire.requestFrom(Addr, 2);

// Read 2 bytes of data

// temp msb, temp lsb

if (Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

}

// Convert the data

hum = ((data[0] * 256) + data[1]);

humidity = (hum / 65536.0) * 100.0;

// Output data to dashboard

Particle.publish("Relative Humidity : ", String(humidity));

Particle.publish("Temperature in Celsius : ", String(cTemp));

Particle.publish("Temperature in Fahrenheit : ", String(fTemp));

delay(1000);

}

Step 4: Applications:

HDC1000 can be employed in heating, ventilation and air conditioning (HVAC), Smart Thermostats and Room Monitors. This sensor also finds its application in Printers, Handheld Meters,Medical Devices,Cargo Shipping as well as Automotive Windshield Defog.