Skip to content

Commit

Permalink
update readStatus() + add getAddress() (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart authored Dec 21, 2022
1 parent bf043d8 commit 3488d44
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [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
- the state is sent after a read command as first byte
- see https://github.com/RobTillaart/DHT20/issues/8 + page 11 datasheet
- add **getAddress()** convenience function.


## [0.2.0] - 2022-10-30
- add changelog.md
- add rp2040 to build-CI
Expand Down
14 changes: 7 additions & 7 deletions DHT20.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
//
// FILE: DHT20.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// VERSION: 0.2.1
// PURPOSE: Arduino library for DHT20 I2C temperature and humidity sensor.
//
// HISTORY: see changelog.md


#include "DHT20.h"
Expand Down Expand Up @@ -62,6 +60,12 @@ bool DHT20::isConnected()
}


uint8_t DHT20::getAddress()
{
return DHT20_ADDRESS;
}


// See datasheet 7.4 Sensor Reading Process, point 1
// use with care.
uint8_t DHT20::resetSensor()
Expand Down Expand Up @@ -225,10 +229,6 @@ float DHT20::getTempOffset()
//
uint8_t DHT20::readStatus()
{
_wire->beginTransmission(DHT20_ADDRESS);
_wire->write(0x71);
_wire->endTransmission();
delay(1); // needed to stabilize timing
_wire->requestFrom(DHT20_ADDRESS, (uint8_t)1);
delay(1); // needed to stabilize timing
return (uint8_t) _wire->read();
Expand Down
5 changes: 3 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.0
// VERSION: 0.2.1
// HISTORY: See DHT20.cpp
// URL: https://github.com/RobTillaart/DHT20
//
Expand All @@ -21,7 +21,7 @@
#include "Arduino.h"
#include "Wire.h"

#define DHT20_LIB_VERSION (F("0.2.0"))
#define DHT20_LIB_VERSION (F("0.2.1"))

#define DHT20_OK 0
#define DHT20_ERROR_CHECKSUM -10
Expand All @@ -45,6 +45,7 @@ class DHT20
#endif
bool begin();
bool isConnected();
uint8_t getAddress();


// ASYNCHRONUOUS CALL
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Please let me know if other platforms work (or not).
- **bool begin(uint8_t dataPin, uint8_t clockPin)** begin for ESP32 et al, to set I2C bus pins.
- **bool begin()** initializer for non ESP32. Returns true if connected.
- **bool isConnected()** returns true if the address of the DHT20 can be seen on the I2C bus.

- **uint8_t getAddress()** returns the (fixed) address - convenience.

### Core

Expand Down Expand Up @@ -186,6 +186,7 @@ See examples
#### must
- improve documentation.
- investigate the bug from #8 further
(is done in 0.2.1 see issue #8)

#### should

Expand All @@ -197,7 +198,7 @@ See examples
- investigate optimizing timing in readStatus()
- delay(1) ==> microSeconds(???).
- connected flag?
- add **uint8_t getAddress()** to return the address (convenience).


#### won't

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.0",
"version": "0.2.1",
"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.0
version=0.2.1
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 3488d44

Please sign in to comment.