BME280 Combined humidity and pressure sensor library

Dependents:   mDot_TTN_OTAA_Node LoraGPSLogger mDot_TTN_OTAA_Node_send_data_as_string

Fork of BME280 by Toyomasa Watarai

Revision:
6:6a7fa855c18c
Parent:
5:64b7a81c61e4
diff -r 64b7a81c61e4 -r 6a7fa855c18c BME280.cpp
--- a/BME280.cpp	Wed May 11 06:17:58 2016 +0000
+++ b/BME280.cpp	Wed Dec 14 11:13:38 2016 +0000
@@ -15,8 +15,8 @@
 #include "mbed.h"
 #include "BME280.h"
 
-BME280::BME280(PinName sda, PinName scl, char slave_adr)
-    :
+
+BME280::BME280(PinName sda, PinName scl, char slave_adr) :
     i2c_p(new I2C(sda, scl)), 
     i2c(*i2c_p),
     address(slave_adr),
@@ -25,8 +25,7 @@
     initialize();
 }
 
-BME280::BME280(I2C &i2c_obj, char slave_adr)
-    :
+BME280::BME280(I2C &i2c_obj, char slave_adr) :
     i2c_p(NULL), 
     i2c(i2c_obj),
     address(slave_adr),
@@ -99,6 +98,16 @@
  
     DEBUG_PRINT("dig_H = 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dig_H1, dig_H2, dig_H3, dig_H4, dig_H5, dig_H6);
 }
+
+bool BME280::deviceExists() {
+    char cmd[4];
+ 
+    cmd[0] = 0xd0; // device ID
+    i2c.write(address, cmd, 1);
+    i2c.read(address, &cmd[1], 1);
+
+    return ( cmd[1] == 0x60 );
+}
  
 float BME280::getTemperature()
 {