diff --git a/.github/workflows/arduino_test_runner.yml b/.github/workflows/arduino_test_runner.yml index b9b5b10..096b975 100644 --- a/.github/workflows/arduino_test_runner.yml +++ b/.github/workflows/arduino_test_runner.yml @@ -4,9 +4,14 @@ name: Arduino CI on: [push, pull_request] jobs: - arduino_ci: + runTest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: Arduino-CI/action@v0.1.0 \ No newline at end of file + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - run: | + gem install arduino_ci + arduino_ci.rb diff --git a/SHT31.cpp b/SHT31.cpp index cc9fb4d..fdc840c 100644 --- a/SHT31.cpp +++ b/SHT31.cpp @@ -1,7 +1,7 @@ // // FILE: SHT31.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.3.3 +// VERSION: 0.3.4 // DATE: 2019-02-08 // PURPOSE: Arduino library for the SHT31 temperature and humidity sensor // https://www.adafruit.com/product/2857 @@ -28,6 +28,7 @@ // 0.3.2 2021-08-05 expose raw data from sensor // 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 #include "SHT31.h" diff --git a/SHT31.h b/SHT31.h index b90b5df..c88fff2 100644 --- a/SHT31.h +++ b/SHT31.h @@ -2,7 +2,7 @@ // // FILE: SHT31.h // AUTHOR: Rob Tillaart -// VERSION: 0.3.3 +// VERSION: 0.3.4 // DATE: 2019-02-08 // PURPOSE: Arduino library for the SHT31 temperature and humidity sensor // https://www.adafruit.com/product/2857 @@ -14,7 +14,7 @@ #include "Wire.h" -#define SHT31_LIB_VERSION (F("0.3.3")) +#define SHT31_LIB_VERSION (F("0.3.4")) // fields readStatus diff --git a/examples/SHT31_isConnected/SHT31_isConnected.ino b/examples/SHT31_isConnected/SHT31_isConnected.ino index 82f05a5..df8896b 100644 --- a/examples/SHT31_isConnected/SHT31_isConnected.ino +++ b/examples/SHT31_isConnected/SHT31_isConnected.ino @@ -40,12 +40,22 @@ void loop() if ( sht.isConnected() ) { start = micros(); - sht.read(); // default = true/fast slow = false + bool b = sht.read(); // default = true/fast slow = false stop = micros(); + + int error = sht.getError(); + uint16_t stat = sht.readStatus(); + Serial.print(millis()); Serial.print("\t"); Serial.print(stop - start); Serial.print("\t"); + Serial.print(b, HEX); + Serial.print("\t"); + Serial.print(error, HEX); + Serial.print("\t"); + Serial.print(stat, HEX); + Serial.print("\t"); Serial.print(sht.getTemperature(), 1); Serial.print("\t"); Serial.print(sht.getHumidity(), 1); @@ -59,7 +69,7 @@ void loop() // sht.reset(); } Serial.println(); - delay(100); + delay(1000); } diff --git a/examples/SHT31_two_I2C/.arduino-ci.yml b/examples/SHT31_two_I2C/.arduino-ci.yml new file mode 100644 index 0000000..7a5dd0f --- /dev/null +++ b/examples/SHT31_two_I2C/.arduino-ci.yml @@ -0,0 +1,7 @@ +compile: + # Choosing to run compilation tests on different Arduino platforms + platforms: + # - uno + # - leonardo + # - due + # - zero diff --git a/examples/SHT31_two_I2C/SHT31_two_I2C.ino b/examples/SHT31_two_I2C/SHT31_two_I2C.ino new file mode 100644 index 0000000..f3a9a58 --- /dev/null +++ b/examples/SHT31_two_I2C/SHT31_two_I2C.ino @@ -0,0 +1,100 @@ +// +// 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" +#include "SHT31.h" + + +TwoWire myWire(&sercom5, 0, 1); +// TwoWire myWire = Wire1; // test. + + +// note: address reuse on second I2C bus +#define SHT31_ADDRESS_1 0x44 +#define SHT31_ADDRESS_2 0x45 +#define SHT31_ADDRESS_3 0x44 +#define SHT31_ADDRESS_4 0x45 + + +SHT31 sht_1; +SHT31 sht_2; +SHT31 sht_3; +SHT31 sht_4; + + +bool b1, b2, b3, b4; + + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("SHT31_LIB_VERSION: \t"); + Serial.println(SHT31_LIB_VERSION); + + Wire.begin(); + Wire.setClock(100000); + myWire.begin(); + myWire.setClock(100000); + + // see datasheet for details + pinPeripheral(0, PIO_SERCOM_ALT); + pinPeripheral(1, PIO_SERCOM_ALT); + + b1 = sht_1.begin(SHT31_ADDRESS_1, &Wire); + b2 = sht_2.begin(SHT31_ADDRESS_2, &Wire); + b3 = sht_3.begin(SHT31_ADDRESS_3, &myWire); + b4 = sht_4.begin(SHT31_ADDRESS_4, &myWire); + + // see if they are connected + Serial.print("BEGIN:\t"); + Serial.print(b1); + Serial.print("\t"); + Serial.print(b2); + Serial.print("\t"); + Serial.print(b3); + Serial.print("\t"); + Serial.print(b4); + Serial.print("\t"); + Serial.println(); +} + + +void loop() +{ + // read all sensors that are found + if (b1) sht_1.read(); + if (b2) sht_2.read(); + if (b3) sht_3.read(); + if (b4) sht_4.read(); + + Serial.print(sht_1.getTemperature(), 1); + Serial.print("\t"); + Serial.print(sht_2.getTemperature(), 1); + Serial.print("\t"); + Serial.print(sht_3.getTemperature(), 1); + Serial.print("\t"); + Serial.print(sht_4.getTemperature(), 1); + Serial.print("\t"); + Serial.print(sht_1.getHumidity(), 1); + Serial.print("\t"); + Serial.print(sht_2.getHumidity(), 1); + Serial.print("\t"); + Serial.print(sht_3.getHumidity(), 1); + Serial.print("\t"); + Serial.print(sht_4.getHumidity(), 1); + Serial.println(); + + delay(1000); +} + +// -- END OF FILE -- diff --git a/examples/SHT31_two_I2C_array/.arduino-ci.yml b/examples/SHT31_two_I2C_array/.arduino-ci.yml new file mode 100644 index 0000000..7a5dd0f --- /dev/null +++ b/examples/SHT31_two_I2C_array/.arduino-ci.yml @@ -0,0 +1,7 @@ +compile: + # Choosing to run compilation tests on different Arduino platforms + platforms: + # - uno + # - leonardo + # - due + # - zero diff --git a/examples/SHT31_two_I2C_array/SHT31_two_I2C_array.ino b/examples/SHT31_two_I2C_array/SHT31_two_I2C_array.ino new file mode 100644 index 0000000..3932b17 --- /dev/null +++ b/examples/SHT31_two_I2C_array/SHT31_two_I2C_array.ino @@ -0,0 +1,82 @@ +// +// 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. +// edited for a board (e.g. ESP32) that has Wire and Wire1 (compiles, not tested) + + +#include "Wire.h" +#include "SHT31.h" + + +// TwoWire myWire(&sercom5, 0, 1); +TwoWire myWire = Wire1; + + +uint8_t addr[4] = { 0x44, 0x45, 0x44, 0x45 }; +TwoWire * wireAr[4] = { &Wire, &Wire, &myWire, &myWire }; +SHT31 sht[4]; +bool b[4]; + + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("SHT31_LIB_VERSION: \t"); + Serial.println(SHT31_LIB_VERSION); + + Wire.begin(); + Wire.setClock(100000); + myWire.begin(); + myWire.setClock(100000); + + // see datasheet for details + // pinPeripheral(0, PIO_SERCOM_ALT); + // pinPeripheral(1, PIO_SERCOM_ALT); + + for (uint8_t i = 0; i < 4; i++) + { + b[i] = sht[i].begin(addr[i], wireAr[i]); + } + + // see if they are connected + Serial.print("BEGIN:\t"); + for (uint8_t i = 0; i < 4; i++) + { + Serial.print(b[i]); + Serial.print("\t"); + } + Serial.println(); +} + + +void loop() +{ + // read all that are found + for (uint8_t i = 0; i < 4; i++) + { + if (b[i]) sht[i].read(); + } + + for (uint8_t i = 0; i < 4; i++) + { + Serial.print(sht[i].getTemperature(), 1); + Serial.print("\t"); + } + for (uint8_t i = 0; i < 4; i++) + { + Serial.print(sht[i].getHumidity(), 1); + Serial.print("\t"); + } + Serial.println(); + + delay(1000); +} + +// -- END OF FILE -- diff --git a/library.json b/library.json index 460ff71..12e77c3 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/SHT31" }, - "version": "0.3.3", + "version": "0.3.4", "license": "MIT", "frameworks": "arduino", "platforms": "*" diff --git a/library.properties b/library.properties index 87baab7..e1a271b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SHT31 -version=0.3.3 +version=0.3.4 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for the SHT31 temperature and humidity sensor