Skip to content

Commit

Permalink
update library.json, readme, license, minor edits (#29)
Browse files Browse the repository at this point in the history
* update library.json, readme, license, minor edits
  • Loading branch information
RobTillaart committed Dec 28, 2021
1 parent ab5cbfe commit 4b358c7
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 28 deletions.
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) 2019-2021 Rob Tillaart
Copyright (c) 2019-2022 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
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# SHT31

Arduino library for the SHT31 temperature and humidity sensor
Arduino library for the SHT31 temperature and humidity sensor.

Relates to the SHT85 library - https://github.com/RobTillaart/SHT85

Expand Down Expand Up @@ -37,10 +37,10 @@ https://github.com/hawesg/SHT31D_Particle_Photon_ClosedCube
#### Base interface

- **SHT31()** constructor.
- **bool begin(address, dataPin, clockPin)** begin function for ESP8266 & ESP32;
- **bool begin(uint8_taddress, uint8_tdataPin, uint8_tclockPin)** begin function for ESP8266 & ESP32;
returns false if device address is incorrect or device cannot be reset.
- **bool begin(address)** for single I2C bus platforms, e.g UNO.
- **bool begin(address, TwoWire \*wire)** for platforms with multiple I2C buses.
- **bool begin(uint8_t address)** for single I2C bus platforms, e.g UNO.
- **bool begin(uint8_t address, TwoWire \*wire)** for platforms with multiple I2C buses.
- **bool read(bool fast = true)** blocks 4 (fast) or 15 (slow) milliseconds + actual read + math.
Does read both the temperature and humidity.
- **bool isConnected()** check sensor is reachable over I2C. Returns false if not connected.
Expand All @@ -62,7 +62,7 @@ you've performed a new reading.
- **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.

| Error | Symbolic | Description
| Error | Symbolic | Description |
|:-----:|:--------------------------|:----------------------------|
| 0x00 | SHT31_OK | no error |
| 0x81 | SHT31_ERR_WRITECMD | I2C write failed |
Expand All @@ -71,7 +71,7 @@ Be sure to clear the error flag by calling **getError()** before calling any com
| 0x84 | SHT31_ERR_NOT_CONNECT | Could not connect |
| 0x85 | SHT31_ERR_CRC_TEMP | CRC error in temperature |
| 0x86 | SHT31_ERR_CRC_HUM | CRC error in humidity |
| 0x87 | SHT31_ERR_CRC_STATUS | CRC error in statusfield |
| 0x87 | SHT31_ERR_CRC_STATUS | CRC error in status field |
| 0x88 | SHT31_ERR_HEATER_COOLDOWN | Heater need to cool down |
| 0x88 | SHT31_ERR_HEATER_ON | Could not switch on heater |

Expand Down Expand Up @@ -130,8 +130,8 @@ Returns false if reading fails or in case of a CRC failure.
| 4 | System reset detected | 0 | no reset since last ‘clear status register’ command
| | | 1 | reset detected (hard or soft reset command or supply fail) - default
| 3-2 | Reserved | 00 |
| 1 | Command status | 0 | last cmd executed successfully
| | | 1 | last cmd not processed. Invalid or failed checksum
| 1 | Command status | 0 | last command executed successfully
| | | 1 | last command not processed. Invalid or failed checksum
| 0 | Write data checksum status | 0 | checksum of last write correct
| | | 1 | checksum of last write transfer failed

Expand All @@ -151,3 +151,9 @@ See examples.
- investigate command ART (auto sampling at 4 Hz)
- investigate command BREAK (stop auto sampling)
- software I2C experiments?
- separate releaseNotes.md


#### Wont


3 changes: 2 additions & 1 deletion SHT31.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: SHT31.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.3.4
// VERSION: 0.3.5
// DATE: 2019-02-08
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
// https://www.adafruit.com/product/2857
Expand Down Expand Up @@ -29,6 +29,7 @@
// 0.3.3 2021-08-24 fix #22 prevent heater to switch on too fast.
// update readme
// 0.3.4 2021-09-19 update build-CI
// 0.3.5 2021-12-28 update library.json, readme, license, minor edits


#include "SHT31.h"
Expand Down
4 changes: 2 additions & 2 deletions SHT31.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: SHT31.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.4
// VERSION: 0.3.5
// DATE: 2019-02-08
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
// https://www.adafruit.com/product/2857
Expand All @@ -14,7 +14,7 @@
#include "Wire.h"


#define SHT31_LIB_VERSION (F("0.3.4"))
#define SHT31_LIB_VERSION (F("0.3.5"))


// fields readStatus
Expand Down
2 changes: 1 addition & 1 deletion examples/SHT31_I2Cspeed/SHT31_I2Cspeed.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_I2Cspeed
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: testing the performance at different I2C speeds
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -61,3 +60,4 @@ void test()


// -- END OF FILE --

3 changes: 2 additions & 1 deletion examples/SHT31_async/SHT31_async.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_async.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo async interface
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -67,4 +66,6 @@ void loop()
cnt++; // simulate other activity
}


// -- END OF FILE --

3 changes: 2 additions & 1 deletion examples/SHT31_demo/SHT31_demo.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_demo.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.0.2
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -49,4 +48,6 @@ void loop()
delay(100);
}


// -- END OF FILE --

2 changes: 1 addition & 1 deletion examples/SHT31_heater/SHT31_heater.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_heater.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo heater functions
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -67,3 +66,4 @@ void printHeaterStatus(uint16_t status)


// -- END OF FILE --

2 changes: 1 addition & 1 deletion examples/SHT31_isConnected/SHT31_isConnected.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_isConnected.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo (needs 0.2.4 or up)
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -74,3 +73,4 @@ void loop()


// -- END OF FILE --

2 changes: 1 addition & 1 deletion examples/SHT31_lastRead/SHT31_lastRead.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_lastRead.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -48,3 +47,4 @@ void loop()


// -- END OF FILE --

3 changes: 2 additions & 1 deletion examples/SHT31_rawValues/SHT31_rawValues.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_async.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.3.2
// PURPOSE: demo async interface
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -76,4 +75,6 @@ void loop()
cnt++; // simulate other activity
}


// -- END OF FILE --

2 changes: 1 addition & 1 deletion examples/SHT31_slowRead/SHT31_slowRead.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_slowRead.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT31

Expand Down Expand Up @@ -50,3 +49,4 @@ void loop()


// -- END OF FILE --

6 changes: 5 additions & 1 deletion examples/SHT31_two_I2C/.arduino-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on different Arduino platforms
platforms:
# - uno
# - leonardo
# - due
# - zero
# - leonardo
# - m4
# - esp32
# - esp8266
# - mega2560
4 changes: 2 additions & 2 deletions examples/SHT31_two_I2C/SHT31_two_I2C.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
//
// FILE: SHT31_two_I2C.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT31
//
// NOTE: see issue #22 for details
// originally written for a ATSAMD21G18A custom board.
//


#include "Wire.h"
Expand Down Expand Up @@ -97,4 +95,6 @@ void loop()
delay(1000);
}


// -- END OF FILE --

6 changes: 5 additions & 1 deletion examples/SHT31_two_I2C_array/.arduino-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on different Arduino platforms
platforms:
# - uno
# - leonardo
# - due
# - zero
# - leonardo
# - m4
# - esp32
# - esp8266
# - mega2560
3 changes: 2 additions & 1 deletion examples/SHT31_two_I2C_array/SHT31_two_I2C_array.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: SHT31_two_I2C.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT31
//
Expand Down Expand Up @@ -79,4 +78,6 @@ void loop()
delay(1000);
}


// -- END OF FILE --

4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SHT31",
"keywords": "SHT31, Temperature, Humidity, I2C, SHT30, SHT35",
"keywords": "SHT31,Temperature,Humidity,I2C,SHT30,SHT35",
"description": "Arduino library for the I2C SHT31 temperature and humidity sensor",
"authors":
[
Expand All @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/SHT31"
},
"version": "0.3.4",
"version": "0.3.5",
"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=SHT31
version=0.3.4
version=0.3.5
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for the SHT31 temperature and humidity sensor
Expand Down
31 changes: 31 additions & 0 deletions test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ int expect; // TODO needed as there seems a problem with 8 bit comparisons (cha

uint32_t start, stop;


unittest_setup()
{
fprintf(stderr, "SHT31_LIB_VERSION: %s\n", (char *) SHT31_LIB_VERSION);
}


Expand All @@ -48,6 +50,35 @@ unittest_teardown()
}


unittest(test_constants_1)
{
fprintf(stderr, "fields readStatus\n");
assertEqual(SHT31_STATUS_ALERT_PENDING , (1 << 15) );
assertEqual(SHT31_STATUS_HEATER_ON , (1 << 13) );
assertEqual(SHT31_STATUS_HUM_TRACK_ALERT , (1 << 11) );
assertEqual(SHT31_STATUS_TEMP_TRACK_ALERT, (1 << 10) );
assertEqual(SHT31_STATUS_SYSTEM_RESET , (1 << 4) );
assertEqual(SHT31_STATUS_COMMAND_STATUS , (1 << 1) );
assertEqual(SHT31_STATUS_WRITE_CRC_STATUS, (1 << 0) );
}


unittest(test_constants_2)
{
fprintf(stderr, "error codes\n");
assertEqual(SHT31_OK , 0x00);
assertEqual(SHT31_ERR_WRITECMD , 0x81);
assertEqual(SHT31_ERR_READBYTES , 0x82);
assertEqual(SHT31_ERR_HEATER_OFF , 0x83);
assertEqual(SHT31_ERR_NOT_CONNECT , 0x84);
assertEqual(SHT31_ERR_CRC_TEMP , 0x85);
assertEqual(SHT31_ERR_CRC_HUM , 0x86);
assertEqual(SHT31_ERR_CRC_STATUS , 0x87);
assertEqual(SHT31_ERR_HEATER_COOLDOWN, 0x88);
assertEqual(SHT31_ERR_HEATER_ON , 0x89);
}


unittest(test_begin)
{
SHT31 sht;
Expand Down

0 comments on commit 4b358c7

Please sign in to comment.