@@ -36,93 +36,12 @@ necessary:
3636from the sensor, but return the values read last. To read a new sample, make
3737sure to call ` readSample() `
3838
39- ### Sample code
40- ``` c++
41- #include < Wire.h>
39+ ## Example projects
4240
43- #include < SHTSensor.h>
41+ See example project
42+ [ sht-autodetect] ( examples/sht-autodetect/sht-autodetect.ino )
4443
45- SHTSensor sht;
44+ ### Usage with multiple SHT31 sensors
4645
47- void setup () {
48- // put your setup code here, to run once:
49-
50- Wire.begin();
51- Serial.begin(9600);
52- sht.init();
53- }
54-
55- void loop () {
56- // put your main code here, to run repeatedly:
57-
58- sht.readSample();
59- Serial.print("SHT:\n");
60- Serial.print(" RH: ");
61- Serial.print(sht.getHumidity(), 2);
62- Serial.print("\n");
63- Serial.print(" T: ");
64- Serial.print(sht.getTemperature(), 2);
65- Serial.print("\n");
66-
67- delay (1000);
68- }
69- ```
70-
71- ### Usage with two SHT31 sensors
72-
73- ``` c++
74- #include < Wire.h>
75- #include " SHTSensor.h"
76-
77- // Sensor with normal i2c address
78- // Sensor 1 with address pin pulled to GND
79- SHTSensor sht1 (SHTSensor::SHT3X);
80-
81- // Sensor with alternative i2c address
82- // Sensor 2 with address pin pulled to Vdd
83- SHTSensor sht2(SHTSensor::SHT3X_ALT);
84-
85- void setup() {
86- // put your setup code here, to run once:
87- Wire.begin();
88- Serial.begin(9600);
89- delay(1000); // let serial console settle
90-
91- // init on a specific sensor type (i.e. without auto detecting),
92- // does not check if the sensor is responding and will thus always succeed.
93-
94- // initialize sensor with normal i2c-address
95- sht1.init();
96-
97- // initialize sensor with alternative i2c-address
98- sht2.init();
99- }
100- void loop() {
101- // put your main code here, to run repeatedly:
102- // read from first sensor
103- if (sht1.readSample()) {
104- Serial.print("SHT1 :\n");
105- Serial.print(" RH: ");
106- Serial.print(sht1.getHumidity(), 2);
107- Serial.print("\n");
108- Serial.print(" T: ");
109- Serial.print(sht1.getTemperature(), 2);
110- Serial.print("\n");
111- } else {
112- Serial.print("Sensor 1: Error in readSample()\n");
113- }
114- // read from second sensor
115- if (sht2.readSample()) {
116- Serial.print("SHT2:\n");
117- Serial.print(" RH: ");
118- Serial.print(sht2.getHumidity(), 2);
119- Serial.print("\n");
120- Serial.print(" T: ");
121- Serial.print(sht2.getTemperature(), 2);
122- Serial.print("\n");
123- } else {
124- Serial.print("Sensor 2: Error in readSample()\n");
125- }
126- delay(1000);
127- }
128- ```
46+ See example project
47+ [ multiple-sht-sensors] ( examples/multiple-sht-sensors/multiple-sht-sensors.ino )
0 commit comments