mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.2.0 SHT31_SWW
This commit is contained in:
parent
f04075ab5b
commit
e813875d60
@ -6,10 +6,14 @@ 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-12-09
|
||||
- refactor API, follow SHT31
|
||||
|
||||
----
|
||||
|
||||
## [0.1.2] - 2023-11-22
|
||||
- update readme.md
|
||||
|
||||
|
||||
## [0.1.1] - 2023-07-23
|
||||
- update documentation
|
||||
- minor edits
|
||||
|
@ -62,7 +62,13 @@ Accuracy table
|
||||
|
||||
|
||||
|
||||
#### Links
|
||||
#### 0.2.0 Breaking change
|
||||
|
||||
Version 0.2.0 introduced a breaking change in constructor and begin().
|
||||
Parameters have moved from begin() to the constructor.
|
||||
|
||||
|
||||
#### Related
|
||||
|
||||
These libraries need to be installed to get SHT31_SW working:
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: SHT31_SWW.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// AUTHOR: Rob Tillaart, Gunter Haug
|
||||
// VERSION: 0.2.0
|
||||
// DATE: 2019-02-08 (base SHT31 lib)
|
||||
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
|
||||
// to be used with the SoftwareWire library instead of (hardware) Wire.
|
||||
@ -29,10 +29,10 @@
|
||||
#define SHT31_HEATER_TIMEOUT 180000UL // milliseconds
|
||||
|
||||
|
||||
SHT31_SWW::SHT31_SWW()
|
||||
SHT31_SWW::SHT31_SWW(uint8_t address, SoftwareWire * wire)
|
||||
{
|
||||
_softwareWire = NULL;
|
||||
_address = 0;
|
||||
_address = address;
|
||||
_softwareWire = wire;
|
||||
_lastRead = 0;
|
||||
_rawTemperature = 0;
|
||||
_rawHumidity = 0;
|
||||
@ -44,25 +44,17 @@ SHT31_SWW::SHT31_SWW()
|
||||
}
|
||||
|
||||
|
||||
bool SHT31_SWW::begin(const uint8_t address, SoftwareWire * wire)
|
||||
bool SHT31_SWW::begin()
|
||||
{
|
||||
if ((address != 0x44) && (address != 0x45))
|
||||
if ((_address != 0x44) && (_address != 0x45))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_address = address;
|
||||
_softwareWire = wire;
|
||||
_softwareWire->begin();
|
||||
return reset();
|
||||
}
|
||||
|
||||
|
||||
bool SHT31_SWW::begin(SoftwareWire * wire)
|
||||
{
|
||||
return begin(SHT_DEFAULT_ADDRESS, wire);
|
||||
}
|
||||
|
||||
|
||||
bool SHT31_SWW::isConnected()
|
||||
{
|
||||
_softwareWire->beginTransmission(_address);
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: SHT31_SWW.h
|
||||
// AUTHOR: Rob Tillaart, Gunter Haug
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.2.0
|
||||
// DATE: 2019-02-08 (base SHT31 lib)
|
||||
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
|
||||
// to be used with the SoftwareWire library instead of (hardware) Wire.
|
||||
@ -17,17 +17,15 @@
|
||||
#include "SHT31.h"
|
||||
|
||||
|
||||
#define SHT31_SWW_LIB_VERSION (F("0.1.2"))
|
||||
#define SHT31_SWW_LIB_VERSION (F("0.2.0"))
|
||||
|
||||
|
||||
class SHT31_SWW : public SHT31
|
||||
{
|
||||
public:
|
||||
SHT31_SWW();
|
||||
SHT31_SWW(uint8_t address, SoftwareWire *wire);
|
||||
|
||||
// use SHT_DEFAULT_ADDRESS
|
||||
bool begin(const uint8_t address, SoftwareWire *wire);
|
||||
bool begin(SoftwareWire *wire);
|
||||
bool begin();
|
||||
|
||||
// check sensor is reachable over I2C
|
||||
bool isConnected();
|
||||
|
@ -15,7 +15,7 @@ SoftwareWire sw(6, 7);
|
||||
uint32_t start;
|
||||
uint32_t stop;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -26,8 +26,8 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
Serial.print(stat, HEX);
|
||||
@ -57,7 +57,7 @@ void test()
|
||||
Serial.print(sht.getTemperature(), 1);
|
||||
Serial.print("\t");
|
||||
Serial.println(sht.getHumidity(), 1);
|
||||
delay(100);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ uint32_t start;
|
||||
uint32_t stop;
|
||||
uint32_t cnt;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -27,8 +27,8 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
Serial.print(stat, HEX);
|
||||
@ -44,9 +44,9 @@ void loop()
|
||||
if (sht.dataReady())
|
||||
{
|
||||
start = micros();
|
||||
bool success = sht.readData(); // default = true = fast
|
||||
bool success = sht.readData(); // default = true = fast
|
||||
stop = micros();
|
||||
sht.requestData(); // request for next sample
|
||||
sht.requestData(); // request for next sample
|
||||
|
||||
Serial.print("\t");
|
||||
Serial.print(stop - start);
|
||||
@ -65,8 +65,8 @@ void loop()
|
||||
cnt = 0;
|
||||
}
|
||||
}
|
||||
cnt++; // simulate other activity
|
||||
cnt++; // simulate other activity
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -14,7 +14,7 @@ SoftwareWire sw(6, 7);
|
||||
uint32_t start;
|
||||
uint32_t stop;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -25,10 +25,10 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
bool b = sht.begin(SHT31_ADDRESS, &sw);
|
||||
// sw.setClock(50000);
|
||||
bool b = sht.begin();
|
||||
Serial.print("CON: ");
|
||||
Serial.println(b);
|
||||
// sw.setClock(50000);
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
Serial.print(stat, HEX);
|
||||
|
@ -15,7 +15,7 @@ SoftwareWire sw(6, 7);
|
||||
uint32_t start;
|
||||
uint32_t stop;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
uint16_t status;
|
||||
|
||||
|
||||
@ -27,10 +27,10 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
sht.setHeatTimeout(30); // heater timeout 30 seconds, just for demo.
|
||||
sht.setHeatTimeout(30); // heater timeout 30 seconds, just for demo.
|
||||
|
||||
status = sht.readStatus();
|
||||
printHeaterStatus(status);
|
||||
@ -52,7 +52,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
// forced switch off
|
||||
// forced switch off
|
||||
if (status & SHT31_STATUS_HEATER_ON) sht.heatOff();
|
||||
}
|
||||
|
||||
@ -70,4 +70,4 @@ void printHeaterStatus(uint16_t status)
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -16,7 +16,7 @@ uint32_t start;
|
||||
uint32_t stop;
|
||||
uint32_t connectionFails = 0;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -27,8 +27,8 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
Serial.print(stat, HEX);
|
||||
|
@ -15,7 +15,7 @@ SoftwareWire sw(6, 7);
|
||||
uint32_t start;
|
||||
uint32_t stop;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -26,8 +26,8 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
@ -38,7 +38,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
sht.read(); // default = true/fast slow = false
|
||||
sht.read(); // default = true/fast slow = false
|
||||
Serial.print("\t");
|
||||
Serial.print(sht.lastRead());
|
||||
Serial.print("\t");
|
||||
@ -49,4 +49,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -16,7 +16,7 @@ uint32_t start;
|
||||
uint32_t stop;
|
||||
uint32_t cnt;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -27,8 +27,8 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
@ -48,9 +48,9 @@ void loop()
|
||||
if (sht.dataReady())
|
||||
{
|
||||
start = micros();
|
||||
bool success = sht.readData(); // default = true = fast
|
||||
bool success = sht.readData(); // default = true = fast
|
||||
stop = micros();
|
||||
sht.requestData(); // request for next sample
|
||||
sht.requestData(); // request for next sample
|
||||
|
||||
Serial.print("\t");
|
||||
Serial.print(stop - start);
|
||||
@ -65,19 +65,23 @@ void loop()
|
||||
rawHumidity = sht.getRawHumidity();
|
||||
Serial.print(rawTemperature, HEX);
|
||||
Serial.print(" = ");
|
||||
Serial.print(rawTemperature * (175.0 / 65535) - 45, 1); // This formula comes from page 14 of the SHT31 datasheet
|
||||
|
||||
// This formula comes from page 14 of the SHT31 datasheet
|
||||
Serial.print(rawTemperature * (175.0 / 65535) - 45, 1);
|
||||
Serial.print("°C\t");
|
||||
Serial.print(sht.getRawHumidity(), HEX);
|
||||
Serial.print(" = ");
|
||||
Serial.print(rawHumidity * (100.0 / 65535), 1); // This formula comes from page 14 of the SHT31 datasheet
|
||||
|
||||
// This formula comes from page 14 of the SHT31 datasheet
|
||||
Serial.print(rawHumidity * (100.0 / 65535), 1);
|
||||
Serial.print("%\t");
|
||||
Serial.println(cnt);
|
||||
cnt = 0;
|
||||
}
|
||||
}
|
||||
cnt++; // simulate other activity
|
||||
cnt++; // simulate other activity
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -15,7 +15,7 @@ SoftwareWire sw(6, 7);
|
||||
uint32_t start;
|
||||
uint32_t stop;
|
||||
|
||||
SHT31_SWW sht;
|
||||
SHT31_SWW sht(SHT31_ADDRESS, &sw);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -26,8 +26,8 @@ void setup()
|
||||
Serial.println(SHT31_SWW_LIB_VERSION);
|
||||
|
||||
sw.begin();
|
||||
sht.begin(SHT31_ADDRESS, &sw);
|
||||
sw.setClock(100000);
|
||||
sht.begin();
|
||||
|
||||
uint16_t stat = sht.readStatus();
|
||||
Serial.print(stat, HEX);
|
||||
|
@ -26,7 +26,7 @@
|
||||
"version": "^1.6.0"
|
||||
}
|
||||
],
|
||||
"version": "0.1.2",
|
||||
"version": "0.2.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "avr",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=SHT31_SWW
|
||||
version=0.1.2
|
||||
version=0.2.0
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user