Skip to content

Commit

Permalink
update build-CI + issue_20 examples (#24)
Browse files Browse the repository at this point in the history
* update build-CI + new examples for #20
  • Loading branch information
RobTillaart authored Sep 20, 2021
1 parent 6e3d80c commit e4e0105
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb
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.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
Expand All @@ -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"
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.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
Expand All @@ -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
Expand Down
14 changes: 12 additions & 2 deletions examples/SHT31_isConnected/SHT31_isConnected.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -59,7 +69,7 @@ void loop()
// sht.reset();
}
Serial.println();
delay(100);
delay(1000);
}


Expand Down
7 changes: 7 additions & 0 deletions examples/SHT31_two_I2C/.arduino-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compile:
# Choosing to run compilation tests on different Arduino platforms
platforms:
# - uno
# - leonardo
# - due
# - zero
100 changes: 100 additions & 0 deletions examples/SHT31_two_I2C/SHT31_two_I2C.ino
Original file line number Diff line number Diff line change
@@ -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 --
7 changes: 7 additions & 0 deletions examples/SHT31_two_I2C_array/.arduino-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compile:
# Choosing to run compilation tests on different Arduino platforms
platforms:
# - uno
# - leonardo
# - due
# - zero
82 changes: 82 additions & 0 deletions examples/SHT31_two_I2C_array/SHT31_two_I2C_array.ino
Original file line number Diff line number Diff line change
@@ -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 --
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/SHT31"
},
"version": "0.3.3",
"version": "0.3.4",
"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.3
version=0.3.4
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for the SHT31 temperature and humidity sensor
Expand Down

0 comments on commit e4e0105

Please sign in to comment.