-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimal code to use the SHT31 with NINA
Based on Sensirion SHT examples
- Loading branch information
1 parent
17f0b4d
commit c3b86e6
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <Wire.h> | ||
|
||
#include "SHTSensor.h" | ||
|
||
SHTSensor sht; | ||
// To use a specific sensor instead of probing the bus use this command: | ||
// SHTSensor sht(SHTSensor::SHT3X); | ||
|
||
void setup() { | ||
// put your setup code here, to run once: | ||
|
||
Wire.begin(); | ||
Serial.begin(115200); | ||
delay(1000); // let serial console settle | ||
|
||
if (sht.init()) { | ||
Serial.print("init(): success\n"); | ||
} else { | ||
Serial.print("init(): failed\n"); | ||
} | ||
sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x | ||
|
||
} | ||
|
||
void loop() { | ||
// put your main code here, to run repeatedly: | ||
|
||
if (sht.readSample()) { | ||
Serial.print("SHT:\n"); | ||
Serial.print(" RH: "); | ||
Serial.print(sht.getHumidity(), 2); | ||
Serial.print("\n"); | ||
Serial.print(" T: "); | ||
Serial.print(sht.getTemperature(), 2); | ||
Serial.print("\n"); | ||
} else { | ||
Serial.print("Error in readSample()\n"); | ||
} | ||
|
||
delay(1000); | ||
} |