ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
zyaura.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
6
7namespace esphome::zyaura {
8
9static const uint8_t ZA_MAX_MS = 2;
10static const uint8_t ZA_MSG_LEN = 5;
11static const uint8_t ZA_FRAME_SIZE = 40;
12static const uint8_t ZA_MSG_DELIMETER = 0x0D;
13
14static const uint8_t ZA_BYTE_TYPE = 0;
15static const uint8_t ZA_BYTE_HIGH = 1;
16static const uint8_t ZA_BYTE_LOW = 2;
17static const uint8_t ZA_BYTE_SUM = 3;
18static const uint8_t ZA_BYTE_END = 4;
19
21 HUMIDITY = 0x41,
23 CO2 = 0x50,
24};
25
26struct ZaMessage {
28 uint16_t value;
29};
30
32 public:
33 bool decode(uint32_t ms, bool data);
35
36 protected:
37 uint8_t buffer_[ZA_MSG_LEN];
38 int num_bits_ = 0;
40};
41
43 public:
44 uint16_t co2 = -1;
45 uint16_t temperature = -1;
46 uint16_t humidity = -1;
47
48 void setup(InternalGPIOPin *pin_clock, InternalGPIOPin *pin_data);
49 static void interrupt(ZaSensorStore *arg);
50
51 protected:
55
57};
58
60class ZyAuraSensor final : public PollingComponent {
61 public:
66 SUB_SENSOR(humidity)
67
68 void setup() override { this->store_.setup(this->pin_clock_, this->pin_data_); }
69 void dump_config() override;
70 void update() override;
71
72 protected:
76
77 bool publish_state_(ZaDataType data_type, sensor::Sensor *sensor, uint16_t *data_value);
78};
79
80} // namespace esphome::zyaura
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition gpio_pin.h:98
This class simplifies creating components that periodically check a state.
Definition component.h:532
Base-class for all sensors.
Definition sensor.h:48
uint8_t buffer_[ZA_MSG_LEN]
Definition zyaura.h:37
bool decode(uint32_t ms, bool data)
Definition zyaura.cpp:9
void set_data_(ZaMessage *message)
Definition zyaura.cpp:57
ZaDataProcessor processor_
Definition zyaura.h:54
ISRInternalGPIOPin pin_data_
Definition zyaura.h:53
void setup(InternalGPIOPin *pin_clock, InternalGPIOPin *pin_data)
Definition zyaura.cpp:40
static void interrupt(ZaSensorStore *arg)
Definition zyaura.cpp:48
ISRInternalGPIOPin pin_clock_
Definition zyaura.h:52
Component for reading temperature/co2/humidity measurements from ZyAura sensors.
Definition zyaura.h:60
void set_pin_clock(InternalGPIOPin *pin)
Definition zyaura.h:62
SUB_SENSOR(co2) SUB_SENSOR(temperature) SUB_SENSOR(humidity) void setup() override
Definition zyaura.h:64
InternalGPIOPin * pin_clock_
Definition zyaura.h:74
void set_pin_data(InternalGPIOPin *pin)
Definition zyaura.h:63
InternalGPIOPin * pin_data_
Definition zyaura.h:75
void dump_config() override
Definition zyaura.cpp:103
bool publish_state_(ZaDataType data_type, sensor::Sensor *sensor, uint16_t *data_value)
Definition zyaura.cpp:71
const LogString * message
Definition component.cpp:35
void setup()
static void uint32_t
uint16_t temperature
Definition sun_gtil2.cpp:12