Skip to content

Commit c9767df

Browse files
authored
Merge pull request #1 from cparata/master
Add code for LPS25HB and example for X-NUCLEO-IKS01A1
2 parents 4551a41 + c869abc commit c9767df

File tree

8 files changed

+3206
-1
lines changed

8 files changed

+3206
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
11
# LPS25HB
2-
Arduino library to support the LPS25HB 260-1260 hPa absolute digital ouput barometer
2+
Arduino library to support the LPS25HB 260-1260 hPa absolute digital output barometer
3+
4+
## API
5+
6+
This sensor uses I2C to communicate. It is then required to create a TwoWire interface before accessing to the sensors:
7+
8+
dev_i2c = new TwoWire(I2C2_SDA, I2C2_SCL);
9+
dev_i2c->begin();
10+
11+
An instance can be created and enbaled following the procedure below:
12+
13+
PressTemp = new LPS25HBSensor(dev_i2c);
14+
PressTemp->Enable();
15+
16+
The access to the sensor values is done as explained below:
17+
18+
Read pressure and temperature.
19+
20+
PressTemp->GetPressure(&pressure);
21+
PressTemp->GetTemperature(&temperature);
22+
23+
## Documentation
24+
25+
You can find the source files at
26+
https://github.com/stm32duino/LPS25HB
27+
28+
The LPS25HB datasheet is available at
29+
http://www.st.com/content/st_com/en/products/mems-and-sensors/pressure-sensors/lps25hb.html
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
******************************************************************************
3+
* @file X_NUCLEO_IKS01A1_LPS25HB_DataLog_Terminal.ino
4+
* @author AST
5+
* @version V1.0.0
6+
* @date 7 September 2017
7+
* @brief Arduino test application for the STMicrolectronics X-NUCLEO-IKS01A2
8+
* MEMS Inertial and Environmental sensor expansion board.
9+
* This application makes use of C++ classes obtained from the C
10+
* components' drivers.
11+
******************************************************************************
12+
* @attention
13+
*
14+
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
15+
*
16+
* Redistribution and use in source and binary forms, with or without modification,
17+
* are permitted provided that the following conditions are met:
18+
* 1. Redistributions of source code must retain the above copyright notice,
19+
* this list of conditions and the following disclaimer.
20+
* 2. Redistributions in binary form must reproduce the above copyright notice,
21+
* this list of conditions and the following disclaimer in the documentation
22+
* and/or other materials provided with the distribution.
23+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
24+
* may be used to endorse or promote products derived from this software
25+
* without specific prior written permission.
26+
*
27+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*
38+
******************************************************************************
39+
*/
40+
41+
42+
// Includes.
43+
#include <LPS25HBSensor.h>
44+
45+
#if defined(ARDUINO_SAM_DUE)
46+
#define DEV_I2C Wire1 //Define which I2C bus is used. Wire1 for the Arduino Due
47+
#define SerialPort Serial
48+
#else
49+
#define DEV_I2C Wire //Or Wire
50+
#define SerialPort Serial
51+
#endif
52+
53+
// Components.
54+
LPS25HBSensor *PressTemp;
55+
56+
void setup() {
57+
// Led.
58+
pinMode(13, OUTPUT);
59+
60+
// Initialize serial for output.
61+
SerialPort.begin(9600);
62+
63+
// Initialize I2C bus.
64+
DEV_I2C.begin();
65+
66+
// Initlialize components.
67+
PressTemp = new LPS25HBSensor (&DEV_I2C);
68+
PressTemp->Enable();
69+
}
70+
71+
void loop() {
72+
// Led blinking.
73+
digitalWrite(13, HIGH);
74+
delay(250);
75+
digitalWrite(13, LOW);
76+
delay(250);
77+
78+
// Read pressure and temperature.
79+
float pressure, temperature;
80+
PressTemp->GetPressure(&pressure);
81+
PressTemp->GetTemperature(&temperature);
82+
83+
// Output data.
84+
SerialPort.print("| Pres[hPa]: ");
85+
SerialPort.print(pressure, 2);
86+
SerialPort.print(" | Temp[C]: ");
87+
SerialPort.print(temperature, 2);
88+
SerialPort.println(" |");
89+
}

keywords.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#######################################
2+
# Syntax Coloring Map For LPS25HB
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
LPS25HBSensor KEYWORD1 LPS25HBSensor
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
Enable KEYWORD2
16+
Disable KEYWORD2
17+
ReadID KEYWORD2
18+
Reset KEYWORD2
19+
GetTemperature KEYWORD2
20+
GetODR KEYWORD2
21+
SetODR KEYWORD2
22+
ReadReg KEYWORD2
23+
WriteReg KEYWORD2
24+
IO_Read KEYWORD2
25+
IO_Write KEYWORD2
26+
GetPressure KEYWORD2
27+
28+
29+
#######################################
30+
# Constants (LITERAL1)
31+
#######################################

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=LPS25HB
2+
version=1.0
3+
author=AST
4+
maintainer=stm32duino
5+
sentence=260-1260 hPa absolute digital output barometer.
6+
paragraph=This library provides Arduino support for the 260-1260 hPa absolute digital output barometer LPS25HB for STM32 boards.
7+
category=Sensors
8+
url=https://github.com/stm32duino/LPS25HB
9+
architectures=stm32

0 commit comments

Comments
 (0)