You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Arduino IDE Library Manager](#arduino-ide-library-manager)
12
21
-[Installing Manually from GitHub](#installing-manually-from-github)
13
-
-[Usage](#usage)
14
-
-[Basic Usage](#basic-usage)
15
-
-[New Methods in v2.0.0](#new-methods-in-v200)
16
-
-[Wiring Details](#wiring-details)
17
-
-[Examples](#examples)
18
-
-[Error Handling](#error-handling)
19
-
-[Troubleshooting](#troubleshooting)
20
-
-[FAQ](#faq)
21
-
-[Compatibility](#compatibility)
22
-
-[Contribute by Testing](#contribute-by-testing)
23
-
-[Contributing](#contributing)
24
-
-[Code of Conduct](#code-of-conduct)
25
-
-[License](#license)
26
-
-[External References](#external-references)
22
+
-[Usage](#usage)
23
+
-[Basic Usage](#basic-usage)
24
+
-[New Methods](#new-methods)
25
+
-[Wiring Details](#wiring-details)
26
+
-[Examples](#examples)
27
+
-[Error Handling](#error-handling)
28
+
-[Troubleshooting](#troubleshooting)
29
+
-[FAQ](#faq)
30
+
-[Compatibility](#compatibility)
31
+
-[Contribute by Testing](#contribute-by-testing)
32
+
-[Contributing](#contributing)
33
+
-[Code of Conduct](#code-of-conduct)
34
+
-[License](#license)
35
+
-[External References](#external-references)
27
36
28
37
## Introduction
29
-
30
38
This Arduino library is designed for the DHT11 temperature and humidity sensor. It simplifies the process of reading temperature and humidity data, making it easy to integrate the DHT11 sensor into your Arduino projects.
- Introduced the `readTemperatureHumidity(int &temperature, int &humidity)` method, allowing for efficient simultaneous reading of temperature and humidity, streamlining the data acquisition process.
50
+
- Refactored the internal data reading process, reducing code repetition and improving maintainability.
51
+
- Enhanced error handling: Now, specific error codes are returned from the `readTemperatureHumidity` method, making it consistent with the `readTemperature` and `readHumidity` methods.
52
+
- Documentation updated to reflect the new changes and provide clear guidance on using the new library version.
39
53
54
+
*Note: The updates in version 2.1.0 are backward compatible with the previous versions(v2.x.x), ensuring a smooth transition for existing projects.*
55
+
56
+
### v2.0.0 Update
40
57
- Changed the return type of `readTemperature()` and `readHumidity()` methods from `float` to `int`. This aligns with the DHT11 sensor's 1-degree resolution.
41
58
- Enhanced code documentation for easier maintenance and better readability.
42
59
- Added the `getErrorString` method to return human-readable error messages based on error codes.
@@ -117,10 +134,12 @@ This library abstracts these complexities, allowing users to easily read tempera
117
134
- Include the `DHT11.h` header file.
118
135
- Create an instance of the DHT11 class, specifying the digital pin connected to the sensor's data pin.
119
136
- Use `readTemperature()` and `readHumidity()` methods to read the data.
137
+
-`getErrorString(int errorCode)`: Returns a human-readable error message based on the provided error code.
120
138
121
-
### New Methods in v2.0.0
139
+
### New Methods
140
+
141
+
-`readTemperatureHumidity(int &temperature, int &humidity)`: This new method allows for simultaneous reading of temperature and humidity, reducing the complexity and time required for separate readings. It returns an `int` indicating the success or specific error encountered during the operation.
122
142
123
-
-`getErrorString(int errorCode)`: Returns a human-readable error message based on the provided error code.
124
143
125
144
### Wiring Details
126
145
@@ -131,7 +150,7 @@ The DHT11 sensor has three or four pins, depending on the variant:
131
150
-**Ground (GND)**: Connect to the ground of your MCU.
132
151
-**NC (No Connect)**: Some variants have this pin. It is not used and can be left unconnected.
133
152
134
-
Remember to use a pull-up resistor (typically 10kΩ) between the VCC and Data pins for reliable communication.
153
+
Remember to use a pull-up resistor (typically 10kΩ) between the VCC and Data pins for reliable communication.(Optional)
135
154
136
155
## Examples
137
156
@@ -153,7 +172,7 @@ All examples provided use Arduino UNO's digital pin 2 as the default connection
153
172
154
173
The library provides clear error handling mechanisms. When reading data:
155
174
156
-
- If there's a timeout while waiting for a response from the sensor, the methods `readTemperature()` and `readHumidity()` return the value `DHT11::ERROR_TIMEOUT`.
175
+
- If there's a timeout while waiting for a response from the sensor, the methods `readTemperature()` and `readHumidity()`& return the value `DHT11::ERROR_TIMEOUT`.<!-- TODO update for int readTemperatureHumidity(int &temperature, int &humidity); -->
157
176
- If there's a checksum mismatch indicating data corruption, the methods return the value `DHT11::ERROR_CHECKSUM`.
158
177
159
178
For translating these error codes to human-readable strings, the library offers the `DHT11::getErrorString(int errorCode)` method.
@@ -202,8 +221,6 @@ The library has been tested and confirmed to work on the following boards:
`*` For xtensa-based boards (ESP32 and ESP8266), a delay is required between consecutive method calls for optimal performance. Check [Examples](/examples/) for the implementation details.
206
-
207
224
Given the vast number of boards and architectures available, it's a challenge for a solo developer to test on all. Community contributions in terms of compatibility testing are highly encouraged.
0 commit comments