Skip to content

BMP390

BMP390 barometric pressure and temperature sensor service. Waits for the DRDY interrupt (via a volatile flag set by the GPIO ISR), reads raw ADC data over SPI, compensates it using the sensor's factory calibration, and publishes altitude / pressure / temperature packets via pub/sub.

APID: K_BMP390_SERVICE_APID (0x0004)


Files

File Description
bmp390.h Public API and BMP390_t context struct
bmp390.c Driver implementation, compensation formulas, service task

Key types

typedef struct {
    /* Config — set at declaration */
    spp_uint8_t  spiDevIdx;    // SPI device index (1 = BMP390 on ESP32 port)
    spp_uint32_t intPin;       // DRDY interrupt GPIO
    spp_uint32_t intIntrType;  // Interrupt trigger type (rising edge = 1)
    spp_uint32_t intPull;      // Pull resistor: 0=none 1=up 2=down

    /* Runtime — filled by init, do not set manually */
    void        *p_spiHandler;
    BMP390_Data_t bmpData;     // drdyFlag + ISR context
    spp_uint16_t  seq;
} BMP390_t;

BMP390_Data_t contains a volatile spp_bool_t drdyFlag that the GPIO ISR sets. SPP_SERVICES_callProducers() calls produce which checks the flag internally.


Registration

extern const SPP_Module_t g_bmp390Module;

static BMP390_t s_bmp = {
    .spiDevIdx   = 1U,
    .intPin      = 17U,
    .intIntrType = 1U,   // rising edge
    .intPull     = 0U,   // no pull
};

SPP_SERVICES_register(&g_bmp390Module, &s_bmp);

register() calls init (mounts SPI, installs ISR, configures sensor) and start immediately. No separate initAll() or startAll() needed.


Packet payload layout (12 bytes)

Offset Type Field
0 float Altitude (m)
4 float Pressure (Pa)
8 float Temperature (°C)

Hardware configuration (ESP32-S3)

  • SPI device index: 1 (CS GPIO 18, 500 kHz, MODE0)
  • DRDY interrupt GPIO: 17 (configured via BMP390_t)
  • ODR: 50 Hz
  • IIR filter: coefficient 2
  • Over-sampling: default (OSR = 0)
  • Chip ID register: 0x00, expected value 0x60