This is the LPS22HH a High-performance MEMS (Microelectromechanical ) nano pressure sensor that ranges to 260 – 1260 hPa (Hectopascal) an absolute digital output barometer that communicates through 3 protocols i2C, i3C, and SPI. from sensing elements, which detects an absolute pressure that consists of a suspended membrane design for dedicated approach. The LPS22H was developed by STMicroelectronics and can operate at a temperature level of -40 degrees to +85 degrees suited for the harsh environment. These LPS22HH are suitable for numerous applications such as weather types of equipment, or perhaps weather station devices, GPS Devices, Wearable devices, Drones, Gas metering, or altimeters and barometers for portable devices. For more technical details and specifications such as communicating with SPI or i3C refer to the datasheet below. Moreover, our source code below demonstrates using the i2C protocol and some minimal wiring requirements.
Testing Requirements
- Arduino IDE | PlatformIO
- Test Boards :
- Note: The Diagram below is using Raspberry Pi – PICO (please refer to your MCU’s respective pin-outs & bus configuration)
- Resistors (See below diagram for required value)
- Capacitor(See below diagram for required value)
Wiring Guide
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
#include <LPS22HHSensor.h> //This library can be downloaded below.. #ifndef LED_BUILTIN #define LED_BUILTIN PNUM_NOT_DEFINED #warning "LED_BUILTIN is not defined." #endif #define SerialPort Serial #if defined(ARDUINO_B_L4S5I_IOT01A) || defined(ARDUINO_B_U585I_IOT02A) #define USE_I2C_INTERFACE #else // Uncomment one communication interface to use: // X_NUCLEO_IKS01A3 uses I2C interface (set by default) // #define USE_SPI_INTERFACE #define USE_I2C_INTERFACE #endif #if !defined(USE_SPI_INTERFACE) && !defined(USE_I2C_INTERFACE) || \ defined(USE_SPI_INTERFACE) && defined(USE_I2C_INTERFACE) #error "Uncomment one communication interface to use!" #endif #ifdef USE_SPI_INTERFACE // Uncomment to set SPI pins to use else default instance will be used // #define LPS22HH_SPI_MOSI PB10 // #define LPS22HH_SPI_MISO PB11 // #define LPS22HH_SPI_SCLK PB11 // Define Software Chip Select pin to use (default: SS) #define LPS22HH_SPI_SSEL SS #if defined(LPS22HH_SPI_MOSI) && defined(LPS22HH_SPI_MISO) && \ defined(LPS22HH_SPI_SCLK) && defined(LPS22HH_SPI_SSEL) SPIClass dev_interface(LPS22HH_SPI_MOSI, LPS22HH_SPI_MISO, LPS22HH_SPI_SCLK); #else #define dev_interface SPI #endif LPS22HHSensor PressTemp(&dev_interface, LPS22HH_SPI_SSEL); #else // USE_I2C_INTERFACE #if defined(ARDUINO_B_L4S5I_IOT01A) #define LPS22HH_I2C_SCL PB10 #define LPS22HH_I2C_SDA PB11 #elif defined(ARDUINO_B_U585I_IOT02A) #define LPS22HH_I2C_SCL PH4 #define LPS22HH_I2C_SDA PH5 #else // Uncomment to set I2C pins to use else default instance will be used // #define LPS22HH_I2C_SCL PYn // #define LPS22HH_I2C_SDA PYn #endif #if defined(LPS22HH_I2C_SCL) && defined(LPS22HH_I2C_SDA) TwoWire dev_interface(LPS22HH_I2C_SDA, LPS22HH_I2C_SCL); #else // X_NUCLEO_IKS01A3 uses default instance #define dev_interface Wire #endif LPS22HHSensor PressTemp(&dev_interface); #endif void setup() { // Led pinMode(LED_BUILTIN, OUTPUT); // Initialize serial for output SerialPort.begin(9600); // Initialize bus interface dev_interface.begin(); // Initlialize component serial.print("14CORE | Initializing..... ");) delay(1000); SerialPort.print("Starting ... "); PressTemp.begin(); PressTemp.Enable(); } void loop() { // Led blinking digitalWrite(LED_BUILTIN, HIGH); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(250); // Read pressure float pressure, temperature; PressTemp.GetPressure(&pressure); PressTemp.GetTemperature(&temperature); SerialPort.print("Pressure in pascal - [hPa]:"); SerialPort.print(pressure, 2); SerialPort.print(", Temperature [C]: "); SerialPort.println(temperature, 2); } |