ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
pm1006
pm1006.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/core/helpers.h
"
5
#include "
esphome/components/sensor/sensor.h
"
6
#include "
esphome/components/uart/uart.h
"
7
8
namespace
esphome::pm1006
{
9
10
class
PM1006Component
final :
public
PollingComponent
,
public
uart::UARTDevice
{
11
SUB_SENSOR(pm_2_5)
12
13
public
:
14
PM1006Component
() =
default
;
15
16
void
setup()
override
;
17
void
dump_config()
override
;
18
void
loop()
override
;
19
void
update()
override
;
20
21
protected
:
22
optional<bool>
check_byte_
()
const
;
23
void
parse_data_
();
24
uint8_t
pm1006_checksum_
(
const
uint8_t *command_data, uint8_t
length
)
const
;
25
uint16_t
get_16_bit_uint_
(uint8_t start_index)
const
{
26
return
encode_uint16
(this->
data_
[start_index], this->
data_
[start_index + 1]);
27
}
28
29
uint8_t
data_
[20];
30
uint8_t
data_index_
{0};
31
uint32_t
last_transmission_
{0};
32
};
33
34
}
// namespace esphome::pm1006
esphome::Component::length
uint32_t length
Definition
component.h:323
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:532
esphome::pm1006::PM1006Component
Definition
pm1006.h:10
esphome::pm1006::PM1006Component::pm1006_checksum_
uint8_t pm1006_checksum_(const uint8_t *command_data, uint8_t length) const
Definition
pm1006.cpp:45
esphome::pm1006::PM1006Component::get_16_bit_uint_
uint16_t get_16_bit_uint_(uint8_t start_index) const
Definition
pm1006.h:25
esphome::pm1006::PM1006Component::last_transmission_
uint32_t last_transmission_
Definition
pm1006.h:31
esphome::pm1006::PM1006Component::data_
uint8_t data_[20]
Definition
pm1006.h:29
esphome::pm1006::PM1006Component::data_index_
uint8_t data_index_
Definition
pm1006.h:30
esphome::pm1006::PM1006Component::parse_data_
void parse_data_()
Definition
pm1006.cpp:80
esphome::pm1006::PM1006Component::check_byte_
optional< bool > check_byte_() const
Definition
pm1006.cpp:49
esphome::uart::UARTDevice
Definition
uart.h:15
component.h
helpers.h
esphome::pm1006
Definition
pm1006.cpp:4
esphome::encode_uint16
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
Definition
helpers.h:1043
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
sensor.h
uart.h
Generated by
1.12.0