GY-63_MS5611/libraries/SHT2x/examples/SHT2x_I2Cspeed/SHT2x_I2Cspeed.ino

60 lines
951 B
Arduino
Raw Normal View History

2021-09-27 14:51:23 -04:00
//
// FILE: SHT2x_I2Cspeed
// AUTHOR: Rob Tillaart
// PURPOSE: testing the performance at different I2C speeds
// URL: https://github.com/RobTillaart/SHT2x
#include "Wire.h"
#include "SHT2x.h"
uint32_t start;
uint32_t stop;
SHT2x sht;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("SHT2x_LIB_VERSION: \t");
Serial.println(SHT2x_LIB_VERSION);
sht.begin();
uint8_t stat = sht.getStatus();
Serial.print(stat, HEX);
Serial.println();
}
void loop()
{
for (uint32_t I2Cfreq = 100000; I2Cfreq < 600000; I2Cfreq += 50000)
{
2021-09-29 07:21:17 -04:00
Serial.print(I2Cfreq / 1000);
2021-09-27 14:51:23 -04:00
Wire.setClock(I2Cfreq);
test();
}
}
void test()
{
start = micros();
sht.read();
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(1000);
}
// -- END OF FILE --
2021-12-28 06:13:24 -05:00