ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
dps310.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::dps310 {
8
9static const uint8_t DPS310_REG_PRS_B2 = 0x00; // Highest byte of pressure data
10static const uint8_t DPS310_REG_TMP_B2 = 0x03; // Highest byte of temperature data
11static const uint8_t DPS310_REG_PRS_CFG = 0x06; // Pressure configuration
12static const uint8_t DPS310_REG_TMP_CFG = 0x07; // Temperature configuration
13static const uint8_t DPS310_REG_MEAS_CFG = 0x08; // Sensor configuration
14static const uint8_t DPS310_REG_CFG = 0x09; // Interrupt/FIFO configuration
15static const uint8_t DPS310_REG_RESET = 0x0C; // Soft reset
16static const uint8_t DPS310_REG_PROD_REV_ID = 0x0D; // Register that contains the part ID
17static const uint8_t DPS310_REG_COEF = 0x10; // Top of calibration coefficient data space
18static const uint8_t DPS310_REG_TMP_COEF_SRC = 0x28; // Temperature calibration src
19
20static const uint8_t DPS310_BIT_PRS_RDY = 0x10; // Pressure measurement is ready
21static const uint8_t DPS310_BIT_TMP_RDY = 0x20; // Temperature measurement is ready
22static const uint8_t DPS310_BIT_SENSOR_RDY = 0x40; // Sensor initialization complete when bit is set
23static const uint8_t DPS310_BIT_COEF_RDY = 0x80; // Coefficients are available when bit is set
24static const uint8_t DPS310_BIT_TMP_COEF_SRC = 0x80; // Temperature measurement source (0 = ASIC, 1 = MEMS element)
25static const uint8_t DPS310_BIT_REQ_PRES = 0x01; // Set this bit to request pressure reading
26static const uint8_t DPS310_BIT_REQ_TEMP = 0x02; // Set this bit to request temperature reading
27
28static const uint8_t DPS310_CMD_RESET = 0x89; // What to write to reset the device
29
30static const uint8_t DPS310_VAL_PRS_CFG = 0x01; // Value written to DPS310_REG_PRS_CFG at startup
31static const uint8_t DPS310_VAL_TMP_CFG = 0x01; // Value written to DPS310_REG_TMP_CFG at startup
32static const uint8_t DPS310_VAL_REG_CFG = 0x00; // Value written to DPS310_REG_CFG at startup
33
34static const uint8_t DPS310_INIT_TIMEOUT = 20; // How long to wait for DPS310 start-up to complete
35static const uint8_t DPS310_NUM_COEF_REGS = 18; // Number of coefficients we need to read from the device
36static const int32_t DPS310_SCALE_FACTOR = 1572864; // Measurement compensation scale factor
37
38class DPS310Component final : public PollingComponent, public i2c::I2CDevice {
39 SUB_SENSOR(temperature)
40 SUB_SENSOR(pressure)
41
42 public:
43 void setup() override;
44 void dump_config() override;
45 void update() override;
46
47 protected:
49 bool setup_registers_();
50 void read_();
51 void read_pressure_();
52 void read_temperature_();
53 void calculate_values_(int32_t raw_temperature, int32_t raw_pressure);
54
56 int16_t c0_, c1_, c01_, c11_, c20_, c21_, c30_;
57 uint8_t prod_rev_id_;
59};
60
61} // namespace esphome::dps310
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
void calculate_values_(int32_t raw_temperature, int32_t raw_pressure)
Definition dps310.cpp:143
bool setup_registers_()
Configure the sensor; false on a failure.
Definition dps310.cpp:17
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
uint16_t temperature
Definition sun_gtil2.cpp:12
uint8_t pressure
Definition tt21100.cpp:7