Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BME280 by
Diff: BME280.cpp
- Revision:
- 5:3eb4c6c38dc4
- Parent:
- 4:ddcaa259e65b
- Child:
- 6:2f87adc3e6b7
diff -r ddcaa259e65b -r 3eb4c6c38dc4 BME280.cpp
--- a/BME280.cpp Tue May 12 13:32:09 2015 +0000
+++ b/BME280.cpp Fri Dec 30 03:13:46 2016 +0000
@@ -107,9 +107,12 @@
char cmd[4];
cmd[0] = 0xfa; // temp_msb
- i2c.write(address, cmd, 1);
- i2c.read(address, &cmd[1], 3);
-
+ int writeResult = i2c.write(address, cmd, 1);
+ int readResult = i2c.read(address, &cmd[1], 3);
+
+ if(writeResult != 0 || readResult != 0)
+ return -10000000;
+
temp_raw = (cmd[1] << 12) | (cmd[2] << 4) | (cmd[3] >> 4);
int32_t temp;
@@ -132,8 +135,11 @@
char cmd[4];
cmd[0] = 0xf7; // press_msb
- i2c.write(address, cmd, 1);
- i2c.read(address, &cmd[1], 3);
+ int writeResult = i2c.write(address, cmd, 1);
+ int readResult = i2c.read(address, &cmd[1], 3);
+
+ if(writeResult != 0 || readResult != 0)
+ return -10000000;
press_raw = (cmd[1] << 12) | (cmd[2] << 4) | (cmd[3] >> 4);
@@ -170,8 +176,11 @@
char cmd[4];
cmd[0] = 0xfd; // hum_msb
- i2c.write(address, cmd, 1);
- i2c.read(address, &cmd[1], 2);
+ int writeResult = i2c.write(address, cmd, 1);
+ int readResult = i2c.read(address, &cmd[1], 2);
+
+ if(writeResult != 0 || readResult != 0)
+ return -10000000;
hum_raw = (cmd[1] << 8) | cmd[2];
