for STM32L476RG

Fork of BME280 by Toyomasa Watarai

Files at this revision

API Documentation at this revision

Comitter:
Allar
Date:
Thu Jun 01 08:04:13 2017 +0000
Parent:
5:c1f1647004c4
Commit message:
night;

Changed in this revision

BME280.cpp Show annotated file Show diff for this revision Revisions of this file
BME280.h Show annotated file Show diff for this revision Revisions of this file
diff -r c1f1647004c4 -r a9bb4ca073b2 BME280.cpp
--- a/BME280.cpp	Sat Mar 11 04:21:14 2017 +0000
+++ b/BME280.cpp	Thu Jun 01 08:04:13 2017 +0000
@@ -55,7 +55,17 @@
     if (NULL != i2c_p)
         delete  i2c_p;
 }
-    
+bool BME280::verifyConnection(void) {
+    char cmd[1];
+    cmd[0] = 0xD0; //ID
+    i2c.write(address, cmd, 1);
+    i2c.read(address, cmd, 1);
+    uint8_t part_id = cmd[0];//ID
+    if (part_id == 0x60)
+        return true;
+    return false;
+}
+
 void BME280::initialize()
 {
     char cmd[18];
diff -r c1f1647004c4 -r a9bb4ca073b2 BME280.h
--- a/BME280.h	Sat Mar 11 04:21:14 2017 +0000
+++ b/BME280.h	Thu Jun 01 08:04:13 2017 +0000
@@ -111,6 +111,7 @@
      */
     void initialize(void);
 
+    bool verifyConnection(void);
     /** Read the current temperature value (degree Celsius) from BME280 sensor
      *
      */