Skip to content

Commit

Permalink
Fix INA226 Sensor Voltage Readings
Browse files Browse the repository at this point in the history
They were off by a factor of 1000 due to the difference between
Volts and MilliVolts, as reported by @morcant .

Fixes meshtastic#5969
  • Loading branch information
fifieldt committed Feb 1, 2025
1 parent 3a5c498 commit fbd6e65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/Telemetry/Sensor/INA226Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ bool INA226Sensor::getMetrics(meshtastic_Telemetry *measurement)
measurement->variant.environment_metrics.has_current = true;

// mV conversion to V
measurement->variant.environment_metrics.voltage = ina226.getBusVoltage() / 1000;
measurement->variant.environment_metrics.voltage = ina226.getBusVoltage();
measurement->variant.environment_metrics.current = ina226.getCurrent_mA();
return true;
}

uint16_t INA226Sensor::getBusVoltageMv()
{
return lround(ina226.getBusVoltage());
return lround(ina226.getBusVoltage() * 1000);
}

int16_t INA226Sensor::getCurrentMa()
Expand Down

0 comments on commit fbd6e65

Please sign in to comment.