fix value calculation

This commit is contained in:
Philipp Harms 2024-10-19 04:28:10 +02:00
parent f12c304d93
commit 32ce8e9bc4
2 changed files with 1 additions and 3 deletions

View file

@ -26,7 +26,7 @@ float MCP3221Sensor::sample() {
return NAN;
}
uint16_t value = (data[0] << 8) | data[1];
uint16_t value = encode_uint16(data[0], data[1]);
float voltage = value * this->reference_voltage_ / 4096.0f;
return voltage;

View file

@ -12,8 +12,6 @@ from esphome.const import (
AUTO_LOAD = ["voltage_sampler"]
DEPENDENCIES = ["i2c"]
# CONF_CONTINUOUS_MODE = "continuous_mode"
mcp3221_ns = cg.esphome_ns.namespace("mcp3221")
MCP3221Sensor = mcp3221_ns.class_(