Library for Bosch BMP280 temperature and pressure sensor
Dependents: ELEC350-LCD-DEMO ELEC350-CWTEMPLATE-2017 ELEC351_v1 ELEC350-CWTEMPLATE-2017 ... more
Fork of BMP280 by
Library for Temperature and Pressure Sensor Bosch BMP280.
Breakoutboard for example from Adafruit
Revision 7:c72b726c7dc9, committed 2016-04-19
- Comitter:
- 12104404
- Date:
- Tue Apr 19 02:03:35 2016 +0000
- Parent:
- 6:d03826fe1062
- Child:
- 8:d22ecbef9b90
- Commit message:
- exploded
Changed in this revision
| BMP280.cpp | Show annotated file Show diff for this revision Revisions of this file |
| BMP280.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/BMP280.cpp Wed Apr 13 07:39:05 2016 +0000
+++ b/BMP280.cpp Tue Apr 19 02:03:35 2016 +0000
@@ -1,21 +1,21 @@
/**
- * BME280 Combined humidity and pressure sensor library
+ * BMP280 Combined humidity and pressure sensor library
*
* @author Toyomasa Watarai
* @version 1.0
* @date 06-April-2015
*
- * Library for "BME280 temperature, humidity and pressure sensor module" from Switch Science
+ * Library for "BMP280 temperature, humidity and pressure sensor module" from Switch Science
* https://www.switch-science.com/catalog/2236/
*
- * For more information about the BME280:
- * http://ae-bst.resource.bosch.com/media/products/dokumente/bme280/BST-BME280_DS001-10.pdf
+ * For more information about the BMP280:
+ * http://ae-bst.resource.bosch.com/media/products/dokumente/BMP280/BST-BMP280_DS001-10.pdf
*/
#include "mbed.h"
#include "BMP280.h"
-BME280::BME280(PinName sda, PinName scl, char slave_adr)
+BMP280::BMP280(PinName sda, PinName scl, char slave_adr)
:
i2c_p(new I2C(sda, scl)),
i2c(*i2c_p),
@@ -25,7 +25,7 @@
initialize();
}
-BME280::BME280(I2C &i2c_obj, char slave_adr)
+BMP280::BMP280(I2C &i2c_obj, char slave_adr)
:
i2c_p(NULL),
i2c(i2c_obj),
@@ -35,13 +35,13 @@
initialize();
}
-BME280::~BME280()
+BMP280::~BMP280()
{
if (NULL != i2c_p)
delete i2c_p;
}
-void BME280::initialize()
+void BMP280::initialize()
{
char cmd[18];
@@ -101,7 +101,7 @@
*/
}
-float BME280::getTemperature()
+float BMP280::getTemperature()
{
uint32_t temp_raw;
float tempf;
@@ -126,7 +126,7 @@
return (tempf/100.0f);
}
-float BME280::getPressure()
+float BMP280::getPressure()
{
uint32_t press_raw;
float pressf;
@@ -162,32 +162,4 @@
pressf = (float)press;
return (pressf/100.0f);
-}
-
-/*float BME280::getHumidity()
-{
- uint32_t hum_raw;
- float humf;
- char cmd[4];
-
- cmd[0] = 0xfd; // hum_msb
- i2c.write(address, cmd, 1);
- i2c.read(address, &cmd[1], 2);
-
- hum_raw = (cmd[1] << 8) | cmd[2];
-
- int32_t v_x1;
-
- v_x1 = t_fine - 76800;
- v_x1 = (((((hum_raw << 14) -(((int32_t)dig_H4) << 20) - (((int32_t)dig_H5) * v_x1)) +
- ((int32_t)16384)) >> 15) * (((((((v_x1 * (int32_t)dig_H6) >> 10) *
- (((v_x1 * ((int32_t)dig_H3)) >> 11) + 32768)) >> 10) + 2097152) *
- (int32_t)dig_H2 + 8192) >> 14));
- v_x1 = (v_x1 - (((((v_x1 >> 15) * (v_x1 >> 15)) >> 7) * (int32_t)dig_H1) >> 4));
- v_x1 = (v_x1 < 0 ? 0 : v_x1);
- v_x1 = (v_x1 > 419430400 ? 419430400 : v_x1);
-
- humf = (float)(v_x1 >> 12);
-
- return (humf/1024.0f);
-}*/
+}
\ No newline at end of file
--- a/BMP280.h Wed Apr 13 07:39:05 2016 +0000
+++ b/BMP280.h Tue Apr 19 02:03:35 2016 +0000
@@ -18,7 +18,7 @@
#include "mbed.h"
//#define _DEBUG
-#define DEFAULT_SLAVE_ADDRESS (0x76 << 1)
+#define DEFAULT_SLAVE_ADDRESS (0x77 << 1)
#ifdef _DEBUG
extern Serial pc;
@@ -36,7 +36,7 @@
* @endcode
*/
-class BME280
+class BMP280
{
public:
@@ -47,7 +47,7 @@
* @param scl I2C-bus SCL pin
* @param slave_adr (option) I2C-bus address (default: 0x76)
*/
- BME280(PinName sda, PinName sck, char slave_adr = DEFAULT_SLAVE_ADDRESS);
+ BMP280(PinName sda, PinName sck, char slave_adr = DEFAULT_SLAVE_ADDRESS);
/** Create a BME280 instance
* which is connected to specified I2C pins with specified address
@@ -55,11 +55,11 @@
* @param i2c_obj I2C object (instance)
* @param slave_adr (option) I2C-bus address (default: 0x76)
*/
- BME280(I2C &i2c_obj, char slave_adr = DEFAULT_SLAVE_ADDRESS);
+ BMP280(I2C &i2c_obj, char slave_adr = DEFAULT_SLAVE_ADDRESS);
/** Destructor of BME280
*/
- virtual ~BME280();
+ virtual ~BMP280();
/** Initializa BME280 sensor
*
