mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 06:33:51 +00:00 
			
		
		
		
	extend scd4x (#3409)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <vector> | ||||
| #include "esphome/core/application.h" | ||||
| #include "esphome/core/component.h" | ||||
| #include "esphome/components/sensor/sensor.h" | ||||
| #include "esphome/components/sensirion_common/i2c_sensirion.h" | ||||
| @@ -7,7 +8,14 @@ | ||||
| namespace esphome { | ||||
| namespace scd4x { | ||||
|  | ||||
| enum ERRORCODE { COMMUNICATION_FAILED, SERIAL_NUMBER_IDENTIFICATION_FAILED, MEASUREMENT_INIT_FAILED, UNKNOWN }; | ||||
| enum ERRORCODE { | ||||
|   COMMUNICATION_FAILED, | ||||
|   SERIAL_NUMBER_IDENTIFICATION_FAILED, | ||||
|   MEASUREMENT_INIT_FAILED, | ||||
|   FRC_FAILED, | ||||
|   UNKNOWN | ||||
| }; | ||||
| enum MeasurementMode { PERIODIC, LOW_POWER_PERIODIC, SINGLE_SHOT, SINGLE_SHOT_RHT_ONLY }; | ||||
|  | ||||
| class SCD4XComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice { | ||||
|  public: | ||||
| @@ -25,10 +33,13 @@ class SCD4XComponent : public PollingComponent, public sensirion_common::Sensiri | ||||
|   void set_co2_sensor(sensor::Sensor *co2) { co2_sensor_ = co2; } | ||||
|   void set_temperature_sensor(sensor::Sensor *temperature) { temperature_sensor_ = temperature; }; | ||||
|   void set_humidity_sensor(sensor::Sensor *humidity) { humidity_sensor_ = humidity; } | ||||
|   void set_measurement_mode(MeasurementMode mode) { measurement_mode_ = mode; } | ||||
|   bool perform_forced_calibration(uint16_t current_co2_concentration); | ||||
|   bool factory_reset(); | ||||
|  | ||||
|  protected: | ||||
|   bool update_ambient_pressure_compensation_(uint16_t pressure_in_hpa); | ||||
|  | ||||
|   bool start_measurement_(); | ||||
|   ERRORCODE error_code_; | ||||
|  | ||||
|   bool initialized_{false}; | ||||
| @@ -38,7 +49,7 @@ class SCD4XComponent : public PollingComponent, public sensirion_common::Sensiri | ||||
|   bool ambient_pressure_compensation_; | ||||
|   uint16_t ambient_pressure_; | ||||
|   bool enable_asc_; | ||||
|  | ||||
|   MeasurementMode measurement_mode_{PERIODIC}; | ||||
|   sensor::Sensor *co2_sensor_{nullptr}; | ||||
|   sensor::Sensor *temperature_sensor_{nullptr}; | ||||
|   sensor::Sensor *humidity_sensor_{nullptr}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user