From 32ce8e9bc4ad029c4efb8dae518103f9853ed6f2 Mon Sep 17 00:00:00 2001 From: Philipp Harms Date: Sat, 19 Oct 2024 04:28:10 +0200 Subject: [PATCH] fix value calculation --- esphome/components/mcp3221/mcp3221_sensor.cpp | 2 +- esphome/components/mcp3221/sensor.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/esphome/components/mcp3221/mcp3221_sensor.cpp b/esphome/components/mcp3221/mcp3221_sensor.cpp index 2164bc32ad..674be499c3 100644 --- a/esphome/components/mcp3221/mcp3221_sensor.cpp +++ b/esphome/components/mcp3221/mcp3221_sensor.cpp @@ -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; diff --git a/esphome/components/mcp3221/sensor.py b/esphome/components/mcp3221/sensor.py index a06a0676bc..c32698fdd3 100644 --- a/esphome/components/mcp3221/sensor.py +++ b/esphome/components/mcp3221/sensor.py @@ -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_(