7static const char *
const TAG =
"grove_gas_mc_v2";
12static const uint8_t GROVE_GAS_MC_V2_HEAT_ON = 0xFE;
13static const uint8_t GROVE_GAS_MC_V2_HEAT_OFF = 0xFF;
14static const uint8_t GROVE_GAS_MC_V2_READ_GM102B = 0x01;
15static const uint8_t GROVE_GAS_MC_V2_READ_GM302B = 0x03;
16static const uint8_t GROVE_GAS_MC_V2_READ_GM502B = 0x05;
17static const uint8_t GROVE_GAS_MC_V2_READ_GM702B = 0x07;
20 if (sensor ==
nullptr) {
24 if (!this->
read_bytes(address, (uint8_t *) &value, 4)) {
25 ESP_LOGW(TAG,
"Reading Grove Gas Sensor data failed!");
36 if (!(this->
write_bytes(GROVE_GAS_MC_V2_HEAT_ON, {}))) {
42void GroveGasMultichannelV2Component::update() {
44 if (!this->
read_sensor_(GROVE_GAS_MC_V2_READ_GM102B, this->nitrogen_dioxide_sensor_))
46 if (!this->
read_sensor_(GROVE_GAS_MC_V2_READ_GM302B, this->ethanol_sensor_))
48 if (!this->
read_sensor_(GROVE_GAS_MC_V2_READ_GM502B, this->tvoc_sensor_))
50 if (!this->
read_sensor_(GROVE_GAS_MC_V2_READ_GM702B, this->carbon_monoxide_sensor_))
56void GroveGasMultichannelV2Component::dump_config() {
57 ESP_LOGCONFIG(TAG,
"Grove Multichannel Gas Sensor V2");
59 LOG_UPDATE_INTERVAL(this);
60 LOG_SENSOR(" ", "Nitrogen Dioxide", this->nitrogen_dioxide_sensor_);
61 LOG_SENSOR(" ", "Ethanol", this->ethanol_sensor_);
62 LOG_SENSOR(" ", "Carbon Monoxide", this->carbon_monoxide_sensor_);
63 LOG_SENSOR(" ", "TVOC", this->tvoc_sensor_);
66 switch (this->error_code_) {
68 ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
71 ESP_LOGW(TAG,
"Sensor reported invalid APP installed");
74 ESP_LOGW(TAG,
"Sensor reported APP start failed");
78 ESP_LOGW(TAG,
"Unknown setup error");