ESPHome
2026.3.0
Loading...
Searching...
No Matches
esphome
components
sen6x
sen6x.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/sensor/sensor.h
"
5
#include "
esphome/components/sensirion_common/i2c_sensirion.h
"
6
7
namespace
esphome::sen6x
{
8
9
class
SEN6XComponent
:
public
PollingComponent
,
public
sensirion_common::SensirionI2CDevice
{
10
SUB_SENSOR(pm_1_0)
11
SUB_SENSOR(pm_2_5)
12
SUB_SENSOR(pm_4_0)
13
SUB_SENSOR(pm_10_0)
14
SUB_SENSOR(
temperature
)
15
SUB_SENSOR(humidity)
16
SUB_SENSOR(voc)
17
SUB_SENSOR(nox)
18
SUB_SENSOR(co2)
19
SUB_SENSOR(hcho)
20
21
public
:
22
float
get_setup_priority
()
const override
{
return
setup_priority::DATA
; }
23
void
setup
()
override
;
24
void
dump_config()
override
;
25
void
update()
override
;
26
27
enum
Sen6xType { SEN62, SEN63C, SEN65, SEN66, SEN68, SEN69C, UNKNOWN };
28
29
void
set_type(
const
std::string &
type
) {
sen6x_type_
=
infer_type_from_product_name_
(
type
); }
30
31
protected
:
32
Sen6xType
infer_type_from_product_name_
(
const
std::string &product_name);
33
void
poll_data_ready_
();
34
void
read_measurements_
();
35
void
parse_and_publish_measurements_
();
36
37
bool
initialized_
{
false
};
38
std::string
product_name_
;
39
Sen6xType
sen6x_type_
{UNKNOWN};
40
std::string
serial_number_
;
41
uint16_t
read_cmd_
{0};
42
uint8_t
firmware_version_major_
{0};
43
uint8_t
firmware_version_minor_
{0};
44
uint8_t
poll_retries_remaining_
{0};
45
uint8_t
read_words_
{0};
46
bool
startup_complete_
{
false
};
47
};
48
49
}
// namespace esphome::sen6x
esphome::Component::get_setup_priority
virtual float get_setup_priority() const
priority of setup().
Definition
component.cpp:92
esphome::Component::setup
virtual void setup()
Where the component's initialization should happen.
Definition
component.cpp:94
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:538
esphome::sen6x::SEN6XComponent
Definition
sen6x.h:9
esphome::sen6x::SEN6XComponent::startup_complete_
bool startup_complete_
Definition
sen6x.h:46
esphome::sen6x::SEN6XComponent::read_cmd_
uint16_t read_cmd_
Definition
sen6x.h:41
esphome::sen6x::SEN6XComponent::read_words_
uint8_t read_words_
Definition
sen6x.h:45
esphome::sen6x::SEN6XComponent::read_measurements_
void read_measurements_()
Definition
sen6x.cpp:246
esphome::sen6x::SEN6XComponent::serial_number_
std::string serial_number_
Definition
sen6x.h:40
esphome::sen6x::SEN6XComponent::product_name_
std::string product_name_
Definition
sen6x.h:38
esphome::sen6x::SEN6XComponent::sen6x_type_
Sen6xType sen6x_type_
Definition
sen6x.h:39
esphome::sen6x::SEN6XComponent::poll_retries_remaining_
uint8_t poll_retries_remaining_
Definition
sen6x.h:44
esphome::sen6x::SEN6XComponent::infer_type_from_product_name_
Sen6xType infer_type_from_product_name_(const std::string &product_name)
Definition
sen6x.cpp:386
esphome::sen6x::SEN6XComponent::initialized_
bool initialized_
Definition
sen6x.h:37
esphome::sen6x::SEN6XComponent::poll_data_ready_
void poll_data_ready_()
Definition
sen6x.cpp:212
esphome::sen6x::SEN6XComponent::firmware_version_minor_
uint8_t firmware_version_minor_
Definition
sen6x.h:43
esphome::sen6x::SEN6XComponent::parse_and_publish_measurements_
void parse_and_publish_measurements_()
Definition
sen6x.cpp:256
esphome::sen6x::SEN6XComponent::firmware_version_major_
uint8_t firmware_version_major_
Definition
sen6x.h:42
esphome::sensirion_common::SensirionI2CDevice
Definition
i2c_sensirion.h:20
component.h
type
uint16_t type
Definition
dns_server_esp32_idf.cpp:0
i2c_sensirion.h
esphome::sen6x
Definition
sen6x.cpp:6
esphome::setup_priority::DATA
constexpr float DATA
For components that import data from directly connected sensors like DHT.
Definition
component.h:31
sensor.h
temperature
uint16_t temperature
Definition
sun_gtil2.cpp:12
Generated by
1.12.0