nodemcu-firmware/docs/en/modules/bmp085.md

92 lines
2.2 KiB
Markdown
Raw Normal View History

2016-01-14 22:15:09 +01:00
# BMP085 Module
| Since | Origin / Contributor | Maintainer | Source |
| :----- | :-------------------- | :---------- | :------ |
| 2015-08-03 | [Konrad Beckmann](https://github.com/kbeckmann) | [Konrad Beckmann](https://github.com/kbeckmann) | [bmp085.c](../../../app/modules/bmp085.c)|
2016-01-14 22:15:09 +01:00
2016-01-14 22:46:12 +01:00
This module provides access to the [BMP085](https://www.sparkfun.com/tutorials/253) temperature and pressure sensor. The module also works with BMP180.
2016-01-14 22:15:09 +01:00
## bmp085.init()
Initializes the module and sets the pin configuration.
!!! attention
This function is deprecated and will be removed in upcoming releases. Use `bmp085.setup()` instead.
2016-01-14 22:15:09 +01:00
#### Syntax
`bmp085.init(sda, scl)`
#### Parameters
- `sda` data pin
- `scl` clock pin
#### Returns
`nil`
## bmp085.setup()
Initializes the module.
#### Syntax
`bmp085.setup()`
#### Parameters
None
#### Returns
`nil`
2016-01-14 22:15:09 +01:00
## bmp085.temperature()
Samples the sensor and returns the temperature in celsius as an integer multiplied with 10.
#### Syntax
`bmp085.temperature()`
#### Returns
2016-01-14 22:46:12 +01:00
temperature multiplied with 10 (integer)
2016-01-14 22:15:09 +01:00
#### Example
```lua
local sda, scl = 1, 2
i2c.setup(0, sda, scl, i2c.SLOW)
bmp085.setup()
2016-01-14 22:15:09 +01:00
local t = bmp085.temperature()
print(string.format("Temperature: %s.%s degrees C", t / 10, t % 10))
```
## bmp085.pressure()
Samples the sensor and returns the pressure in pascal as an integer.
The optional `oversampling_setting` parameter determines for how long time the sensor samples data.
The default is `3` which is the longest sampling setting. Possible values are 0, 1, 2, 3.
See the data sheet for more information.
#### Syntax
`bmp085.pressure(oversampling_setting)`
#### Parameters
2016-01-14 22:46:12 +01:00
`oversampling_setting` integer that can be 0, 1, 2 or 3
2016-01-14 22:15:09 +01:00
#### Returns
2016-01-14 22:46:12 +01:00
pressure in pascals (integer)
2016-01-14 22:15:09 +01:00
#### Example
```lua
local sda, scl = 1, 2
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
bmp085.setup()
2016-01-14 22:15:09 +01:00
local p = bmp085.pressure()
print(string.format("Pressure: %s.%s mbar", p / 100, p % 100))
```
## bmp085.pressure_raw()
Samples the sensor and returns the raw pressure in internal units. Might be useful if you need higher precision.
#### Syntax
`bmp085.pressure_raw(oversampling_setting)`
#### Parameters
2016-01-14 22:46:12 +01:00
`oversampling_setting` integer that can be 0, 1, 2 or 3
2016-01-14 22:15:09 +01:00
#### Returns
2016-01-14 22:46:12 +01:00
raw pressure sampling value (integer)