ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
honeywellabp2_i2c
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
5
#include "
esphome/components/sensor/sensor.h
"
6
#include "
esphome/components/i2c/i2c.h
"
7
#include "
esphome/core/hal.h
"
8
#include "
esphome/core/component.h
"
9
10
namespace
esphome::honeywellabp2_i2c
{
11
12
enum
ABP2TRANFERFUNCTION
{
ABP2_TRANS_FUNC_A
= 0,
ABP2_TRANS_FUNC_B
= 1 };
13
14
class
HONEYWELLABP2Sensor
final :
public
PollingComponent
,
public
i2c::I2CDevice
{
15
SUB_SENSOR(
pressure
)
16
SUB_SENSOR(
temperature
)
17
18
public
:
19
void
loop
()
override
;
20
void
update()
override
;
21
void
dump_config()
override
;
22
23
void
read_sensor_data();
24
void
start_measurement();
25
bool
is_measurement_ready();
26
void
measurement_timeout();
27
28
float
get_pressure();
29
float
get_temperature();
30
31
void
set_min_pressure(
float
min_pressure) { this->
min_pressure_
= min_pressure; };
32
void
set_max_pressure(
float
max_pressure) { this->
max_pressure_
= max_pressure; };
33
void
set_transfer_function(
ABP2TRANFERFUNCTION
transfer_function);
34
35
protected
:
36
float
min_pressure_
= 0.0;
37
float
max_pressure_
= 0.0;
38
ABP2TRANFERFUNCTION
transfer_function_
=
ABP2_TRANS_FUNC_A
;
39
40
const
float
max_count_a_
= 15099494.4;
// (90% of 2^24 counts or 0xE66666)
41
const
float
min_count_a_
= 1677721.6;
// (10% of 2^24 counts or 0x19999A)
42
const
float
max_count_b_
= 11744051.2;
// (70% of 2^24 counts or 0xB33333)
43
const
float
min_count_b_
= 5033164.8;
// (30% of 2^24 counts or 0x4CCCCC)
44
45
float
max_count_
{
max_count_a_
};
46
float
min_count_
{
min_count_a_
};
47
bool
measurement_running_
=
false
;
48
49
uint8_t
raw_data_
[7];
// holds output data
50
uint8_t
i2c_cmd_
[3] = {0xAA, 0x00, 0x00};
// command to be sent
51
float
last_pressure_
;
52
float
last_temperature_
;
53
};
54
55
}
// namespace esphome::honeywellabp2_i2c
esphome::Component::loop
virtual void loop()
This method will be called repeatedly.
Definition
component.cpp:86
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:532
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor
Definition
honeywellabp2.h:14
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::min_pressure_
float min_pressure_
Definition
honeywellabp2.h:36
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::max_count_
float max_count_
Definition
honeywellabp2.h:45
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::min_count_a_
const float min_count_a_
Definition
honeywellabp2.h:41
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::max_count_a_
const float max_count_a_
Definition
honeywellabp2.h:40
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::max_count_b_
const float max_count_b_
Definition
honeywellabp2.h:42
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::min_count_b_
const float min_count_b_
Definition
honeywellabp2.h:43
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::i2c_cmd_
uint8_t i2c_cmd_[3]
Definition
honeywellabp2.h:50
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::raw_data_
uint8_t raw_data_[7]
Definition
honeywellabp2.h:49
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::last_temperature_
float last_temperature_
Definition
honeywellabp2.h:52
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::max_pressure_
float max_pressure_
Definition
honeywellabp2.h:37
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::transfer_function_
ABP2TRANFERFUNCTION transfer_function_
Definition
honeywellabp2.h:38
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::last_pressure_
float last_pressure_
Definition
honeywellabp2.h:51
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::min_count_
float min_count_
Definition
honeywellabp2.h:46
esphome::honeywellabp2_i2c::HONEYWELLABP2Sensor::measurement_running_
bool measurement_running_
Definition
honeywellabp2.h:47
esphome::i2c::I2CDevice
This Class provides the methods to read/write bytes from/to an i2c device.
Definition
i2c.h:144
component.h
hal.h
i2c.h
esphome::honeywellabp2_i2c
Definition
honeywellabp2.cpp:5
esphome::honeywellabp2_i2c::ABP2TRANFERFUNCTION
ABP2TRANFERFUNCTION
Definition
honeywellabp2.h:12
esphome::honeywellabp2_i2c::ABP2_TRANS_FUNC_B
@ ABP2_TRANS_FUNC_B
Definition
honeywellabp2.h:12
esphome::honeywellabp2_i2c::ABP2_TRANS_FUNC_A
@ ABP2_TRANS_FUNC_A
Definition
honeywellabp2.h:12
sensor.h
temperature
uint16_t temperature
Definition
sun_gtil2.cpp:12
pressure
uint8_t pressure
Definition
tt21100.cpp:7
Generated by
1.12.0