Skip to content

Commit

Permalink
fix #12 timeout (#13)
Browse files Browse the repository at this point in the history
- fix #12 add time out to read function
  • Loading branch information
RobTillaart authored Jul 27, 2023
1 parent 3f1510a commit 3660205
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.2.3] - 2023-07-27
- fix #12 add time out to read function


## [0.2.2] - 2022-12-21
- update keywords.txt
- add defaults to offset functions.
- update readme.md
- update GitHub actions
- update license 2023


## [0.2.1] - 2022-12-21
- first part of the **readStatus()** not part of the protocol
- different interpretation of datasheet page 10 section 7.4
Expand Down
7 changes: 6 additions & 1 deletion DHT20.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: DHT20.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.2
// VERSION: 0.2.3
// PURPOSE: Arduino library for DHT20 I2C temperature and humidity sensor.


Expand Down Expand Up @@ -98,8 +98,13 @@ int DHT20::read()
int status = requestData();
if (status < 0) return status;
// wait for measurement ready
uint32_t start = millis();
while (isMeasuring())
{
if (millis() - start >= 1000)
{
return DHT20_ERROR_READ_TIMEOUT;
}
yield();
}
// read the measurement
Expand Down
4 changes: 2 additions & 2 deletions DHT20.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// FILE: DHT20.h
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DHT20 I2C temperature and humidity sensor.
// VERSION: 0.2.2
// VERSION: 0.2.3
// URL: https://github.com/RobTillaart/DHT20
//

Expand All @@ -20,7 +20,7 @@
#include "Arduino.h"
#include "Wire.h"

#define DHT20_LIB_VERSION (F("0.2.2"))
#define DHT20_LIB_VERSION (F("0.2.3"))

#define DHT20_OK 0
#define DHT20_ERROR_CHECKSUM -10
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/DHT20.git"
},
"version": "0.2.2",
"version": "0.2.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=DHT20
version=0.2.2
version=0.2.3
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for I2C DHT20 temperature and humidity sensor.
Expand Down

0 comments on commit 3660205

Please sign in to comment.