8static const char *
const TAG =
"gdk101";
9static const uint8_t NUMBER_OF_READ_RETRIES = 5;
11void GDK101Component::update() {
58void GDK101Component::dump_config() {
59 ESP_LOGCONFIG(TAG,
"GDK101:");
62 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
65 LOG_SENSOR(
" ",
"Firmware Version", this->fw_version_sensor_);
66 LOG_SENSOR(
" ",
"Average Radaition Dose per 1 minute", this->rad_1m_sensor_);
67 LOG_SENSOR(
" ",
"Average Radaition Dose per 10 minutes", this->rad_10m_sensor_);
68 LOG_SENSOR(
" ",
"Status", this->status_sensor_);
69 LOG_SENSOR(
" ",
"Measurement Duration", this->measurement_duration_sensor_);
72#ifdef USE_BINARY_SENSOR
73 LOG_BINARY_SENSOR(
" ",
"Vibration Status", this->vibration_binary_sensor_);
80 uint8_t retry = NUMBER_OF_READ_RETRIES;
95 ESP_LOGE(TAG,
"Updating GDK101 failed!");
104 if (this->rad_1m_sensor_ !=
nullptr) {
105 if (!this->
read_bytes(GDK101_REG_READ_1MIN_AVG, data, 2)) {
106 ESP_LOGE(TAG,
"Updating GDK101 failed!");
110 const float dose = data[0] + (data[1] / 100.0f);
112 this->rad_1m_sensor_->publish_state(dose);
120 if (this->rad_10m_sensor_ !=
nullptr) {
121 if (!this->
read_bytes(GDK101_REG_READ_10MIN_AVG, data, 2)) {
122 ESP_LOGE(TAG,
"Updating GDK101 failed!");
126 const float dose = data[0] + (data[1] / 100.0f);
128 this->rad_10m_sensor_->publish_state(dose);
135 if (!this->
read_bytes(GDK101_REG_READ_STATUS, data, 2)) {
136 ESP_LOGE(TAG,
"Updating GDK101 failed!");
141 if (this->status_sensor_ !=
nullptr) {
142 this->status_sensor_->publish_state(data[0]);
146#ifdef USE_BINARY_SENSOR
147 if (this->vibration_binary_sensor_ !=
nullptr) {
148 this->vibration_binary_sensor_->publish_state(data[1]);
157 if (this->fw_version_sensor_ !=
nullptr) {
158 if (!this->
read_bytes(GDK101_REG_READ_FIRMWARE, data, 2)) {
159 ESP_LOGE(TAG,
"Updating GDK101 failed!");
163 const float fw_version = data[0] + (data[1] / 10.0f);
165 this->fw_version_sensor_->publish_state(fw_version);
173 if (this->measurement_duration_sensor_ !=
nullptr) {
174 if (!this->
read_bytes(GDK101_REG_READ_MEASURING_TIME, data, 2)) {
175 ESP_LOGE(TAG,
"Updating GDK101 failed!");
179 const float meas_time = (data[0] * 60) + data[1];
181 this->measurement_duration_sensor_->publish_state(meas_time);
virtual void mark_failed()
Mark this component as failed.
virtual void setup()
Where the component's initialization should happen.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
void status_set_error(const char *message=nullptr)
bool read_status_(uint8_t *data)
bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len)
bool read_dose_1m_(uint8_t *data)
bool read_dose_10m_(uint8_t *data)
bool read_fw_version_(uint8_t *data)
bool reset_sensor_(uint8_t *data)
bool read_measurement_duration_(uint8_t *data)
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)