mirror of
https://github.com/esphome/esphome.git
synced 2024-09-02 00:20:30 +02: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:
parent
83a12d980e
commit
c041cc483c
|
@ -100,7 +100,7 @@ void INA3221Component::update() {
|
|||
this->status_set_warning();
|
||||
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)
|
||||
channel.shunt_voltage_sensor_->publish_state(shunt_voltage_v);
|
||||
current_a = shunt_voltage_v / channel.shunt_resistance_;
|
||||
|
|
Loading…
Reference in New Issue
Block a user