mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	fix shunt voltage / current / power reading in INA3221 (#1101)
* fix shunt voltage / current / power reading in INA3221 * support nagetive shunt voltage reading * fix loss of precision
This commit is contained in:
		| @@ -100,7 +100,7 @@ void INA3221Component::update() { | |||||||
|         this->status_set_warning(); |         this->status_set_warning(); | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|       const float shunt_voltage_v = int16_t(raw) * 40.0f / 1000000.0f; |       const float shunt_voltage_v = int16_t(raw) * 40.0f / 8.0f / 1000000.0f; | ||||||
|       if (channel.shunt_voltage_sensor_ != nullptr) |       if (channel.shunt_voltage_sensor_ != nullptr) | ||||||
|         channel.shunt_voltage_sensor_->publish_state(shunt_voltage_v); |         channel.shunt_voltage_sensor_->publish_state(shunt_voltage_v); | ||||||
|       current_a = shunt_voltage_v / channel.shunt_resistance_; |       current_a = shunt_voltage_v / channel.shunt_resistance_; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user