barometric pressure sensor BMP085 - デジタル気圧センサー
.
barometric pressure sensor BMP085
デジタル気圧センサー BMP085 (Bosch Sensortec) を I2C で接続します。
Weatherduinoのプログラムを流用し、I2Cの部分をmbed用に書き換えました。
Schematic
blockdiagram
+--------+ | |3.3V---+-+--+ | | | | | BMP085 | | R R | +------+ | | | | +---VDD|3,4 | | mbed |SCK----+-|------SCK|6 8|XCLR | |SDA------+------SDA|7 | | | +---GND|1 2|EOC | | | +------+ | | | | |GND---------+ R=2.2kΩ x 2 +--------+
Library
Import libraryBMP085
barometric pressure sensor BMP085 http://mbed.org/users/okini3939/notebook/barometric-pressure-sensor-bmp085/ http://mbed.org/users/okini3939/notebook/weatherduino-on-mbed/
Import library
Public Member Functions |
|
BMP085 (PinName p_sda, PinName p_scl, BMP085_oss p_oss=BMP085_oss1) | |
Initializes interface (private I2C)
|
|
BMP085 (I2C &p_i2c, BMP085_oss p_oss=BMP085_oss1) | |
Initializes interface (public I2C)
|
|
float | get_temperature () |
Get temperature.
|
|
float | get_pressure () |
Get pressure.
|
|
void | update () |
Update results.
|
Sample
#include "mbed.h" #include "BMP085.h" BMP085 bmp085(p9, p10); DigitalOut myled(LED1); Serial pc(USBTX, USBRX); int main() { float p, t; while(1) { myled = 1; bmp085.update(); p = bmp085.get_pressure(); t = bmp085.get_temperature(); pc.printf("p:%6.2f hPa / t:%6.2f C\n", p, t); myled = 0; wait(3); } }
Import programbmp085_lib
barometric pressure sensor BMP085 http://mbed.org/users/okini3939/notebook/barometric-pressure-sensor-bmp085/ http://mbed.org/users/okini3939/notebook/weatherduino-on-mbed/
I2Cを他と共用する場合
: I2C i2c(p9, p10); BMP085 bmp085(i2c); :
サンプリング回数を指定する場合
BMP085_oss1,2,4,8
: BMP085 bmp085(p9, p10, BMP085_oss4); or BMP085 bmp085(i2c, BMP085_oss4); :
2 comments on barometric pressure sensor BMP085 - デジタル気圧センサー:
Please log in to post comments.
Tested it... works great!!! Thanks.