Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/Continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: LPS22HH Continuous Integration
on:
push:
branches:
- main
paths-ignore:
- '*'
- '**.md'
- '**.txt'
pull_request:
paths-ignore:
- '*'
- '**.md'
- '**.txt'
jobs:
astyle_check:
runs-on: ubuntu-latest
name: AStyle check
steps:
# First of all, clone the repo using the checkout action.
- name: Checkout
uses: actions/checkout@main

- name: Astyle check
id: Astyle
uses: stm32duino/actions/astyle-check@main

# Use the output from the `Astyle` step
- name: Astyle Errors
if: failure()
run: |
cat ${{ steps.Astyle.outputs.astyle-result }}
exit 1
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main

# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
- name: Spell check
uses: codespell-project/actions-codespell@master
with:
check_filenames: true
check_hidden: true
# In the event of a false positive, add the word in all lower case to this file:
ignore_words_file: ./extras/codespell-ignore-words-list.txt
lib_build:
runs-on: ubuntu-latest
name: Library compilation
steps:

# First of all, clone the repo using the checkout action.
- name: Checkout
uses: actions/checkout@main

- name: Compilation
id: compile
uses: stm32duino/actions/compile-examples@main
with:
custom-config: "./extras/build_config.json"
board-pattern: "NUCLEO_L476RG|NUCLEO_H503RB|NUCLEO_C562RE"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# Use the output from the `Compilation` step
- name: Compilation Errors
if: failure()
run: |
cat ${{ steps.compile.outputs.compile-result }}
exit 1
21 changes: 0 additions & 21 deletions .github/workflows/astyle.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/codespell.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/compile-examples.yml

This file was deleted.

21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Arduino library to support the LPS22HH 260-1260 hPa absolute digital output baro

## API

This sensor uses I2C or SPI to communicate.
This sensor uses I2C, I3C or SPI to communicate.
For I2C it is then required to create a TwoWire interface before accessing to the sensors:

TwoWire dev_i2c(I2C_SDA, I2C_SCL);
Expand All @@ -14,6 +14,10 @@ For SPI it is then required to create a SPI interface before accessing to the se
SPIClass dev_spi(SPI_MOSI, SPI_MISO, SPI_SCK);
dev_spi.begin();

For I3C it is then required to create an I3C interface before accessing to the sensors:

I3C.begin(I3C_SDA, I3C_SCL, 1000000U);

An instance can be created and enabled when the I2C bus is used following the procedure below:

LPS22HHSensor PressTemp(&dev_i2c);
Expand All @@ -26,6 +30,15 @@ An instance can be created and enabled when the SPI bus is used following the pr
PressTemp.begin();
PressTemp.Enable();

An instance can be created and enabled when the I3C bus is used with SETDASA (static-to-dynamic address assignment):

LPS22HHSensor PressTemp(&I3C, LPS22HH_I3C_ADD_H);
I3C.resetDynamicAddresses();
I3C.assignDynamicAddress(PressTemp.getStaticAddress(), LPS22HH_DYNAMIC_ADDRESS);
PressTemp.begin(LPS22HH_DYNAMIC_ADDRESS);
I3C.setClock(12500000);
PressTemp.Enable();

The access to the sensor values is done as explained below:

Read pressure and temperature.
Expand All @@ -35,6 +48,12 @@ The access to the sensor values is done as explained below:
PressTemp.GetPressure(&pressure);
PressTemp.GetTemperature(&temperature);

# Examples

There are several examples with the LPS22HH library.
* LPS22HH_DataLog_Terminal_I2C: This application shows how to get pressure and temperature data from the LPS22HH sensor over I2C and print them on terminal.
* LPS22HH_Datalog_Terminal_I3C: This application shows how to use the LPS22HH sensor over I3C using SETDASA.

## Documentation

You can find the source files at
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
@file LPS22HH_Datalog_Terminal_I3C.ino
@author STMicroelectronics
@brief Example to use the LPS22HH pressure sensor with I3C and SETDASA command
*******************************************************************************
Copyright (c) 2026, STMicroelectronics
All rights reserved.

This software component is licensed by ST under BSD 3-Clause license,
the "License"; You may not use this file except in compliance with the
License. You may obtain a copy of the License at:
opensource.org/licenses/BSD-3-Clause

*******************************************************************************
*/
#include "LPS22HHSensor.h"

#define LPS22HH_DYNAMIC_ADDRESS 0x30

LPS22HHSensor sensor(&I3C, LPS22HH_I3C_ADD_H);

void setup()
{
Serial.begin(115200);
while (!Serial) {}
delay(1000);

Serial.println("=== LPS22HH SETDASA ===");

if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

if (!I3C.resetDynamicAddresses()) {
Serial.println("resetDynamicAddresses() failed");
while (1) {}
}

if (!I3C.assignDynamicAddress(sensor.getStaticAddress(), LPS22HH_DYNAMIC_ADDRESS)) {
Serial.println("assignDynamicAddress() failed");
while (1) {}
}

if (sensor.begin(LPS22HH_DYNAMIC_ADDRESS) != LPS22HH_OK) {
Serial.println("sensor.begin() failed");
while (1) {}
}

if (!I3C.setClock(12500000)) {
Serial.println("setClock() failed");
while (1) {}
}

if (sensor.Enable() != LPS22HH_OK) {
Serial.println("sensor.Enable() failed");
while (1) {}
}

Serial.println("LPS22HH ready");
}

void loop()
{
float pressure = 0;
float temperature = 0;

if (sensor.GetPressure(&pressure) == LPS22HH_OK && sensor.GetTemperature(&temperature) == LPS22HH_OK) {
Serial.print("Pres[hPa]:");
Serial.print(pressure, 2);
Serial.print(",Temp[C]:");
Serial.println(temperature, 2);
} else {
Serial.println("Read failed");
}

delay(500);
}
26 changes: 26 additions & 0 deletions extras/build_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"cores": [
{
"maintainer": "STMicroelectronics",
"architecture": "stm32",
"boards": [
],
"sketches": [
{
"pattern": "[^I][^3][^C]",
"applicable": true,
"boards": [
"NUCLEO_L476RG",
"NUCLEO_H503RB",
"NUCLEO_C562RE"
]
},
{
"pattern": "I3C",
"applicable": true,
"boards": [ "NUCLEO_H503RB","NUCLEO_C562RE"]
}
]
}
]
}
2 changes: 2 additions & 0 deletions extras/codespell-ignore-words-list.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
daa
ois
pres
ths
11 changes: 10 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#######################################

LPS22HHSensor KEYWORD1
LPS22HHStatusTypeDef KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
Expand All @@ -15,6 +16,8 @@ LPS22HHSensor KEYWORD1
begin KEYWORD2
end KEYWORD2
ReadID KEYWORD2
getStaticAddress KEYWORD2
getDynAddress KEYWORD2
Enable KEYWORD2
Disable KEYWORD2
GetOutputDataRate KEYWORD2
Expand Down Expand Up @@ -43,4 +46,10 @@ Get_One_Shot_Status KEYWORD2
#######################################

LPS22HH_OK LITERAL1
LPS22HH_ERROR LITERAL1
LPS22HH_ERROR LITERAL1
LPS22HH_I2C_BUS LITERAL1
LPS22HH_SPI_4WIRES_BUS LITERAL1
LPS22HH_SPI_3WIRES_BUS LITERAL1
LPS22HH_I3C_BUS LITERAL1
LPS22HH_I3C_ADD_L LITERAL1
LPS22HH_I3C_ADD_H LITERAL1
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=STM32duino LPS22HH
version=2.0.4
version=2.1.0
author=SRA
maintainer=stm32duino
sentence=Nano pressure sensor.
Expand Down
Loading
Loading