-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,093 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Texas Instruments HDC10X0 Humidity and Temperature Sensor Driver for Arduino | ||
|
||
## Features | ||
|
||
- supports HDC1080 | ||
- supports HDC1000, HDC1008, HDC1010 and HDC1050 (untested) | ||
- blocking and non-blocking mode | ||
- multiple I2C bus support | ||
- heater support | ||
- convenience method to heat the sensor for a specified duration | ||
- serial ID support | ||
- CPU deep sleep support | ||
- tested with SAMD21 MCU | ||
- test build for ATmega 328P, ESP8266 and ESP32 MCU | ||
|
||
### Table of contents | ||
|
||
[1. Motivation](#motivation) | ||
[2. Results](#results) | ||
[3. Documentation](#documentation) | ||
[4. Examples](#examples) | ||
[5. Contributing](#contributing) | ||
[6. Licenses and Credits](#licenses-and-credits) | ||
|
||
## Motivation | ||
|
||
There are several Arduino libraries available for the HDC10XX sensors, but most of them share at least one of the following drawbacks: | ||
|
||
- support for non-blocking usage missing | ||
- build-in delays | ||
- sparse implementation of device features | ||
- not all HDC10XX variants supported | ||
- GPL license | ||
|
||
## Results | ||
|
||
In non-blocking mode with 11 bit resolution it is possible to perform an acquisition cycle for humidity and temperature in about 10 ms with the CPU | ||
being involved for less than 1 ms (tested with a SAMD21 MCU). | ||
|
||
Freeing up the CPU for about 9 ms compared to blocking mode does not sound like much, but even with a CPU running at 8 MHz this typically equates to significantly more than 50.000 CPU instructions. | ||
|
||
## Documentation | ||
|
||
See method description in the [header file](src/TI_HDC10XX.h). | ||
|
||
## Examples | ||
|
||
Examples for blocking and non-blocking use can be found in the [examples](examples) subdirectory. | ||
|
||
## Contributing | ||
|
||
Contributors are welcome. Please create a merge request if you want to fix a bug or add a feature. | ||
|
||
## Licenses and Credits | ||
|
||
Copyright (c) 2024 [Jens B.](https://github.com/jnsbyr/) | ||
|
||
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) | ||
|
||
This library depends on the Arduino platform and the Arduino Wire library. | ||
|
||
The code was edited with [Visual Studio Code](https://code.visualstudio.com). | ||
|
||
The badges in this document are provided by [img.shields.io](https://img.shields.io/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <TI_HDC10XX.h> | ||
|
||
//TI_HDC1000 dhtSensor; | ||
//TI_HDC1010 dhtSensor; | ||
//TI_HDC1050 dhtSensor; | ||
TI_HDC1080 dhtSensor; | ||
bool sensorInitialized = false; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while(!Serial); | ||
|
||
Wire.begin(); | ||
Wire.setTimeout(10000); // [µs] | ||
dhtSensor.setBlocking(true); | ||
if (dhtSensor.reset()) | ||
{ | ||
dhtSensor.setResolution(11, 11); | ||
|
||
bool voltageOK = dhtSensor.isSupplyVoltageOK(); | ||
Serial.println(voltageOK? "sensor supply voltage OK" : "sensor supply voltage LOW"); | ||
|
||
uint32_t serial = dhtSensor.readSerialIdLow(); | ||
Serial.print("sensor SNR: "); | ||
Serial.println(serial); | ||
|
||
Serial.print("heating sensor for 60 s ..."); | ||
for (int i=0; i<60; i++) | ||
{ | ||
dhtSensor.heat(1000); | ||
Serial.print("."); | ||
} | ||
Serial.println(" done."); | ||
|
||
sensorInitialized = true; | ||
} | ||
else | ||
{ | ||
Serial.println("ERROR: sensor reset failed"); | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
if (sensorInitialized) | ||
{ | ||
uint32_t start = millis(); | ||
if (dhtSensor.startAcquisition(dhtSensor.ACQ_TYPE_COMBINED)) | ||
{ | ||
uint32_t stop = millis(); | ||
float temperature = dhtSensor.getTemperature(); | ||
float humidity = dhtSensor.getHumidity(); | ||
Serial.print(temperature); | ||
Serial.print(" °C "); | ||
Serial.print(humidity); | ||
Serial.print(" %RH "); | ||
Serial.print(stop - start); | ||
Serial.println(" ms"); | ||
} | ||
else | ||
{ | ||
Serial.println("ERROR: sensor not responding"); | ||
} | ||
} | ||
else | ||
{ | ||
Serial.println("sensor not available"); | ||
} | ||
|
||
delay(3000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <TI_HDC10XX.h> | ||
|
||
//TI_HDC1000 dhtSensor; | ||
//TI_HDC1010 dhtSensor; | ||
//TI_HDC1050 dhtSensor; | ||
TI_HDC1080 dhtSensor; | ||
bool sensorInitialized = false; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while(!Serial); | ||
|
||
Wire.begin(); | ||
Wire.setTimeout(10000); // [µs] | ||
if (dhtSensor.reset()) | ||
{ | ||
delay(8); // or sleep or do something productive | ||
dhtSensor.setResolution(11, 11); | ||
|
||
bool voltageOK = dhtSensor.isSupplyVoltageOK(); | ||
Serial.println(voltageOK? "sensor supply voltage OK" : "sensor supply voltage LOW"); | ||
|
||
uint32_t serial = dhtSensor.readSerialIdLow(); | ||
Serial.print("sensor SNR: "); | ||
Serial.println(serial); | ||
|
||
Serial.print("heating sensor for 60 s ..."); | ||
for (int i=0; i<60; i++) | ||
{ | ||
dhtSensor.heat(1000); | ||
Serial.print("."); | ||
} | ||
Serial.println(" done."); | ||
|
||
sensorInitialized = true; | ||
} | ||
else | ||
{ | ||
Serial.println("ERROR: sensor reset failed"); | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
if (sensorInitialized) | ||
{ | ||
uint32_t start = millis(); | ||
if (dhtSensor.startAcquisition(dhtSensor.ACQ_TYPE_COMBINED)) | ||
{ | ||
// variant A: block | ||
delay((dhtSensor.getAcquisitionTime() + 1000)/1000); // or sleep or do something productive | ||
// variant B: loop | ||
//int available = 20; // [ms] timeout | ||
//while (!isAcquisitionComplete() && (available-- > 0)) | ||
//{ | ||
// delay(1); // or sleep or do something productive | ||
//} | ||
if (dhtSensor.readAcquisitionData()) | ||
{ | ||
uint32_t stop = millis(); | ||
float temperature = dhtSensor.getTemperature(); | ||
float humidity = dhtSensor.getHumidity(); | ||
Serial.print(temperature); | ||
Serial.print(" °C "); | ||
Serial.print(humidity); | ||
Serial.print(" %RH "); | ||
Serial.print(stop - start); | ||
Serial.println(" ms"); | ||
} | ||
else | ||
{ | ||
Serial.println("ERROR: sensor results not available"); | ||
} | ||
} | ||
else | ||
{ | ||
Serial.println("ERROR: sensor not responding"); | ||
} | ||
} | ||
else | ||
{ | ||
Serial.println("sensor not available"); | ||
} | ||
|
||
delay(3000); // or sleep or do something productive | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Texas Instruments HDC10XX", | ||
"keywords": "Texas Instruments TI HDC1000 HDC1008 HDC1010 HDC1050 HDC1080 humidity temperature", | ||
"description": "Arduino driver for Texas Instruments HDC10XX humidity and temperature sensors with I2C bus. Supports blocking and non-blocking use of HDC1000, HDC1008, HDC1010, HDC1050 and HDC1080.", | ||
"authors": [ | ||
{ | ||
"name": "Jens B.", | ||
"maintainer": true | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jnsbyr/arduino-hdc10xx/" | ||
}, | ||
"version": "1.0.0", | ||
"examples": "examples/*/*.ino", | ||
"license": "Apache-2.0", | ||
"frameworks": "arduino", | ||
"platforms": "*", | ||
"headers": "TI_HDC10XX.h" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name=Texas Instruments HDC10XX | ||
version=1.0.0 | ||
author=Jens B. | ||
maintainer=Jens B. | ||
sentence=Adruino driver for Texas Instruments HDC10XX humidity and temperature sensors with I2C bus. | ||
paragraph=Supports blocking and non-blocking use of HDC1000, HDC1008, HDC1010, HDC1050 and HDC1080. | ||
category=Sensors | ||
url=https://github.com/jnsbyr/arduino-hdc10xx/ | ||
architectures=* | ||
includes=TI_HDC10XX.h |
Oops, something went wrong.