working with mbed os 5.5
Dependents: Mbed-Connect-Cloud-Demo Mbed-Connect-Cloud-Demo mbed-cloud-connect-sensor-laser-distance2 mbed-cloud-connect-sensor-laser-distance2 ... more
Fork of Sht31 by
Diff: Sht31.cpp
- Revision:
- 1:756e26f0b067
- Parent:
- 0:c90aa4f69539
- Child:
- 2:c84a60326ecf
diff -r c90aa4f69539 -r 756e26f0b067 Sht31.cpp
--- a/Sht31.cpp Wed Jul 20 16:51:28 2016 +0000
+++ b/Sht31.cpp Thu Jul 21 15:31:08 2016 +0000
@@ -19,7 +19,7 @@
Sht31::Sht31(PinName sda, PinName scl) : _i2c(sda, scl) {
_i2caddr = 0x44;
- printf("\r\n");
+ printf("\r\n");
reset();
readStatus();
}
@@ -35,9 +35,7 @@
}
void Sht31::reset(void) {
- _i2c.start();
- _i2c.write(SHT31_SOFTRESET);
- _i2c.stop();
+ writeCommand(SHT31_SOFTRESET);
wait_ms(10);
}
@@ -66,7 +64,6 @@
_i2c.stop();
}
-
bool Sht31::readTempHum(void) {
char readbuffer[6];
@@ -76,9 +73,9 @@
_i2c.start();
_i2c.read(_i2caddr, readbuffer, 6);
_i2c.stop();
- for (uint8_t i = 0; i < 6; i++) {
- printf("0x%Xd\r\n", readbuffer[i]);
- }
+ for (uint8_t i = 0; i < 6; i++) {
+ printf("0x%Xd\r\n", readbuffer[i]);
+ }
uint16_t ST, SRH;
ST = readbuffer[0];
ST <<= 8;
Andrea Corrado

SHT31-D Temperature & Humidity Sensor