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 Robert Taylor

Revision:
2:c84a60326ecf
Parent:
1:756e26f0b067
--- a/Sht31.cpp	Thu Jul 21 15:31:08 2016 +0000
+++ b/Sht31.cpp	Mon Sep 11 13:51:03 2017 +0000
@@ -18,8 +18,7 @@
 #include "mbed.h"
 
 Sht31::Sht31(PinName sda, PinName scl) : _i2c(sda, scl) {
-    _i2caddr = 0x44;
-    printf("\r\n");
+    _i2caddr = (0x44 << 1);
     reset();
     readStatus();
 }
@@ -42,26 +41,20 @@
 uint16_t Sht31::readStatus(void) {
     writeCommand(SHT31_READSTATUS);
     char val[1];
-    _i2c.start();
     _i2c.read(_i2caddr, val, 1);
-    _i2c.stop();
     uint16_t stat = val[0];
     stat <<= 8;
-    _i2c.start();
     _i2c.read(_i2caddr, val, 1);
-    _i2c.stop();
     stat |= val[0];
-    printf("0x%X\r\n", stat);
+    // printf("0x%X\r\n", stat);
     return stat;
 }
 
 void Sht31::writeCommand(uint16_t cmd) {
     char buf[2];
-    _i2c.start();
     buf[0] = (cmd >> 8);
     buf[1] = (cmd & 0xFF);
     _i2c.write(_i2caddr, buf, 2);
-    _i2c.stop();
 }
 
 bool Sht31::readTempHum(void) {
@@ -70,12 +63,8 @@
     writeCommand(SHT31_MEAS_HIGHREP);
 
     wait_ms(500);
-    _i2c.start();
     _i2c.read(_i2caddr, readbuffer, 6);
-    _i2c.stop();
-    for (uint8_t i = 0; i < 6; i++) {
-        printf("0x%Xd\r\n", readbuffer[i]);
-    }
+    
     uint16_t ST, SRH;
     ST = readbuffer[0];
     ST <<= 8;
@@ -93,14 +82,12 @@
         return false;
     }
 
-    printf("ST = %d\r\n", ST);
     double stemp = ST;
     stemp *= 175;
     stemp /= 0xffff;
     stemp = -45 + stemp;
     temp = stemp;
 
-    printf("SRH = %d\r\n", SRH);
     double shum = SRH;
     shum *= 100;
     shum /= 0xFFFF;