GY-63_MS5611/libraries/SHT31/examples/SHT31_demo/SHT31_demo.ino
2021-05-28 13:45:10 +02:00

53 lines
890 B
C++

//
// FILE: SHT31_demo.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.0.2
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT31
#include "Wire.h"
#include "SHT31.h"
#define SHT31_ADDRESS 0x44
uint32_t start;
uint32_t stop;
SHT31 sht;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("SHT31_LIB_VERSION: \t");
Serial.println(SHT31_LIB_VERSION);
Wire.begin();
sht.begin(SHT31_ADDRESS);
Wire.setClock(100000);
uint16_t stat = sht.readStatus();
Serial.print(stat, HEX);
Serial.println();
}
void loop()
{
start = micros();
sht.read(); // default = true/fast slow = false
stop = micros();
Serial.print("\t");
Serial.print(stop - start);
Serial.print("\t");
Serial.print(sht.getTemperature(), 1);
Serial.print("\t");
Serial.println(sht.getHumidity(), 1);
delay(100);
}
// -- END OF FILE --