ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
gcja5
gcja5.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::gcja5
{
9
10
class
GCJA5Component
final :
public
Component
,
public
uart::UARTDevice
{
11
SUB_SENSOR(pm_1_0)
12
SUB_SENSOR(pm_2_5)
13
SUB_SENSOR(pm_10_0)
14
SUB_SENSOR(pmc_0_3)
15
SUB_SENSOR(pmc_0_5)
16
SUB_SENSOR(pmc_1_0)
17
SUB_SENSOR(pmc_2_5)
18
SUB_SENSOR(pmc_5_0)
19
SUB_SENSOR(pmc_10_0)
20
21
public
:
22
void
dump_config
()
override
;
23
void
loop()
override
;
24
25
protected
:
26
bool
parse_data_
();
27
bool
calculate_checksum_
();
28
29
uint16_t
get_16_bit_uint_
(uint8_t start_index)
const
{
30
return
encode_uint16
(this->
rx_message_
[start_index + 1], this->
rx_message_
[start_index]);
31
}
32
uint32_t
get_32_bit_uint_
(uint8_t start_index)
const
{
33
return
encode_uint32
(this->
rx_message_
[start_index + 3], this->
rx_message_
[start_index + 2],
34
this->
rx_message_
[start_index + 1], this->
rx_message_
[start_index]);
35
}
36
uint32_t
last_transmission_
{0};
37
std::vector<uint8_t>
rx_message_
;
38
39
bool
first_status_log_
{
false
};
40
};
41
42
}
// namespace esphome::gcja5
esphome::Component
Definition
component.h:147
esphome::Component::dump_config
virtual void dump_config()
Definition
component.cpp:359
esphome::gcja5::GCJA5Component
Definition
gcja5.h:10
esphome::gcja5::GCJA5Component::get_32_bit_uint_
uint32_t get_32_bit_uint_(uint8_t start_index) const
Definition
gcja5.h:32
esphome::gcja5::GCJA5Component::get_16_bit_uint_
uint16_t get_16_bit_uint_(uint8_t start_index) const
Definition
gcja5.h:29
esphome::gcja5::GCJA5Component::parse_data_
bool parse_data_()
Definition
gcja5.cpp:66
esphome::gcja5::GCJA5Component::calculate_checksum_
bool calculate_checksum_()
Definition
gcja5.cpp:58
esphome::gcja5::GCJA5Component::first_status_log_
bool first_status_log_
Definition
gcja5.h:39
esphome::gcja5::GCJA5Component::last_transmission_
uint32_t last_transmission_
Definition
gcja5.h:36
esphome::gcja5::GCJA5Component::rx_message_
std::vector< uint8_t > rx_message_
Definition
gcja5.h:37
esphome::uart::UARTDevice
Definition
uart.h:15
component.h
helpers.h
esphome::gcja5
Definition
gcja5.cpp:12
esphome::encode_uint32
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
Definition
helpers.h:1051
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