ESPHome 2026.6.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::gdk101 {
17
18static const uint8_t GDK101_REG_READ_FIRMWARE = 0xB4; // Firmware version
19static const uint8_t GDK101_REG_RESET = 0xA0; // Reset register - reading its value triggers reset
20static const uint8_t GDK101_REG_READ_STATUS = 0xB0; // Status register
21static const uint8_t GDK101_REG_READ_MEASURING_TIME = 0xB1; // Mesuring time
22static const uint8_t GDK101_REG_READ_10MIN_AVG = 0xB2; // Average radiation dose per 10 min
23static const uint8_t GDK101_REG_READ_1MIN_AVG = 0xB3; // Average radiation dose per 1 min
24
26#ifdef USE_SENSOR
27 SUB_SENSOR(rad_1m)
28 SUB_SENSOR(rad_10m)
29 SUB_SENSOR(status)
30 SUB_SENSOR(measurement_duration)
31#endif // USE_SENSOR
32#ifdef USE_BINARY_SENSOR
33 SUB_BINARY_SENSOR(vibration)
34#endif // USE_BINARY_SENSOR
35#ifdef USE_TEXT_SENSOR
36 SUB_TEXT_SENSOR(fw_version)
37#endif // USE_TEXT_SENSOR
38
39 public:
40 void setup() override;
41 void dump_config() override;
42 void update() override;
43
44 protected:
45 bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len);
46 bool try_reset_();
47 bool reset_sensor_(uint8_t *data);
48 bool read_dose_1m_(uint8_t *data);
49 bool read_dose_10m_(uint8_t *data);
50 bool read_status_(uint8_t *data);
51 bool read_fw_version_(uint8_t *data);
52 bool read_measurement_duration_(uint8_t *data);
53 bool reset_complete_{false};
55};
56
57} // namespace esphome::gdk101
uint8_t status
Definition bl0942.h:8
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:585
bool try_reset_()
Attempt to reset the sensor and read firmware version. Returns true on success or hard failure.
Definition gdk101.cpp:60
bool read_status_(uint8_t *data)
Definition gdk101.cpp:154
bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len)
Definition gdk101.cpp:104
bool read_dose_1m_(uint8_t *data)
Definition gdk101.cpp:122
bool read_dose_10m_(uint8_t *data)
Definition gdk101.cpp:138
bool read_fw_version_(uint8_t *data)
Definition gdk101.cpp:175
bool reset_sensor_(uint8_t *data)
Definition gdk101.cpp:114
bool read_measurement_duration_(uint8_t *data)
Definition gdk101.cpp:192
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
const void size_t len
Definition hal.h:64