From 2b91c23bf3c3fcd6ec86ff86fe4a3c0ac4909bc0 Mon Sep 17 00:00:00 2001 From: RadekHvizdos <10856567+RadekHvizdos@users.noreply.github.com> Date: Sun, 10 Apr 2022 22:44:11 +0200 Subject: [PATCH] Extend mcp3204 to support 8 channels (mcp3208 variant) (#3332) --- esphome/components/mcp3204/mcp3204.cpp | 2 +- esphome/components/mcp3204/sensor/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mcp3204/mcp3204.cpp b/esphome/components/mcp3204/mcp3204.cpp index 44044349a3..283df4ccdc 100644 --- a/esphome/components/mcp3204/mcp3204.cpp +++ b/esphome/components/mcp3204/mcp3204.cpp @@ -20,7 +20,7 @@ void MCP3204::dump_config() { } float MCP3204::read_data(uint8_t pin) { - uint8_t adc_primary_config = 0b00000110 & 0b00000111; + uint8_t adc_primary_config = 0b00000110 | (pin >> 2); uint8_t adc_secondary_config = pin << 6; this->enable(); this->transfer_byte(adc_primary_config); diff --git a/esphome/components/mcp3204/sensor/__init__.py b/esphome/components/mcp3204/sensor/__init__.py index 1d8701a91e..404880d405 100644 --- a/esphome/components/mcp3204/sensor/__init__.py +++ b/esphome/components/mcp3204/sensor/__init__.py @@ -17,7 +17,7 @@ CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(MCP3204Sensor), cv.GenerateID(CONF_MCP3204_ID): cv.use_id(MCP3204), - cv.Required(CONF_NUMBER): cv.int_range(min=0, max=3), + cv.Required(CONF_NUMBER): cv.int_range(min=0, max=7), } ).extend(cv.polling_component_schema("60s"))