Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
96585a57
Commit
96585a57
authored
Jan 14, 2016
by
Arnim Läuger
Browse files
Merge pull request #936 from kbeckmann/bmp085-docs
parents
517faf44
d426976e
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/bmp085.c
View file @
96585a57
...
@@ -74,7 +74,7 @@ static int ICACHE_FLASH_ATTR bmp085_init(lua_State* L) {
...
@@ -74,7 +74,7 @@ static int ICACHE_FLASH_ATTR bmp085_init(lua_State* L) {
bmp085_data
.
MC
=
r16
(
bmp085_i2c_id
,
0xBC
);
bmp085_data
.
MC
=
r16
(
bmp085_i2c_id
,
0xBC
);
bmp085_data
.
MD
=
r16
(
bmp085_i2c_id
,
0xBE
);
bmp085_data
.
MD
=
r16
(
bmp085_i2c_id
,
0xBE
);
return
1
;
return
0
;
}
}
static
uint32_t
bmp085_temperature_raw_b5
(
void
)
{
static
uint32_t
bmp085_temperature_raw_b5
(
void
)
{
...
@@ -128,7 +128,7 @@ static int32_t ICACHE_FLASH_ATTR bmp085_pressure_raw(int oss) {
...
@@ -128,7 +128,7 @@ static int32_t ICACHE_FLASH_ATTR bmp085_pressure_raw(int oss) {
p3
=
r8u
(
bmp085_i2c_id
,
0xF8
);
p3
=
r8u
(
bmp085_i2c_id
,
0xF8
);
p
=
(
p1
<<
16
)
|
(
p2
<<
8
)
|
p3
;
p
=
(
p1
<<
16
)
|
(
p2
<<
8
)
|
p3
;
p
=
p
>>
(
8
-
oss
);
p
=
p
>>
(
8
-
oss
);
return
p
;
return
p
;
}
}
...
@@ -159,7 +159,7 @@ static int ICACHE_FLASH_ATTR bmp085_lua_pressure(lua_State* L) {
...
@@ -159,7 +159,7 @@ static int ICACHE_FLASH_ATTR bmp085_lua_pressure(lua_State* L) {
oss
=
3
;
oss
=
3
;
}
}
}
}
p
=
bmp085_pressure_raw
(
oss
);
p
=
bmp085_pressure_raw
(
oss
);
B5
=
bmp085_temperature_raw_b5
();
B5
=
bmp085_temperature_raw_b5
();
...
...
docs/en/modules/bmp085.md
0 → 100644
View file @
96585a57
# BMP085 Module
This module provides access to the BMP085 temperature and pressure sensor. The module also works with BMP180.
## bmp085.init()
Initializes the module and sets the pin configuration.
#### Syntax
`bmp085.init(sda, scl)`
#### Parameters
-
`sda`
data pin
-
`scl`
clock pin
#### Returns
`nil`
## bmp085.temperature()
Samples the sensor and returns the temperature in celsius as an integer multiplied with 10.
#### Syntax
`bmp085.temperature()`
#### Returns
`integer`
temperature multiplied with 10.
#### Example
```
lua
bmp085
.
init
(
1
,
2
)
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
-
`oversampling_setting`
integer that can be 0, 1, 2 or 3.
#### Returns
`integer`
pressure in pascals.
#### Example
```
lua
bmp085
.
init
(
1
,
2
)
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
-
`oversampling_setting`
integer that can be 0, 1, 2 or 3.
#### Returns
`integer`
raw pressure sampling value
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment