MBed 5 version of BME280 test verify a BME280 can be reset via the I2C Bus

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Roietronics
Date:
Fri Apr 14 02:03:45 2017 +0000
Commit message:
Update to MBED OS 5.4

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 8ffd97155ff2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 14 02:03:45 2017 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+
+I2C i2c(I2C_SDA , I2C_SCL ); 
+Serial debug(USBTX, USBRX);
+
+int main() {
+    char buffer[2];
+    buffer[1] = 0xE0;
+    buffer[0] = 0x86;
+    int count = 2;
+    int address = 0x77;
+    int error;
+ //   int i2c_frequency = 200 * 1000;
+    int i2c_frequency = 100 * 1000;
+    debug.printf("\nI2C BME280 Rest Test");
+
+    i2c.frequency(i2c_frequency);
+
+    i2c.start();
+    error = i2c.write(address << 1); //We shift it left because mbed takes in 8 bit addreses
+    i2c.stop();
+    if (error == 1)
+    {
+      debug.printf("\nI2C device found at address 0x%X", address);
+    }
+    else
+    {
+        debug.printf("\nDevice at IC address Ox%X, not responding", address);
+    }
+    
+    i2c.start();
+    error = i2c.write(address << 1, buffer, count); //We shift it left because mbed takes in 8 bit addreses
+    i2c.stop();
+    if (error == 1)
+    {
+      debug.printf("\nBME280 reset request send success");
+    }
+    else
+    {
+        debug.printf("\nBME280 reset request send failed Error Code: %d", error);
+    }
+    debug.printf("\ndone\n");
+}
diff -r 000000000000 -r 8ffd97155ff2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 14 02:03:45 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file