ESPHome  2024.12.2
bmp280_base.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace bmp280_base {
8 
11  uint16_t t1; // 0x88 - 0x89
12  int16_t t2; // 0x8A - 0x8B
13  int16_t t3; // 0x8C - 0x8D
14 
15  uint16_t p1; // 0x8E - 0x8F
16  int16_t p2; // 0x90 - 0x91
17  int16_t p3; // 0x92 - 0x93
18  int16_t p4; // 0x94 - 0x95
19  int16_t p5; // 0x96 - 0x97
20  int16_t p6; // 0x98 - 0x99
21  int16_t p7; // 0x9A - 0x9B
22  int16_t p8; // 0x9C - 0x9D
23  int16_t p9; // 0x9E - 0x9F
24 };
25 
38 };
39 
50 };
51 
54  public:
55  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
56  void set_pressure_sensor(sensor::Sensor *pressure_sensor) { pressure_sensor_ = pressure_sensor; }
57 
59  void set_temperature_oversampling(BMP280Oversampling temperature_over_sampling);
61  void set_pressure_oversampling(BMP280Oversampling pressure_over_sampling);
63  void set_iir_filter(BMP280IIRFilter iir_filter);
64 
65  void setup() override;
66  void dump_config() override;
67  float get_setup_priority() const override;
68  void update() override;
69 
70  virtual bool read_byte(uint8_t a_register, uint8_t *data) = 0;
71  virtual bool write_byte(uint8_t a_register, uint8_t data) = 0;
72  virtual bool read_bytes(uint8_t a_register, uint8_t *data, size_t len) = 0;
73  virtual bool read_byte_16(uint8_t a_register, uint16_t *data) = 0;
74 
75  protected:
77  float read_temperature_(int32_t *t_fine);
79  float read_pressure_(int32_t t_fine);
80  uint8_t read_u8_(uint8_t a_register);
81  uint16_t read_u16_le_(uint8_t a_register);
82  int16_t read_s16_le_(uint8_t a_register);
83 
85  BMP280Oversampling temperature_oversampling_{BMP280_OVERSAMPLING_16X};
88  sensor::Sensor *temperature_sensor_{nullptr};
89  sensor::Sensor *pressure_sensor_{nullptr};
90  enum ErrorCode {
91  NONE = 0,
94  } error_code_{NONE};
95 };
96 
97 } // namespace bmp280_base
98 } // namespace esphome
void setup()
Internal struct storing the calibration values of an BMP280.
Definition: bmp280_base.h:10
BMP280Oversampling
Enum listing all Oversampling values for the BMP280.
Definition: bmp280_base.h:31
This class simplifies creating components that periodically check a state.
Definition: component.h:283
BMP280CalibrationData calibration_
Definition: bmp280_base.h:84
void set_pressure_sensor(sensor::Sensor *pressure_sensor)
Definition: bmp280_base.h:56
BMP280IIRFilter
Enum listing all Infinite Impulse Filter values for the BMP280.
Definition: bmp280_base.h:44
This class implements support for the BMP280 Temperature+Pressure sensor.
Definition: bmp280_base.h:53
std::string size_t len
Definition: helpers.h:293
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition: bmp280_base.h:55
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57