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.
Revision 8:4c37112d31cf, committed 2019-01-22
- Comitter:
- kenjiArai
- Date:
- Tue Jan 22 22:18:35 2019 +0000
- Parent:
- 7:d94871acb463
- Commit message:
- address auto selection
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 |
--- a/BME280.cpp Tue Jan 15 10:06:32 2019 +0000
+++ b/BME280.cpp Tue Jan 22 22:18:35 2019 +0000
@@ -74,7 +74,7 @@
id = getID();
if (id != 0x60){
if (address == DEFAULT_SLAVE_ADDRESS){
- address = DEFAULT_SLAVE_ADDRESS;
+ address = ANOTHER_SLAVE_ADDRESS;
} else if (address == ANOTHER_SLAVE_ADDRESS){
address = DEFAULT_SLAVE_ADDRESS;
}
@@ -155,7 +155,7 @@
char cmd[4];
if(check_chip() == false){
- return 100.0f;
+ return -100.0f;
}
cmd[0] = 0xfa; // temp_msb
i2c.write(address, cmd, 1);
@@ -184,7 +184,7 @@
char cmd[4];
if(check_chip() == false){
- return 2000.0f;
+ return 0.0f;
}
cmd[0] = 0xf7; // press_msb
@@ -228,7 +228,7 @@
char cmd[4];
if(check_chip() == false){
- return 0.0f;
+ return 120.0f;
}
cmd[0] = 0xfd; // hum_msb
@@ -276,7 +276,7 @@
id = getID();
if (id != 0x60){
if (address == DEFAULT_SLAVE_ADDRESS){
- address = DEFAULT_SLAVE_ADDRESS;
+ address = ANOTHER_SLAVE_ADDRESS;
} else if (address == ANOTHER_SLAVE_ADDRESS){
address = DEFAULT_SLAVE_ADDRESS;
}
@@ -346,6 +346,13 @@
uint32_t raw_data;
char cmd[8];
+ if(check_chip() == false){
+ // If sensor is error then return abnormal data
+ dt->humidity = 120.0f;
+ dt->temperatue = -100.0f;
+ dt->pressue = 0.0f;
+ return;
+ }
// Humidity
cmd[0] = 0xfd; // hum_msb
i2c.write(address, cmd, 1);
--- a/BME280.h Tue Jan 15 10:06:32 2019 +0000 +++ b/BME280.h Tue Jan 22 22:18:35 2019 +0000 @@ -41,7 +41,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: November 21st, 2018 - * Revised: December 10th, 2018 + * Revised: January 22nd, 2019 * * Refrence software * bme280 library