ESPHome 2026.6.0-dev
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
39 public:
40 void setup() override;
41 void dump_config() override;
42 void update() override;
43
44 void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
45 void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
46
47 protected:
48 void read_();
49 void read_pressure_();
50 void read_temperature_();
51 void calculate_values_(int32_t raw_temperature, int32_t raw_pressure);
52 static int32_t twos_complement(int32_t val, uint8_t bits);
53
57 int16_t c0_, c1_, c01_, c11_, c20_, c21_, c30_;
58 uint8_t prod_rev_id_;
60};
61
62} // namespace esphome::dps310
This class simplifies creating components that periodically check a state.
Definition component.h:585
sensor::Sensor * pressure_sensor_
Definition dps310.h:55
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition dps310.h:44
sensor::Sensor * temperature_sensor_
Definition dps310.h:54
void set_pressure_sensor(sensor::Sensor *pressure_sensor)
Definition dps310.h:45
void calculate_values_(int32_t raw_temperature, int32_t raw_pressure)
Definition dps310.cpp:159
static int32_t twos_complement(int32_t val, uint8_t bits)
Definition dps310.cpp:177
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
Base-class for all sensors.
Definition sensor.h:47
mopeka_std_values val[3]