Skip to content

Commit

Permalink
update readme + examples (#17)
Browse files Browse the repository at this point in the history
- update readme.md
- update examples
  • Loading branch information
RobTillaart authored Jan 26, 2024
1 parent 7feb749 commit d618114
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.3.1] - 2024-01-26
- update readme.md
- update examples


## [0.3.0] - 2023-10-25
- simplify begin()
- updated all examples
Expand Down
2 changes: 1 addition & 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.3.0
// VERSION: 0.3.1
// PURPOSE: Arduino library for DHT20 I2C temperature and humidity sensor.


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.3.0
// VERSION: 0.3.1
// URL: https://github.com/RobTillaart/DHT20
//

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

#define DHT20_LIB_VERSION (F("0.3.0"))
#define DHT20_LIB_VERSION (F("0.3.1"))

#define DHT20_OK 0
#define DHT20_ERROR_CHECKSUM -10
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2023 Rob Tillaart
Copyright (c) 2022-2024 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ The DHT20 is a humidity and temperature sensor.
The sensor has a fixed address of **0x38**.
It is not known if the address can be changed.

The library must be initiated by calling the **begin()** function,
or **begin(dataPin, clockPin)** for **ESP32** and similar platforms.
The library must be initiated by calling the **begin()** function.

Thereafter one has to call the **read()** function to do the actual reading,
and call **getTemperature()** and **getHumidity()** to get the measured values.
Expand Down Expand Up @@ -55,10 +54,14 @@ reset the sensor if needed in both synchronous and asynchronous calls.
This keeps the API simple. The reads are 1-2 ms slower than 0.1.4. (< 50 ms).
Still far below the 80 ms mentioned in the datasheet.

### 0.3.0

User should call Wire.begin(), and setting I2C pins himself.
It is removed from the specific ESP32 begin() call to be more generic.
#### 0.3.0 Breaking change

Version 0.3.0 introduced a breaking change.
You cannot set the pins in **begin()** any more.
This reduces the dependency of processor dependent Wire implementations.
The user has to call **Wire.begin()** and can optionally set the Wire pins
before calling **begin()**.


#### Tested
Expand All @@ -75,6 +78,24 @@ The sensor has a fixed address of **0x38**.
It is not known if the address can be changed.


#### I2C multiplexing

Sometimes you need to control more devices than possible with the default
address range the device provides.
This is possible with an I2C multiplexer e.g. TCA9548 which creates up
to eight channels (think of it as I2C subnets) which can use the complete
address range of the device.

Drawback of using a multiplexer is that it takes more administration in
your code e.g. which device is on which channel.
This will slow down the access, which must be taken into account when
deciding which devices are on which channel.
Also note that switching between channels will slow down other devices
too if they are behind the multiplexer.

- https://github.com/RobTillaart/TCA9548


#### Connection

Always check datasheet!
Expand Down Expand Up @@ -148,7 +169,8 @@ and should only be used if you are in a need for speed.
#### Constructor

- **DHT20(TwoWire \*wire = &Wire)** constructor, using a specific Wire (I2C bus).
- **bool begin()** initializer for non ESP32. Returns true if connected.
- **bool begin()** initializer. Returns true if connected.
The user must call **Wire.begin()** before calling this function.
- **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.

Expand Down Expand Up @@ -251,6 +273,8 @@ the read calls. (0.2.0)
#### Must

- improve documentation.
- sync AM2315C developments
- see https://github.com/RobTillaart/AM2315C
- investigate the bug from #8 further
(is done in 0.2.1 see issue #8)

Expand Down Expand Up @@ -284,4 +308,3 @@ donate through PayPal or GitHub sponsors.

Thank you,


2 changes: 2 additions & 0 deletions examples/DHT20/DHT20.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand All @@ -19,6 +20,7 @@ DHT20 DHT;

uint8_t count = 0;


void setup()
{
Serial.begin(115200);
Expand Down
5 changes: 4 additions & 1 deletion examples/DHT20_I2C_speed/DHT20_I2C_speed.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20_I2C_speed.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand All @@ -14,12 +15,14 @@

// NOTE datasheet states 400 KHz as maximum


#include "DHT20.h"

DHT20 DHT;

uint32_t start, stop;


void setup()
{
Serial.begin(115200);
Expand Down Expand Up @@ -58,7 +61,7 @@ void setup()

Serial.print(speed);
Serial.print("\t");
Serial.print(stop - start); // time
Serial.print(stop - start); // time
Serial.print("\t");
Serial.print(DHT.getHumidity(), 1);
Serial.print("\t");
Expand Down
2 changes: 2 additions & 0 deletions examples/DHT20_async/DHT20_async.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20_async.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand All @@ -19,6 +20,7 @@ DHT20 DHT;

uint32_t counter = 0;


void setup()
{
Serial.begin(115200);
Expand Down
1 change: 1 addition & 0 deletions examples/DHT20_lcd/DHT20_lcd.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20_lcd.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand Down
1 change: 1 addition & 0 deletions examples/DHT20_offset/DHT20_offset.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20_offset.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand Down
1 change: 1 addition & 0 deletions examples/DHT20_plotter/DHT20_plotter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20_plotter.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand Down
2 changes: 2 additions & 0 deletions examples/DHT20_read_status/DHT20_read_status.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FILE: DHT20_read_status.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//
// Always check datasheet - front view
//
Expand All @@ -19,6 +20,7 @@ DHT20 DHT;

uint8_t count = 0;


void setup()
{
Serial.begin(115200);
Expand Down
2 changes: 1 addition & 1 deletion examples/DHT20_test_esp/DHT20_test_esp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// FILE: DHT20_test_esp.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//

// Always check datasheet - front view
//
// +--------------+
Expand Down
2 changes: 1 addition & 1 deletion examples/DHT20_test_rp2040/DHT20_test_rp2040.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// FILE: DHT20_test_rp2040.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/DHT20
//

// Always check datasheet - front view
//
// +--------------+
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.3.0",
"version": "0.3.1",
"license": "MIT",
"frameworks": "*",
"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.3.0
version=0.3.1
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for I2C DHT20 temperature and humidity sensor.
Expand Down
1 change: 0 additions & 1 deletion test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <ArduinoUnitTests.h>


#include "Wire.h"
#include "DHT20.h"


Expand Down

0 comments on commit d618114

Please sign in to comment.