Explore the world of barometers and their essential role in predicting weather, enabling you to make informed decisions about your outdoor plans
A
A
Hardware Overview
How does it work?
Barometer 2 Click is based on the LPS35HW, an absolute digital output barometer IC in water-resistant package from STMicroelectronics. It can be used to measure absolute pressure values from 260 - 1260hPa. The sensor can be exposed up to 2MPa of pressure peaks, without causing any permanent damage. However, prolonged exposure to such high pressure can affect the reliability and accuracy of the sensor. The LPS35HW IC comprises a piezoresistive MEMS and an ASIC. The MEMS consists of a suspended membrane manufactured using a proprietary technology, developed by ST. The piezoresistive elements on the membrane form a Wheatstone bridge. By applying a pressure, the balance of the bridge is disturbed, which causes a proportional voltage to appear on its output. The output of the Wheatstone bridge is then processed by the ASIC, which outputs conditioned and factory-calibrated data over the I2C interface, in 24-bit, two’s complement format. Barometer 2 click supports the I2C communication interface, allowing it to be used with a wide range of different MCUs. The
slave I2C address can be configured by an SMD jumper, labeled as ADD SEL. An SMD jumper is used to set the least significant bit (LSB) of the I2C address. When set to 1, the 7-bit I2C slave address becomes 0b1011101x. If set to 0, the address becomes 0b1011100x. The last digit (x) is the R/W bit. One of distinctive features of the LPS35HW is a highly configurable FIFO buffer, with 32 slots of 40-bit data, allowing to buffer both pressure and temperature readings. The FIFO buffer can be configured to work in one of several available modes, offering a great flexibility. Along with the extensive interrupt engine which can signal several FIFO-related events over a dedicated INT_DRDY pin, the FIFO buffer can be very useful for writing an optimized MCU firmware. Besides FIFO-related events, the extensive interrupt engine of the LPS35HW IC can be configured to signal several other events over a dedicated INT_DRDY pin, including events when a programmable low or high threshold level is exceeded, and events when there is a data ready to be read from the output. The INT_DRDY pin of
the LPS35HW IC is routed to the mikroBUS™ INT pin. Its active state (active LOW or active HIGH) is freely configurable. Pressure data at the output is in 24-bit, two’s complement format. Thanks to the highly advanced ASIC, the output is already formatted in physical units, with minimum operations required from the host MCU. Since the sensitivity is 4096 LSB/hPa, the output result should be divided by 4096 in order to obtain the value in hPa units. Temperature data is in 16-bit two’s complement format, and it does not require any conversions. The sensitivity of the temperature sensor is 100 LSB/⁰C so the output result should be divided by 100 in order to obtain the value in ⁰C units. ASIC also offers some other processing functions such as the lowpass filtering of the output data, which helps reducing the inconsistencies due to sudden pressure changes. This Click Board™ uses both I2C, and it is designed to be operated only with 3.3V logic level. A proper logic voltage level conversion should be performed before the Click board™ is used with MCUs with logic levels of 5V.
Features overview
Development board
EasyPIC PRO v7a is the seventh generation of PIC development boards specially designed to develop embedded applications rapidly. It supports a wide range of 8-bit PIC microcontrollers from Microchip and a broad set of unique functions, such as the first-ever embedded debugger/programmer over USB-C. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. With two different connectors for each port, EasyPIC PRO v7a allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyPIC PRO
v7a development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART,
RS-232, and Ethernet are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and a standard TQFP socket for the seventh-generation MCU cards. This socket covers a wide range of 8-bit PIC MCUs, from PIC18LF, PIC16LF, PIC16F, and PIC18F families. EasyPIC PRO v7a is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Type
7th Generation
Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
80
RAM (Bytes)
3808
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Software Support
Library Description
This library contains API for Barometer 2 Click driver.
Key functions:
barometer2_get_pressure- Gets the pressure valuebarometer2_get_temperature- Gets the temperature valuebarometer2_software_reset- Resets the device
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief Barometer2 Click example
*
* # Description
* This application measures temperature and pressure data.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes and configures the Click and logger modules and tests the communication for errors.
*
* ## Application Task
* Reads and displays temperature and pressure values every second.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "barometer2.h"
// ------------------------------------------------------------------ VARIABLES
static barometer2_t barometer2;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( )
{
log_cfg_t log_cfg;
barometer2_cfg_t cfg;
uint8_t test;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
barometer2_cfg_setup( &cfg );
BAROMETER2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
barometer2_init( &barometer2, &cfg );
// Test communication
test = barometer2_read_byte( &barometer2, BAROMETER2_REG_WHO_AM_I );
if ( test == BAROMETER2_WHO_AM_I )
{
log_printf( &logger, "---- Communication OK!!! ----\r\n" );
}
else
{
log_printf( &logger, "---- Communication ERROR!!! ----\r\n" );
for ( ; ; );
}
// Software reset
barometer2_software_reset( &barometer2 );
Delay_ms ( 1000 );
barometer2_default_cfg( &barometer2 );
Delay_ms ( 1000 );
log_printf( &logger, "---- Start Measurement ---- \r\n" );
}
void application_task ( )
{
float temperature;
float pressure;
temperature = barometer2_get_temperature( &barometer2, BAROMETER2_TEMPERATURE_IN_CELSIUS );
log_printf( &logger, " Temperature : %.2f C\r\n", temperature );
pressure = barometer2_get_pressure( &barometer2, BAROMETER2_PRESSURE_DATA_IN_mBar );
log_printf( &logger, " Pressure : %.2f mbar\r\n", pressure );
log_printf( &logger, "-------------------------- \r\n" );
Delay_ms ( 1000 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END


































