mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Co-authored-by: Jerome <jerome992@internet.lu>
This commit is contained in:
		| @@ -33,7 +33,10 @@ void CTClampSensor::update() { | ||||
|  | ||||
|     const float rms_ac_dc_squared = this->sample_squared_sum_ / this->num_samples_; | ||||
|     const float rms_dc = this->sample_sum_ / this->num_samples_; | ||||
|     const float rms_ac = std::sqrt(rms_ac_dc_squared - rms_dc * rms_dc); | ||||
|     const float rms_ac_squared = rms_ac_dc_squared - rms_dc * rms_dc; | ||||
|     float rms_ac = 0; | ||||
|     if (rms_ac_squared > 0) | ||||
|       rms_ac = std::sqrt(rms_ac_squared); | ||||
|     ESP_LOGD(TAG, "'%s' - Raw AC Value: %.3fA after %d different samples (%d SPS)", this->name_.c_str(), rms_ac, | ||||
|              this->num_samples_, 1000 * this->num_samples_ / this->sample_duration_); | ||||
|     this->publish_state(rms_ac); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user