F439_CPP_MPL3115A2_Project_01 1.0
STM32F439 MPL3115A2 pressure and temperature tutorial
Loading...
Searching...
No Matches
MPL3115A2 I2C Communication Flow

Startup Flow

  1. main() initializes GPIO, I2C1, and USART1.
  2. main() calls MPL3115A2_Init().
  3. The driver calls HAL_I2C_IsDeviceReady().
  4. If the sensor does not respond, reset_I2C() clocks SCL manually and reinitializes I2C1.
  5. The driver reads WHO_AM_I and expects 0xC4.
  6. The driver places the sensor in standby before configuration changes.
  7. The driver enables pressure and temperature data-ready flags.
  8. The driver enables active barometer mode with OSR=128.

Measurement Flow

Temperature:

  • main() polls the STATUS register for the temperature data-ready bit.
  • MPL3115A2_ReadTemperature() reads OUT_T_MSB and OUT_T_LSB.
  • The raw signed 12-bit fixed-point value is converted to degrees Celsius.
  • main() converts Celsius to Fahrenheit for serial output.

Pressure:

  • main() polls the STATUS register for the pressure/temperature data-ready bit.
  • MPL3115A2_ReadPressure() reads OUT_P_MSB, OUT_P_CSB, and OUT_P_LSB.
  • The raw Q18.2 pressure value is converted from pascals to inches of mercury.