Skip to content

Commit

Permalink
update documentation (#9)
Browse files Browse the repository at this point in the history
- update documentation
- remove commented **SoftwareWire** version => own repo.
  • Loading branch information
RobTillaart committed Jul 23, 2023
1 parent ab573d1 commit f1272f6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 164 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.1.2] - 2023-07-23
- update documentation
- remove commented **SoftwareWire** version => own repo.


## [0.1.1] - 2023-05-12
- add **commented** version with **SoftwareWire** to "fix" issue #5
- clean up SHT31_SW.cpp
- update keywords.txt
- update readme.md


## [0.1.0] - 2023-03-23
- initial version, derives from SHT31 0.3.8
- uses **SoftWire** I2C library.
Expand Down
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Arduino library for the SHT31 temperature and humidity sensor - using **SoftWire

## Description

This experimental library features the class SHT31_SW derived from - https://github.com/RobTillaart/SHT31
This **experimental** library features the class SHT31_SW derived from - https://github.com/RobTillaart/SHT31.
It has the same interface as the SHT31 class so please use that documentation
as it will be the "leading class".

The main difference is that this SHT31_SW class uses the **SoftWire**
library for communication instead of the **TwoWire** based **Wire** class.
The main difference is that the SHT31_SW class uses the **SoftWire** library
for communication instead of the **TwoWire** based **Wire** class.
See SHT31 PR #35.

**SoftWire** is a software I2C bus library to be able to select other pins
Expand All @@ -27,43 +27,44 @@ An important reason to use this version is when you want more than two
devices on one Arduino.


#### SoftwareWire (AVR only)
#### SoftWire vs SoftwareWire

The **SoftWire** library is portable, but seems less stable as it could not read
the SHT85 sensor which is command compatible with the SHT3x.
The cause is not found yet, so until then an alternative **SoftwareWire** is included.
(If you know a solution, please let me know).
The **SoftWire** library is portable, however it could not read (on AVR)
the SHT85 sensor which is command compatible with the SHT3x.
The cause is not found yet.
Therefore a separate repo is created based upon the AVR specific **SoftwareWire**
see links below.
If you know a solution to get softWire working on AVR, please let me know.

The **SoftwareWire** library is an AVR specific and worked for the SHT85.
See https://github.com/RobTillaart/SHT31_SW/issues/5

You need to comment/uncomment the .h and .cpp file and of course use **SoftwareWire**
instead of **SoftWire** in your project.

#### SHT3x SHT85 sensors

#### SHT sensors

The SHT3x family of sensors should work up to 1 MHz I2C (although
The SHT3x family of sensors should work up to 1 MHz I2C although not tested above 400 MHz.

This library should also work for SHT30/35/85 but these are not tested yet.

Accuracy table
Test on UNO

| SENSOR | Temperature | Humidity | works with |
| SENSOR | Temperature | Humidity | works |
|:--------:|:-------------:|:----------:|:---------------|
| SHT30 | ~0.3 | 2.0 | (not tested) |
| SHT31 | ~0.3 | 1.5 | SoftWire |
| SHT31 | ~0.3 | 1.5 | yes |
| SHT35 | ~0.2 | 1.5 | (not tested) |
| SHT85 | ~0.2 | 1.5 | SoftwareWire |
| SHT85 | ~0.2 | 1.5 | no | See SHT31_SWW


#### Links

These libraries need to be installed to get SHT31_SW working:

- https://github.com/RobTillaart/SHT31
- https://github.com/stevemarple/SoftWire
- https://github.com/stevemarple/AsyncDelay
- https://github.com/stevemarple/SoftWire

Related
- https://github.com/Testato/SoftwareWire // AVR only


Expand Down Expand Up @@ -101,7 +102,8 @@ you've performed a new reading.
#### Error interface

- **int getError()** returns last set error flag and clear it.
Be sure to clear the error flag by calling **getError()** before calling any command as the error flag could be from a previous command.
Be sure to clear the error flag by calling **getError()** before calling
any command as the error flag could be from a previous command.

| Error | Symbolic | Description |
|:-------:|:----------------------------|:------------------------------|
Expand Down Expand Up @@ -181,12 +183,13 @@ Returns false if reading fails or in case of a CRC failure.

#### Must

- keep in sync with (leading) SHT31 library.
- remove script for atomic if not needed any more.
- investigate why SHT85 does not work with SoftWire.
- keep in sync with (leading) SHT31 and SHT31_SWW library.

#### Should

- remove script for atomic if not needed any more.
- investigate why SHT85 does not work with SoftWire.

#### Could

#### Wont
Expand Down
98 changes: 4 additions & 94 deletions SHT31_SW.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// FILE: SHT31_SW.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.1.2
// DATE: 2019-02-08 (base SHT31 lib)
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
// to be used with the SoftWire library instead of (hardware) Wire.
// derives from SHT31 0.3.8
// https://www.adafruit.com/product/2857
// URL: https://github.com/RobTillaart/SHT31_SW
// URL: https://github.com/RobTillaart/SHT31
// URL: https://www.adafruit.com/product/2857
// https://github.com/RobTillaart/SHT31_SW
// https://github.com/RobTillaart/SHT31


#include "SHT31_SW.h"
Expand Down Expand Up @@ -91,95 +91,5 @@ bool SHT31_SW::readBytes(uint8_t n, uint8_t *val)
}



/////////////////////////////////////////////////////////
//
// This version is using an AVR specific SoftwareWire
// it can read the SHT85 where the above can't.
// See https://github.com/RobTillaart/SHT31_SW/issues/5
//
// you need to comment the above version (also in .h file)
// and use SoftwareWire instead of SoftWire in your project.
//

/*
SHT31_SW::SHT31_SW()
{
_softWire = NULL;
_address = 0;
_lastRead = 0;
_rawTemperature = 0;
_rawHumidity = 0;
_heatTimeout = 0;
_heaterStart = 0;
_heaterStop = 0;
_heaterOn = false;
_error = SHT31_OK;
}
bool SHT31_SW::begin(const uint8_t address, SoftwareWire *softWire)
{
if ((address != 0x44) && (address != 0x45))
{
return false;
}
_address = address;
_softWire = softWire;
_softWire->begin();
return reset();
}
bool SHT31_SW::begin(SoftwareWire *softWire)
{
return begin(SHT_DEFAULT_ADDRESS, softWire);
}
bool SHT31_SW::isConnected()
{
_softWire->beginTransmission(_address);
int rv = _softWire->endTransmission();
if (rv != 0) _error = SHT31_ERR_NOT_CONNECT;
return (rv == 0);
}
////////////////////////////////////////////////////
//
// PRIVATE
//
bool SHT31_SW::writeCmd(uint16_t cmd)
{
_softWire->beginTransmission(_address);
_softWire->write(cmd >> 8 );
_softWire->write(cmd & 0xFF);
if (_softWire->endTransmission() != 0)
{
_error = SHT31_ERR_WRITECMD;
return false;
}
return true;
}
bool SHT31_SW::readBytes(uint8_t n, uint8_t *val)
{
int rv = _softWire->requestFrom(_address, (uint8_t) n);
if (rv == n)
{
for (uint8_t i = 0; i < n; i++)
{
val[i] = _softWire->read();
}
return true;
}
_error = SHT31_ERR_READBYTES;
return false;
}
*/


// -- END OF FILE --

50 changes: 6 additions & 44 deletions SHT31_SW.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
//
// FILE: SHT31_SW.h
// AUTHOR: Rob Tillaart, Gunter Haug
// VERSION: 0.1.1
// VERSION: 0.1.2
// DATE: 2019-02-08 (base SHT31 lib)
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
// to be used with the SoftWire library instead of (hardware) Wire.
// derives from SHT31 0.3.8
// https://www.adafruit.com/product/2857
// URL: https://github.com/RobTillaart/SHT31_SW
// URL: https://github.com/RobTillaart/SHT31
// URL: https://www.adafruit.com/product/2857
// https://github.com/RobTillaart/SHT31_SW
// https://github.com/RobTillaart/SHT31


#define SHT31_SW_LIB_VERSION (F("0.1.1"))
#define SHT31_SW_LIB_VERSION (F("0.1.2"))


#include "Arduino.h"
Expand All @@ -29,7 +29,7 @@ class SHT31_SW : public SHT31
bool begin(const uint8_t address, SoftWire *wire);
bool begin(SoftWire *wire);

// check sensor is reachable over I2C
// check if sensor is reachable over I2C
bool isConnected();

private:
Expand All @@ -39,43 +39,5 @@ class SHT31_SW : public SHT31
};



/////////////////////////////////////////////////////////
//
// This version is using an AVR specific SoftwareWire
// it can read the SHT85 where the above can't.
// See https://github.com/RobTillaart/SHT31_SW/issues/5
//
// you need to comment the above version (also in .cpp file)
// and use SoftwareWire instead of SoftWire in your project.
//


/*
#include "Arduino.h"
#include "SoftwareWire.h"
#include "SHT31.h"
class SHT31_SW : public SHT31
{
public:
SHT31_SW();
// use SHT_DEFAULT_ADDRESS
bool begin(const uint8_t address, SoftwareWire *wire);
bool begin(SoftwareWire *wire);
// check sensor is reachable over I2C
bool isConnected();
private:
bool writeCmd(uint16_t cmd);
bool readBytes(uint8_t n, uint8_t *val);
SoftwareWire* _softWire;
};
*/


// -- END OF FILE --

15 changes: 14 additions & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@
"type": "git",
"url": "https://github.com/RobTillaart/SHT31_SW"
},
"version": "0.1.1",
"dependencies":
[
{
"owner": "Steve Marple",
"name": "SoftWire",
"version": "^2.0.9"
},
{
"owner": "Steve Marple",
"name": "AsyncDelay",
"version": "^1.1.2"
}
],
"version": "0.1.2",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SHT31_SW
version=0.1.1
version=0.1.2
author=Rob Tillaart <rob.tillaart@gmail.com>, Gunter Haug
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for the I2C SHT31 temperature and humidity sensor
Expand All @@ -8,5 +8,5 @@ category=Sensors
url=https://github.com/RobTillaart/SHT31_SW
architectures=*
includes=SHT31_SW.h
depends=
depends=SoftWire,AsyncDelay

0 comments on commit f1272f6

Please sign in to comment.