Skip to content

Commit e4e0105

Browse files
authored
update build-CI + issue_20 examples (#24)
* update build-CI + new examples for #20
1 parent 6e3d80c commit e4e0105

File tree

10 files changed

+221
-9
lines changed

10 files changed

+221
-9
lines changed

.github/workflows/arduino_test_runner.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ name: Arduino CI
44
on: [push, pull_request]
55

66
jobs:
7-
arduino_ci:
7+
runTest:
88
runs-on: ubuntu-latest
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: Arduino-CI/action@v0.1.0
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb

SHT31.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: SHT31.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.3.3
4+
// VERSION: 0.3.4
55
// DATE: 2019-02-08
66
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
77
// https://www.adafruit.com/product/2857
@@ -28,6 +28,7 @@
2828
// 0.3.2 2021-08-05 expose raw data from sensor
2929
// 0.3.3 2021-08-24 fix #22 prevent heater to switch on too fast.
3030
// update readme
31+
// 0.3.4 2021-09-19 update build-CI
3132

3233

3334
#include "SHT31.h"

SHT31.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: SHT31.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.3.3
5+
// VERSION: 0.3.4
66
// DATE: 2019-02-08
77
// PURPOSE: Arduino library for the SHT31 temperature and humidity sensor
88
// https://www.adafruit.com/product/2857
@@ -14,7 +14,7 @@
1414
#include "Wire.h"
1515

1616

17-
#define SHT31_LIB_VERSION (F("0.3.3"))
17+
#define SHT31_LIB_VERSION (F("0.3.4"))
1818

1919

2020
// fields readStatus

examples/SHT31_isConnected/SHT31_isConnected.ino

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,22 @@ void loop()
4040
if ( sht.isConnected() )
4141
{
4242
start = micros();
43-
sht.read(); // default = true/fast slow = false
43+
bool b = sht.read(); // default = true/fast slow = false
4444
stop = micros();
45+
46+
int error = sht.getError();
47+
uint16_t stat = sht.readStatus();
48+
4549
Serial.print(millis());
4650
Serial.print("\t");
4751
Serial.print(stop - start);
4852
Serial.print("\t");
53+
Serial.print(b, HEX);
54+
Serial.print("\t");
55+
Serial.print(error, HEX);
56+
Serial.print("\t");
57+
Serial.print(stat, HEX);
58+
Serial.print("\t");
4959
Serial.print(sht.getTemperature(), 1);
5060
Serial.print("\t");
5161
Serial.print(sht.getHumidity(), 1);
@@ -59,7 +69,7 @@ void loop()
5969
// sht.reset();
6070
}
6171
Serial.println();
62-
delay(100);
72+
delay(1000);
6373
}
6474

6575

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
compile:
2+
# Choosing to run compilation tests on different Arduino platforms
3+
platforms:
4+
# - uno
5+
# - leonardo
6+
# - due
7+
# - zero
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
//
2+
// FILE: SHT31_two_I2C.ino
3+
// AUTHOR: Rob Tillaart
4+
// VERSION: 0.1.0
5+
// PURPOSE: demo
6+
// URL: https://github.com/RobTillaart/SHT31
7+
//
8+
// NOTE: see issue #22 for details
9+
// originally written for a ATSAMD21G18A custom board.
10+
//
11+
12+
13+
#include "Wire.h"
14+
#include "SHT31.h"
15+
16+
17+
TwoWire myWire(&sercom5, 0, 1);
18+
// TwoWire myWire = Wire1; // test.
19+
20+
21+
// note: address reuse on second I2C bus
22+
#define SHT31_ADDRESS_1 0x44
23+
#define SHT31_ADDRESS_2 0x45
24+
#define SHT31_ADDRESS_3 0x44
25+
#define SHT31_ADDRESS_4 0x45
26+
27+
28+
SHT31 sht_1;
29+
SHT31 sht_2;
30+
SHT31 sht_3;
31+
SHT31 sht_4;
32+
33+
34+
bool b1, b2, b3, b4;
35+
36+
37+
void setup()
38+
{
39+
Serial.begin(115200);
40+
Serial.println(__FILE__);
41+
Serial.print("SHT31_LIB_VERSION: \t");
42+
Serial.println(SHT31_LIB_VERSION);
43+
44+
Wire.begin();
45+
Wire.setClock(100000);
46+
myWire.begin();
47+
myWire.setClock(100000);
48+
49+
// see datasheet for details
50+
pinPeripheral(0, PIO_SERCOM_ALT);
51+
pinPeripheral(1, PIO_SERCOM_ALT);
52+
53+
b1 = sht_1.begin(SHT31_ADDRESS_1, &Wire);
54+
b2 = sht_2.begin(SHT31_ADDRESS_2, &Wire);
55+
b3 = sht_3.begin(SHT31_ADDRESS_3, &myWire);
56+
b4 = sht_4.begin(SHT31_ADDRESS_4, &myWire);
57+
58+
// see if they are connected
59+
Serial.print("BEGIN:\t");
60+
Serial.print(b1);
61+
Serial.print("\t");
62+
Serial.print(b2);
63+
Serial.print("\t");
64+
Serial.print(b3);
65+
Serial.print("\t");
66+
Serial.print(b4);
67+
Serial.print("\t");
68+
Serial.println();
69+
}
70+
71+
72+
void loop()
73+
{
74+
// read all sensors that are found
75+
if (b1) sht_1.read();
76+
if (b2) sht_2.read();
77+
if (b3) sht_3.read();
78+
if (b4) sht_4.read();
79+
80+
Serial.print(sht_1.getTemperature(), 1);
81+
Serial.print("\t");
82+
Serial.print(sht_2.getTemperature(), 1);
83+
Serial.print("\t");
84+
Serial.print(sht_3.getTemperature(), 1);
85+
Serial.print("\t");
86+
Serial.print(sht_4.getTemperature(), 1);
87+
Serial.print("\t");
88+
Serial.print(sht_1.getHumidity(), 1);
89+
Serial.print("\t");
90+
Serial.print(sht_2.getHumidity(), 1);
91+
Serial.print("\t");
92+
Serial.print(sht_3.getHumidity(), 1);
93+
Serial.print("\t");
94+
Serial.print(sht_4.getHumidity(), 1);
95+
Serial.println();
96+
97+
delay(1000);
98+
}
99+
100+
// -- END OF FILE --
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
compile:
2+
# Choosing to run compilation tests on different Arduino platforms
3+
platforms:
4+
# - uno
5+
# - leonardo
6+
# - due
7+
# - zero
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//
2+
// FILE: SHT31_two_I2C.ino
3+
// AUTHOR: Rob Tillaart
4+
// VERSION: 0.1.0
5+
// PURPOSE: demo
6+
// URL: https://github.com/RobTillaart/SHT31
7+
//
8+
// NOTE: see issue #22 for details
9+
// originally written for a ATSAMD21G18A custom board.
10+
// edited for a board (e.g. ESP32) that has Wire and Wire1 (compiles, not tested)
11+
12+
13+
#include "Wire.h"
14+
#include "SHT31.h"
15+
16+
17+
// TwoWire myWire(&sercom5, 0, 1);
18+
TwoWire myWire = Wire1;
19+
20+
21+
uint8_t addr[4] = { 0x44, 0x45, 0x44, 0x45 };
22+
TwoWire * wireAr[4] = { &Wire, &Wire, &myWire, &myWire };
23+
SHT31 sht[4];
24+
bool b[4];
25+
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
Serial.println(__FILE__);
31+
Serial.print("SHT31_LIB_VERSION: \t");
32+
Serial.println(SHT31_LIB_VERSION);
33+
34+
Wire.begin();
35+
Wire.setClock(100000);
36+
myWire.begin();
37+
myWire.setClock(100000);
38+
39+
// see datasheet for details
40+
// pinPeripheral(0, PIO_SERCOM_ALT);
41+
// pinPeripheral(1, PIO_SERCOM_ALT);
42+
43+
for (uint8_t i = 0; i < 4; i++)
44+
{
45+
b[i] = sht[i].begin(addr[i], wireAr[i]);
46+
}
47+
48+
// see if they are connected
49+
Serial.print("BEGIN:\t");
50+
for (uint8_t i = 0; i < 4; i++)
51+
{
52+
Serial.print(b[i]);
53+
Serial.print("\t");
54+
}
55+
Serial.println();
56+
}
57+
58+
59+
void loop()
60+
{
61+
// read all that are found
62+
for (uint8_t i = 0; i < 4; i++)
63+
{
64+
if (b[i]) sht[i].read();
65+
}
66+
67+
for (uint8_t i = 0; i < 4; i++)
68+
{
69+
Serial.print(sht[i].getTemperature(), 1);
70+
Serial.print("\t");
71+
}
72+
for (uint8_t i = 0; i < 4; i++)
73+
{
74+
Serial.print(sht[i].getHumidity(), 1);
75+
Serial.print("\t");
76+
}
77+
Serial.println();
78+
79+
delay(1000);
80+
}
81+
82+
// -- END OF FILE --

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/SHT31"
1717
},
18-
"version": "0.3.3",
18+
"version": "0.3.4",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SHT31
2-
version=0.3.3
2+
version=0.3.4
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino library for the SHT31 temperature and humidity sensor

0 commit comments

Comments
 (0)