ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
gdk101.h
Go to the documentation of this file.
1#pragma once
2
5#ifdef USE_SENSOR
7#endif // USE_SENSOR
8#ifdef USE_BINARY_SENSOR
10#endif // USE_BINARY_SENSOR
11#ifdef USE_TEXT_SENSOR
13#endif // USE_TEXT_SENSOR
15
16namespace esphome {
17namespace gdk101 {
18
19static const uint8_t GDK101_REG_READ_FIRMWARE = 0xB4; // Firmware version
20static const uint8_t GDK101_REG_RESET = 0xA0; // Reset register - reading its value triggers reset
21static const uint8_t GDK101_REG_READ_STATUS = 0xB0; // Status register
22static const uint8_t GDK101_REG_READ_MEASURING_TIME = 0xB1; // Mesuring time
23static const uint8_t GDK101_REG_READ_10MIN_AVG = 0xB2; // Average radiation dose per 10 min
24static const uint8_t GDK101_REG_READ_1MIN_AVG = 0xB3; // Average radiation dose per 1 min
25
27#ifdef USE_SENSOR
28 SUB_SENSOR(rad_1m)
29 SUB_SENSOR(rad_10m)
30 SUB_SENSOR(status)
31 SUB_SENSOR(measurement_duration)
32#endif // USE_SENSOR
33#ifdef USE_BINARY_SENSOR
34 SUB_BINARY_SENSOR(vibration)
35#endif // USE_BINARY_SENSOR
36#ifdef USE_TEXT_SENSOR
37 SUB_TEXT_SENSOR(fw_version)
38#endif // USE_TEXT_SENSOR
39
40 public:
41 void setup() override;
42 void dump_config() override;
43 void update() override;
44
45 protected:
46 bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len);
47 bool try_reset_();
48 bool reset_sensor_(uint8_t *data);
49 bool read_dose_1m_(uint8_t *data);
50 bool read_dose_10m_(uint8_t *data);
51 bool read_status_(uint8_t *data);
52 bool read_fw_version_(uint8_t *data);
53 bool read_measurement_duration_(uint8_t *data);
54 bool reset_complete_{false};
56};
57
58} // namespace gdk101
59} // namespace esphome
uint8_t status
Definition bl0942.h:8
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:89
This class simplifies creating components that periodically check a state.
Definition component.h:602
bool try_reset_()
Attempt to reset the sensor and read firmware version. Returns true on success or hard failure.
Definition gdk101.cpp:61
bool read_status_(uint8_t *data)
Definition gdk101.cpp:155
bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len)
Definition gdk101.cpp:105
bool read_dose_1m_(uint8_t *data)
Definition gdk101.cpp:123
bool read_dose_10m_(uint8_t *data)
Definition gdk101.cpp:139
bool read_fw_version_(uint8_t *data)
Definition gdk101.cpp:176
bool reset_sensor_(uint8_t *data)
Definition gdk101.cpp:115
bool read_measurement_duration_(uint8_t *data)
Definition gdk101.cpp:193
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:1045