actionified, formatted and doxy'd

This commit is contained in:
siddacious 2020-04-08 11:36:24 -07:00
parent 428e115b57
commit 5d60b0d3f0
10 changed files with 387 additions and 341 deletions

32
.github/workflows/githubci.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Arduino Library CI
on: [pull_request, push, repository_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: adafruit/ci-arduino
path: ci
- name: pre-install
run: bash ci/actions_install.sh
- name: test platforms
run: python3 ci/build_platform.py main_platforms
- name: clang
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
- name: doxygen
env:
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
PRETTYNAME : "DHT sensor library"
run: bash ci/doxy_gen_and_deploy.sh

View File

@ -1,29 +0,0 @@
language: c
sudo: false
cache:
directories:
- ~/arduino_ide
- ~/.arduino15/packages/
git:
depth: false
quiet: true
env:
global:
- ARDUINO_IDE_VERSION="1.8.7"
- PRETTYNAME="DHT sensor library"
before_install:
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
install:
- arduino --install-library "Adafruit Unified Sensor"
script:
- build_main_platforms
after_success:
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)

View File

@ -164,8 +164,8 @@ float DHT::readHumidity(bool force) {
* @brief Compute Heat Index * @brief Compute Heat Index
* Simplified version that reads temp and humidity from sensor * Simplified version that reads temp and humidity from sensor
* @param isFahrenheit * @param isFahrenheit
* true if fahrenheit, false if celcius (default * true if fahrenheit, false if celcius
*true) *(default true)
* @return float heat index * @return float heat index
*/ */
float DHT::computeHeatIndex(bool isFahrenheit) { float DHT::computeHeatIndex(bool isFahrenheit) {

73
DHT.h
View File

@ -3,7 +3,8 @@
* *
* This is a library for DHT series of low cost temperature/humidity sensors. * This is a library for DHT series of low cost temperature/humidity sensors.
* *
* You must have Adafruit Unified Sensor Library library installed to use this class. * You must have Adafruit Unified Sensor Library library installed to use this
* class.
* *
* Adafruit invests time and resources providing this open source code, * Adafruit invests time and resources providing this open source code,
* please support Adafruit andopen-source hardware by purchasing products * please support Adafruit andopen-source hardware by purchasing products
@ -22,71 +23,77 @@
/* Uncomment to enable printing out nice debug messages. */ /* Uncomment to enable printing out nice debug messages. */
//#define DHT_DEBUG //#define DHT_DEBUG
#define DEBUG_PRINTER \
#define DEBUG_PRINTER Serial /**< Define where debug output will be printed. */ Serial /**< Define where debug output will be printed. \
*/
/* Setup debug printing macros. */ /* Setup debug printing macros. */
#ifdef DHT_DEBUG #ifdef DHT_DEBUG
#define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } #define DEBUG_PRINT(...) \
#define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } { DEBUG_PRINTER.print(__VA_ARGS__); }
#define DEBUG_PRINTLN(...) \
{ DEBUG_PRINTER.println(__VA_ARGS__); }
#else #else
#define DEBUG_PRINT(...) {} /**< Debug Print Placeholder if Debug is disabled */ #define DEBUG_PRINT(...) \
#define DEBUG_PRINTLN(...) {} /**< Debug Print Line Placeholder if Debug is disabled */ {} /**< Debug Print Placeholder if Debug is disabled */
#define DEBUG_PRINTLN(...) \
{} /**< Debug Print Line Placeholder if Debug is disabled */
#endif #endif
/* Define types of sensors. */ /* Define types of sensors. */
#define DHT11 11 /**< DHT TYPE 11 */ #define DHT11 11 /**< DHT TYPE 11 */
#define DHT12 12 /**< DHY TYPE 12 */ #define DHT12 12 /**< DHY TYPE 12 */
#define DHT22 22 /**< DHT TYPE 22 */ #define DHT22 22 /**< DHT TYPE 22 */
#define DHT21 21 /**< DHT TYPE 21 */ #define DHT21 21 /**< DHT TYPE 21 */
#define AM2301 21 /**< AM2301 */ #define AM2301 21 /**< AM2301 */
/*! /*!
* @brief Class that stores state and functions for DHT * @brief Class that stores state and functions for DHT
*/ */
class DHT { class DHT {
public: public:
DHT(uint8_t pin, uint8_t type, uint8_t count=6); DHT(uint8_t pin, uint8_t type, uint8_t count = 6);
void begin(uint8_t usec=55); void begin(uint8_t usec = 55);
float readTemperature(bool S=false, bool force=false); float readTemperature(bool S = false, bool force = false);
float convertCtoF(float); float convertCtoF(float);
float convertFtoC(float); float convertFtoC(float);
float computeHeatIndex(bool isFahrenheit=true); float computeHeatIndex(bool isFahrenheit = true);
float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); float computeHeatIndex(float temperature, float percentHumidity,
float readHumidity(bool force=false); bool isFahrenheit = true);
bool read(bool force=false); float readHumidity(bool force = false);
bool read(bool force = false);
private: private:
uint8_t data[5]; uint8_t data[5];
uint8_t _pin, _type; uint8_t _pin, _type;
#ifdef __AVR #ifdef __AVR
// Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask // Use direct GPIO access on an 8-bit AVR so keep track of the port and
// for the digital pin connected to the DHT. Other platforms will use digitalRead. // bitmask for the digital pin connected to the DHT. Other platforms will use
uint8_t _bit, _port; // digitalRead.
#endif uint8_t _bit, _port;
#endif
uint32_t _lastreadtime, _maxcycles; uint32_t _lastreadtime, _maxcycles;
bool _lastresult; bool _lastresult;
uint8_t pullTime; // Time (in usec) to pull up data line before reading uint8_t pullTime; // Time (in usec) to pull up data line before reading
uint32_t expectPulse(bool level); uint32_t expectPulse(bool level);
}; };
/*! /*!
* @brief Class that defines Interrupt Lock Avaiability * @brief Class that defines Interrupt Lock Avaiability
*/ */
class InterruptLock { class InterruptLock {
public: public:
InterruptLock() { InterruptLock() {
#if !defined(ARDUINO_ARCH_NRF52) #if !defined(ARDUINO_ARCH_NRF52)
noInterrupts(); noInterrupts();
#endif #endif
} }
~InterruptLock() { ~InterruptLock() {
#if !defined(ARDUINO_ARCH_NRF52) #if !defined(ARDUINO_ARCH_NRF52)
interrupts(); interrupts();
#endif #endif
} }
}; };
#endif #endif

243
DHT_U.cpp
View File

@ -27,46 +27,43 @@
* @param humiditySensorId * @param humiditySensorId
* humidity sensor id * humidity sensor id
*/ */
DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count, int32_t tempSensorId, int32_t humiditySensorId): DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count,
_dht(pin, type, count), int32_t tempSensorId, int32_t humiditySensorId)
_type(type), : _dht(pin, type, count), _type(type), _temp(this, tempSensorId),
_temp(this, tempSensorId), _humidity(this, humiditySensorId) {}
_humidity(this, humiditySensorId)
{}
/*! /*!
* @brief Setup sensor (calls begin on It) * @brief Setup sensor (calls begin on It)
*/ */
void DHT_Unified::begin() { void DHT_Unified::begin() { _dht.begin(); }
_dht.begin();
}
/*! /*!
* @brief Sets sensor name * @brief Sets sensor name
* @param sensor * @param sensor
* Sensor that will be set * Sensor that will be set
*/ */
void DHT_Unified::setName(sensor_t* sensor) { void DHT_Unified::setName(sensor_t *sensor) {
switch(_type) { switch (_type) {
case DHT11: case DHT11:
strncpy(sensor->name, "DHT11", sizeof(sensor->name) - 1); strncpy(sensor->name, "DHT11", sizeof(sensor->name) - 1);
break; break;
case DHT12: case DHT12:
strncpy(sensor->name, "DHT12", sizeof(sensor->name) - 1); strncpy(sensor->name, "DHT12", sizeof(sensor->name) - 1);
break; break;
case DHT21: case DHT21:
strncpy(sensor->name, "DHT21", sizeof(sensor->name) - 1); strncpy(sensor->name, "DHT21", sizeof(sensor->name) - 1);
break; break;
case DHT22: case DHT22:
strncpy(sensor->name, "DHT22", sizeof(sensor->name) - 1); strncpy(sensor->name, "DHT22", sizeof(sensor->name) - 1);
break; break;
default: default:
// TODO: Perhaps this should be an error? However main DHT library doesn't enforce // TODO: Perhaps this should be an error? However main DHT library doesn't
// restrictions on the sensor type value. Pick a generic name for now. // enforce restrictions on the sensor type value. Pick a generic name for
strncpy(sensor->name, "DHT?", sizeof(sensor->name) - 1); // now.
break; strncpy(sensor->name, "DHT?", sizeof(sensor->name) - 1);
break;
} }
sensor->name[sizeof(sensor->name)- 1] = 0; sensor->name[sizeof(sensor->name) - 1] = 0;
} }
/*! /*!
@ -74,24 +71,24 @@ void DHT_Unified::setName(sensor_t* sensor) {
* @param sensor * @param sensor
* Sensor that will be set * Sensor that will be set
*/ */
void DHT_Unified::setMinDelay(sensor_t* sensor) { void DHT_Unified::setMinDelay(sensor_t *sensor) {
switch(_type) { switch (_type) {
case DHT11: case DHT11:
sensor->min_delay = 1000000L; // 1 second (in microseconds) sensor->min_delay = 1000000L; // 1 second (in microseconds)
break; break;
case DHT12: case DHT12:
sensor->min_delay = 2000000L; // 2 second (in microseconds) sensor->min_delay = 2000000L; // 2 second (in microseconds)
break; break;
case DHT21: case DHT21:
sensor->min_delay = 2000000L; // 2 seconds (in microseconds) sensor->min_delay = 2000000L; // 2 seconds (in microseconds)
break; break;
case DHT22: case DHT22:
sensor->min_delay = 2000000L; // 2 seconds (in microseconds) sensor->min_delay = 2000000L; // 2 seconds (in microseconds)
break; break;
default: default:
// Default to slowest sample rate in case of unknown type. // Default to slowest sample rate in case of unknown type.
sensor->min_delay = 2000000L; // 2 seconds (in microseconds) sensor->min_delay = 2000000L; // 2 seconds (in microseconds)
break; break;
} }
} }
@ -102,24 +99,22 @@ void DHT_Unified::setMinDelay(sensor_t* sensor) {
* @param id * @param id
* Sensor id * Sensor id
*/ */
DHT_Unified::Temperature::Temperature(DHT_Unified* parent, int32_t id): DHT_Unified::Temperature::Temperature(DHT_Unified *parent, int32_t id)
_parent(parent), : _parent(parent), _id(id) {}
_id(id)
{}
/*! /*!
* @brief Reads the sensor and returns the data as a sensors_event_t * @brief Reads the sensor and returns the data as a sensors_event_t
* @param event * @param event
* @return always returns true * @return always returns true
*/ */
bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) { bool DHT_Unified::Temperature::getEvent(sensors_event_t *event) {
// Clear event definition. // Clear event definition.
memset(event, 0, sizeof(sensors_event_t)); memset(event, 0, sizeof(sensors_event_t));
// Populate sensor reading values. // Populate sensor reading values.
event->version = sizeof(sensors_event_t); event->version = sizeof(sensors_event_t);
event->sensor_id = _id; event->sensor_id = _id;
event->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; event->type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
event->timestamp = millis(); event->timestamp = millis();
event->temperature = _parent->_dht.readTemperature(); event->temperature = _parent->_dht.readTemperature();
return true; return true;
@ -129,44 +124,44 @@ bool DHT_Unified::Temperature::getEvent(sensors_event_t* event) {
* @brief Provides the sensor_t data for this sensor * @brief Provides the sensor_t data for this sensor
* @param sensor * @param sensor
*/ */
void DHT_Unified::Temperature::getSensor(sensor_t* sensor) { void DHT_Unified::Temperature::getSensor(sensor_t *sensor) {
// Clear sensor definition. // Clear sensor definition.
memset(sensor, 0, sizeof(sensor_t)); memset(sensor, 0, sizeof(sensor_t));
// Set sensor name. // Set sensor name.
_parent->setName(sensor); _parent->setName(sensor);
// Set version and ID // Set version and ID
sensor->version = DHT_SENSOR_VERSION; sensor->version = DHT_SENSOR_VERSION;
sensor->sensor_id = _id; sensor->sensor_id = _id;
// Set type and characteristics. // Set type and characteristics.
sensor->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; sensor->type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
_parent->setMinDelay(sensor); _parent->setMinDelay(sensor);
switch (_parent->_type) { switch (_parent->_type) {
case DHT11: case DHT11:
sensor->max_value = 50.0F; sensor->max_value = 50.0F;
sensor->min_value = 0.0F; sensor->min_value = 0.0F;
sensor->resolution = 2.0F; sensor->resolution = 2.0F;
break; break;
case DHT12: case DHT12:
sensor->max_value = 60.0F; sensor->max_value = 60.0F;
sensor->min_value = -20.0F; sensor->min_value = -20.0F;
sensor->resolution = 0.5F; sensor->resolution = 0.5F;
break; break;
case DHT21: case DHT21:
sensor->max_value = 80.0F; sensor->max_value = 80.0F;
sensor->min_value = -40.0F; sensor->min_value = -40.0F;
sensor->resolution = 0.1F; sensor->resolution = 0.1F;
break; break;
case DHT22: case DHT22:
sensor->max_value = 125.0F; sensor->max_value = 125.0F;
sensor->min_value = -40.0F; sensor->min_value = -40.0F;
sensor->resolution = 0.1F; sensor->resolution = 0.1F;
break; break;
default: default:
// Unknown type, default to 0. // Unknown type, default to 0.
sensor->max_value = 0.0F; sensor->max_value = 0.0F;
sensor->min_value = 0.0F; sensor->min_value = 0.0F;
sensor->resolution = 0.0F; sensor->resolution = 0.0F;
break; break;
} }
} }
@ -177,24 +172,22 @@ void DHT_Unified::Temperature::getSensor(sensor_t* sensor) {
* @param id * @param id
* Sensor id * Sensor id
*/ */
DHT_Unified::Humidity::Humidity(DHT_Unified* parent, int32_t id): DHT_Unified::Humidity::Humidity(DHT_Unified *parent, int32_t id)
_parent(parent), : _parent(parent), _id(id) {}
_id(id)
{}
/*! /*!
* @brief Reads the sensor and returns the data as a sensors_event_t * @brief Reads the sensor and returns the data as a sensors_event_t
* @param event * @param event
* @return always returns true * @return always returns true
*/ */
bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) { bool DHT_Unified::Humidity::getEvent(sensors_event_t *event) {
// Clear event definition. // Clear event definition.
memset(event, 0, sizeof(sensors_event_t)); memset(event, 0, sizeof(sensors_event_t));
// Populate sensor reading values. // Populate sensor reading values.
event->version = sizeof(sensors_event_t); event->version = sizeof(sensors_event_t);
event->sensor_id = _id; event->sensor_id = _id;
event->type = SENSOR_TYPE_RELATIVE_HUMIDITY; event->type = SENSOR_TYPE_RELATIVE_HUMIDITY;
event->timestamp = millis(); event->timestamp = millis();
event->relative_humidity = _parent->_dht.readHumidity(); event->relative_humidity = _parent->_dht.readHumidity();
return true; return true;
@ -204,43 +197,43 @@ bool DHT_Unified::Humidity::getEvent(sensors_event_t* event) {
* @brief Provides the sensor_t data for this sensor * @brief Provides the sensor_t data for this sensor
* @param sensor * @param sensor
*/ */
void DHT_Unified::Humidity::getSensor(sensor_t* sensor) { void DHT_Unified::Humidity::getSensor(sensor_t *sensor) {
// Clear sensor definition. // Clear sensor definition.
memset(sensor, 0, sizeof(sensor_t)); memset(sensor, 0, sizeof(sensor_t));
// Set sensor name. // Set sensor name.
_parent->setName(sensor); _parent->setName(sensor);
// Set version and ID // Set version and ID
sensor->version = DHT_SENSOR_VERSION; sensor->version = DHT_SENSOR_VERSION;
sensor->sensor_id = _id; sensor->sensor_id = _id;
// Set type and characteristics. // Set type and characteristics.
sensor->type = SENSOR_TYPE_RELATIVE_HUMIDITY; sensor->type = SENSOR_TYPE_RELATIVE_HUMIDITY;
_parent->setMinDelay(sensor); _parent->setMinDelay(sensor);
switch (_parent->_type) { switch (_parent->_type) {
case DHT11: case DHT11:
sensor->max_value = 80.0F; sensor->max_value = 80.0F;
sensor->min_value = 20.0F; sensor->min_value = 20.0F;
sensor->resolution = 5.0F; sensor->resolution = 5.0F;
break; break;
case DHT12: case DHT12:
sensor->max_value = 95.0F; sensor->max_value = 95.0F;
sensor->min_value = 20.0F; sensor->min_value = 20.0F;
sensor->resolution = 5.0F; sensor->resolution = 5.0F;
break; break;
case DHT21: case DHT21:
sensor->max_value = 100.0F; sensor->max_value = 100.0F;
sensor->min_value = 0.0F; sensor->min_value = 0.0F;
sensor->resolution = 0.1F; sensor->resolution = 0.1F;
break; break;
case DHT22: case DHT22:
sensor->max_value = 100.0F; sensor->max_value = 100.0F;
sensor->min_value = 0.0F; sensor->min_value = 0.0F;
sensor->resolution = 0.1F; sensor->resolution = 0.1F;
break; break;
default: default:
// Unknown type, default to 0. // Unknown type, default to 0.
sensor->max_value = 0.0F; sensor->max_value = 0.0F;
sensor->min_value = 0.0F; sensor->min_value = 0.0F;
sensor->resolution = 0.0F; sensor->resolution = 0.0F;
break; break;
} }
} }

View File

@ -76,13 +76,13 @@ public:
int32_t _id; int32_t _id;
}; };
/*! /*!
* @brief Returns temperature stored in _temp * @brief Returns temperature stored in _temp
* @return Temperature value * @return Temperature value
*/ */
Temperature temperature() { return _temp; } Temperature temperature() { return _temp; }
/*! /*!
* @brief Returns humidity stored in _humidity * @brief Returns humidity stored in _humidity
* @return Humidity value * @return Humidity value
*/ */

182
README.md
View File

@ -1,4 +1,4 @@
# Adafruit DHT Humidity & Temperature Sensor Library [![Build Status](https://travis-ci.com/adafruit/DHT-sensor-library.svg?branch=master)](https://travis-ci.com/adafruit/DHT-sensor-library) # DHT sensor library [![Build Status](https://github.com/adafruit/DHT-sensor-library/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/DHT-sensor-library/actions)
## Description ## Description
@ -6,157 +6,53 @@ An Arduino library for the DHT series of low-cost temperature/humidity sensors.
You can find DHT tutorials [here](https://learn.adafruit.com/dht). You can find DHT tutorials [here](https://learn.adafruit.com/dht).
## Installation # Dependencies
* [Adafruit Unified Sensor Driver](https://github.com/adafruit/Adafruit_Sensor)
### First Method # Contributing
![image](https://user-images.githubusercontent.com/36513474/67982415-773d6a00-fc44-11e9-8741-8185da71e785.png) Contributions are welcome! Not only youll encourage the development of the library, but youll also learn how to best use the library and probably some C++ too
1. In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries Please read our [Code of Conduct](https://github.com/adafruit/DHT-sensor-library/blob/master/CODE_OF_CONDUCT.md>)
1. Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. before contributing to help this project stay welcoming.
1. Then search for DHT-sensor using the search bar.
1. Click on the text area and then select the specific version and install it.
### Second Method ## Documentation and doxygen
Documentation is produced by doxygen. Contributions should include documentation for any new code added.
1. Navigate to the Releases page. Some examples of how to use doxygen can be found in these guide pages:
1. Download the latest release.
1. Extract the zip file
1. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library
## Requirements https://learn.adafruit.com/the-well-automated-arduino-library/doxygen
This library depends on [Adafruit Unified Sensor Library](https://github.com/adafruit/Adafruit_Sensor). To use this library the user must download the required library. https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips
## Features Written by Adafruit Industries based on work by:
- ### Inexpensive * T. DiCola
* P. Y. Dragon
* L. Fried
* J. Hoffmann
* M. Kooijman
* J. M. Dana
* S. Conaway
* S. IJskes
* T. Forbes
* B. C
* T. J Myers
* L. Sørup
* per1234
* O. Duffy
* matthiasdanner
* J. Lim
* G. Ambrozio
* chelmi
* adams13x13
* Spacefish
* I. Scheller
* C. Miller
* 7eggert
This library is used with low-cost temperature and humidity sensors, for example, DHT11 and DHT22. This library is free of cost and the only cost is of the sensors.
- ### Compatible MIT license, check license.txt for more information
All text above must be included in any redistribution
DHT sensor library is compatible with multiple low-cost temperature and humidity sensors like DHT11 and DHT22. A few examples are implemented just to demonstrate how to modify the code for different sensors. To install, use the Arduino Library Manager and search for "DHT sensor library" and install the library.
- ### Function calls
Basic functions of the low-cost temperature/humidity sensors have been implemented in this library. There's no need to re-implement these functions from scratch. The user simply has to import the library in the project and can use any of its functions by just calling it.
- ### Give back
The library is free, you dont have to pay for anything. However, if you want to support the development, or just thank the author of the library by purchasing products from Adafruit!
Not only youll encourage the development of the library, but youll also learn how to best use the library and probably some C++ too
- ### MIT License
DHT sensor library is open-source and uses one of the most permissive licenses so you can use it on any project.
- Commercial use
- Modification
- Distribution
- Private use
## Functions
- begin()
- readTemperature()
- convertCtoF()
- convertFtoC()
- readHumidity()
- computeHeatIndex()
- read()
- expectPulse()
## Example
Examples include both a "standalone" DHT example and one that works along with the Adafruit Unified Sensor Library. A Unified sensor library is required even if using the standalone version. You can find other examples from [Github-DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library/tree/master/examples).
```Cpp
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}
```
## Contributing
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell others about this library
- Contribute new protocols
Please read [CONTRIBUTING.md](https://github.com/adafruit/DHT-sensor-library/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## Credits
The author and maintainer of this library is Adafruit <info@adafruit.com>
Based on previous work by:
- T. DiCola
- P. Y. Dragon
- L. Fried
- J. Hoffmann
- M. Kooijman
- J. M. Dana
- S. Conaway
- S. IJskes
- T. Forbes
- B. C
- T. J Myers
- L. Sørup
- per1234
- O. Duffy
- matthiasdanner
- J. Lim
- G. Ambrozio
- chelmi
- adams13x13
- Spacefish
- I. Scheller
- C. Miller
- 7eggert
## License
This library is licensed under [MIT license](https://opensource.org/licenses/MIT).

127
code-of-conduct.md Normal file
View File

@ -0,0 +1,127 @@
# Adafruit Community Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and leaders pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level or type of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
## Our Standards
We are committed to providing a friendly, safe and welcoming environment for
all.
Examples of behavior that contributes to creating a positive environment
include:
* Be kind and courteous to others
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Collaborating with other community members
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and sexual attention or advances
* The use of inappropriate images, including in a community member's avatar
* The use of inappropriate language, including in a community member's nickname
* Any spamming, flaming, baiting or other attention-stealing behavior
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for
other community members can have a much more significant impact than simply
providing the correct answer.
## Our Responsibilities
Project leaders are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project leaders have the right and responsibility to remove, edit, or
reject messages, comments, commits, code, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any community member for other behaviors that they deem
inappropriate, threatening, offensive, or harmful.
## Moderation
Instances of behaviors that violate the Adafruit Community Code of Conduct
may be reported by any member of the community. Community members are
encouraged to report these situations, including situations they witness
involving other community members.
You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>.
On the Adafruit Discord, you may send an open message from any channel
to all Community Helpers by tagging @community helpers. You may also send an
open message from any channel, or a direct message to @kattni#1507,
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
@Andon#8175.
Email and direct message reports will be kept confidential.
In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and
investigated.
2. If the behavior is an egregious violation, the community member who
committed the violation may be banned immediately, without warning.
3. Otherwise, moderators will first respond to such behavior with a warning.
4. Moderators follow a soft "three strikes" policy - the community member may
be given another chance, if they are receptive to the warning and change their
behavior.
5. If the community member is unreceptive or unreasonable when warned by a
moderator, or the warning goes unheeded, they may be banned for a first or
second offense. Repeated offenses will result in the community member being
banned.
## Scope
This Code of Conduct and the enforcement policies listed above apply to all
Adafruit Community venues. This includes but is not limited to any community
spaces (both public and private), the entire Adafruit Discord server, and
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
interaction at a conference.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. As a community
member, you are representing our community, and are expected to behave
accordingly.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion.

View File

@ -1,5 +1,5 @@
name=DHT sensor library name=DHT sensor library
version=1.3.8 version=1.3.9
author=Adafruit author=Adafruit
maintainer=Adafruit <info@adafruit.com> maintainer=Adafruit <info@adafruit.com>
sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors

20
license.txt Normal file
View File

@ -0,0 +1,20 @@
Copyright (c) 2020 Adafruit Industries
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.