ESPHome 2025.5.0
Loading...
Searching...
No Matches
dps310.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace dps310 {
9
10static const uint8_t DPS310_REG_PRS_B2 = 0x00; // Highest byte of pressure data
11static const uint8_t DPS310_REG_TMP_B2 = 0x03; // Highest byte of temperature data
12static const uint8_t DPS310_REG_PRS_CFG = 0x06; // Pressure configuration
13static const uint8_t DPS310_REG_TMP_CFG = 0x07; // Temperature configuration
14static const uint8_t DPS310_REG_MEAS_CFG = 0x08; // Sensor configuration
15static const uint8_t DPS310_REG_CFG = 0x09; // Interrupt/FIFO configuration
16static const uint8_t DPS310_REG_RESET = 0x0C; // Soft reset
17static const uint8_t DPS310_REG_PROD_REV_ID = 0x0D; // Register that contains the part ID
18static const uint8_t DPS310_REG_COEF = 0x10; // Top of calibration coefficient data space
19static const uint8_t DPS310_REG_TMP_COEF_SRC = 0x28; // Temperature calibration src
20
21static const uint8_t DPS310_BIT_PRS_RDY = 0x10; // Pressure measurement is ready
22static const uint8_t DPS310_BIT_TMP_RDY = 0x20; // Temperature measurement is ready
23static const uint8_t DPS310_BIT_SENSOR_RDY = 0x40; // Sensor initialization complete when bit is set
24static const uint8_t DPS310_BIT_COEF_RDY = 0x80; // Coefficients are available when bit is set
25static const uint8_t DPS310_BIT_TMP_COEF_SRC = 0x80; // Temperature measurement source (0 = ASIC, 1 = MEMS element)
26static const uint8_t DPS310_BIT_REQ_PRES = 0x01; // Set this bit to request pressure reading
27static const uint8_t DPS310_BIT_REQ_TEMP = 0x02; // Set this bit to request temperature reading
28
29static const uint8_t DPS310_CMD_RESET = 0x89; // What to write to reset the device
30
31static const uint8_t DPS310_VAL_PRS_CFG = 0x01; // Value written to DPS310_REG_PRS_CFG at startup
32static const uint8_t DPS310_VAL_TMP_CFG = 0x01; // Value written to DPS310_REG_TMP_CFG at startup
33static const uint8_t DPS310_VAL_REG_CFG = 0x00; // Value written to DPS310_REG_CFG at startup
34
35static const uint8_t DPS310_INIT_TIMEOUT = 20; // How long to wait for DPS310 start-up to complete
36static const uint8_t DPS310_NUM_COEF_REGS = 18; // Number of coefficients we need to read from the device
37static const int32_t DPS310_SCALE_FACTOR = 1572864; // Measurement compensation scale factor
38
40 public:
41 void setup() override;
42 void dump_config() override;
43 float get_setup_priority() const override;
44 void update() override;
45
46 void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
47 void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
48
49 protected:
50 void read_();
51 void read_pressure_();
52 void read_temperature_();
53 void calculate_values_(int32_t raw_temperature, int32_t raw_pressure);
54 static int32_t twos_complement(int32_t val, uint8_t bits);
55
59 int16_t c0_, c1_, c01_, c11_, c20_, c21_, c30_;
60 uint8_t prod_rev_id_;
62};
63
64} // namespace dps310
65} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
float get_setup_priority() const override
Definition dps310.cpp:101
sensor::Sensor * pressure_sensor_
Definition dps310.h:57
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition dps310.h:46
sensor::Sensor * temperature_sensor_
Definition dps310.h:56
void set_pressure_sensor(sensor::Sensor *pressure_sensor)
Definition dps310.h:47
void calculate_values_(int32_t raw_temperature, int32_t raw_pressure)
Definition dps310.cpp:163
static int32_t twos_complement(int32_t val, uint8_t bits)
Definition dps310.cpp:181
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
Base-class for all sensors.
Definition sensor.h:57
mopeka_std_values val[4]
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7