Sensor driver for MPXV5004 sensor written in C programming language. This repository contains the sensor driver files (.h and .c) to be included, in your project. The driver is MISRA compliant and the documentation can be generated using the Doxygen tool.
The driver is platform-independent. Since the sensor provides an analog output only, acquisition of data is performed through an Analog-to-Digital Converter (ADC) rather than a digital bus such as SPI or I²C. The user must therefore implement a function to acquire and convert the analog voltage from the sensor via the target platform’s ADC peripheral.
Unlike digital interfaces, there is no register read/write protocol or multi-byte access mechanism to manage. Instead, the accuracy and timing of the measurement depend on the ADC configuration (resolution, reference voltage, and sampling time), which must be properly set by the user.
Please refer to the ADC read implementation examples in the mpxv5004_STdC\examples folder for guidance.
- Include in your project the driver files of the sensor (.h and .c)
- Define in your code the read and write functions that use the ADC platform driver like the following:
/** Please note that is MANDATORY: return 0 -> no Error.**/
int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp, uint16_t len)
int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
/** Optional (may be required by driver) **/
void platform_delay(uint32_t millisec)
- Declare and initialize the structure of the device interface:
xxxxxxx_ctx_t dev_ctx; /** xxxxxxx is the used part number **/
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
dev_ctx.mdelay = platform_delay;
- If needed by the platform read and write functions, initialize the handle parameter:
dev_ctx.handle = &platform_handle;
Some integration examples can be found under mpxv5004_STdC\examples folder.
- A standard C language compiler for the target MCU
- A C library for the target MCU and an Analog interface (ie. ADC)
More Information: http://www.st.com
Copyright (C) 2026 STMicroelectronics