HDC1080 High Precision Temperature and Humidity sensor Arduino




/**************************************************************************************

This is example for ClosedCube HDC1080 Humidity and Temperature Sensor breakout booard

Initial Date: 13-May-2016

Hardware connections for Arduino Uno:
VDD to 3.3V DC
SCL to A5
SDA to A4
GND to common ground

Written by AA for ClosedCube

MIT License

**************************************************************************************/

#include <Wire.h>
#include "ClosedCube_HDC1080.h"

ClosedCube_HDC1080 hdc1080;

void setup()
{
Serial.begin(9600);
Serial.println("ClosedCube HDC1080 Arduino Test");

// Default settings:
//  - Heater off
//  - 14 bit Temperature and Humidity Measurement Resolutions
hdc1080.begin(0x40);

Serial.print("Manufacturer ID=0x");
Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
Serial.print("Device ID=0x");
Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device

printSerialNumber();

}

void loop()
{
Serial.print("T=");
Serial.print(hdc1080.readTemperature());
Serial.print("C, RH=");
Serial.print(hdc1080.readHumidity());
Serial.println("%");
delay(3000);
}

void printSerialNumber() {
Serial.print("Device Serial Number=");
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
char format[12];
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
Serial.println(format);
}

ความคิดเห็น