ESPHome  2024.11.0
honeywellabp2.h
Go to the documentation of this file.
1 // for Honeywell ABP sensor
2 // adapting code from https://github.com/vwls/Honeywell_pressure_sensors
3 #pragma once
4 
7 #include "esphome/core/hal.h"
9 
10 namespace esphome {
11 namespace honeywellabp2_i2c {
12 
14 
16  public:
17  void set_pressure_sensor(sensor::Sensor *pressure_sensor) { this->pressure_sensor_ = pressure_sensor; };
18  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; };
19  void loop() override;
20  void update() override;
21  float get_setup_priority() const override { return setup_priority::DATA; };
22  void dump_config() override;
23 
24  void read_sensor_data();
25  void start_measurement();
26  bool is_measurement_ready();
27  void measurement_timeout();
28 
29  float get_pressure();
30  float get_temperature();
31 
32  void set_min_pressure(float min_pressure) { this->min_pressure_ = min_pressure; };
33  void set_max_pressure(float max_pressure) { this->max_pressure_ = max_pressure; };
34  void set_transfer_function(ABP2TRANFERFUNCTION transfer_function);
35 
36  protected:
37  float min_pressure_ = 0.0;
38  float max_pressure_ = 0.0;
40 
43 
44  const float max_count_a_ = 15099494.4; // (90% of 2^24 counts or 0xE66666)
45  const float min_count_a_ = 1677721.6; // (10% of 2^24 counts or 0x19999A)
46  const float max_count_b_ = 11744051.2; // (70% of 2^24 counts or 0xB33333)
47  const float min_count_b_ = 5033164.8; // (30% of 2^24 counts or 0x4CCCCC)
48 
49  float max_count_;
50  float min_count_;
51  bool measurement_running_ = false;
52 
53  uint8_t raw_data_[7]; // holds output data
54  uint8_t i2c_cmd_[3] = {0xAA, 0x00, 0x00}; // command to be sent
57 };
58 
59 } // namespace honeywellabp2_i2c
60 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition: honeywellabp2.h:18
void set_pressure_sensor(sensor::Sensor *pressure_sensor)
Definition: honeywellabp2.h:17
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
void set_transfer_function(ABP2TRANFERFUNCTION transfer_function)