ESPHome  2024.6.6
gdk101.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/defines.h"
5 #ifdef USE_SENSOR
7 #endif // USE_SENSOR
8 #ifdef USE_BINARY_SENSOR
10 #endif // USE_BINARY_SENSOR
12 
13 namespace esphome {
14 namespace gdk101 {
15 
16 static const uint8_t GDK101_REG_READ_FIRMWARE = 0xB4; // Firmware version
17 static const uint8_t GDK101_REG_RESET = 0xA0; // Reset register - reading its value triggers reset
18 static const uint8_t GDK101_REG_READ_STATUS = 0xB0; // Status register
19 static const uint8_t GDK101_REG_READ_MEASURING_TIME = 0xB1; // Mesuring time
20 static const uint8_t GDK101_REG_READ_10MIN_AVG = 0xB2; // Average radiation dose per 10 min
21 static const uint8_t GDK101_REG_READ_1MIN_AVG = 0xB3; // Average radiation dose per 1 min
22 
24 #ifdef USE_SENSOR
25  SUB_SENSOR(rad_1m)
26  SUB_SENSOR(rad_10m)
27  SUB_SENSOR(status)
28  SUB_SENSOR(fw_version)
29  SUB_SENSOR(measurement_duration)
30 #endif // USE_SENSOR
31 #ifdef USE_BINARY_SENSOR
32  SUB_BINARY_SENSOR(vibration)
33 #endif // USE_BINARY_SENSOR
34 
35  public:
36  void setup() override;
37  void dump_config() override;
38  float get_setup_priority() const override;
39  void update() override;
40 
41  protected:
42  bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len);
43  bool reset_sensor_(uint8_t *data);
44  bool read_dose_1m_(uint8_t *data);
45  bool read_dose_10m_(uint8_t *data);
46  bool read_status_(uint8_t *data);
47  bool read_fw_version_(uint8_t *data);
48  bool read_measurement_duration_(uint8_t *data);
49 };
50 
51 } // namespace gdk101
52 } // namespace esphome
bool reset_sensor_(uint8_t *data)
Definition: gdk101.cpp:90
This class simplifies creating components that periodically check a state.
Definition: component.h:283
bool read_fw_version_(uint8_t *data)
Definition: gdk101.cpp:156
virtual void setup()
Where the component's initialization should happen.
Definition: component.cpp:48
bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len)
Definition: gdk101.cpp:80
uint8_t status
Definition: bl0942.h:23
bool read_dose_1m_(uint8_t *data)
Definition: gdk101.cpp:103
std::string size_t len
Definition: helpers.h:292
bool read_status_(uint8_t *data)
Definition: gdk101.cpp:135
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
bool read_measurement_duration_(uint8_t *data)
Definition: gdk101.cpp:172
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
bool read_dose_10m_(uint8_t *data)
Definition: gdk101.cpp:119