diff --git a/components/sensor/cd74hc4067.rst b/components/sensor/cd74hc4067.rst new file mode 100644 index 000000000..5925256a4 --- /dev/null +++ b/components/sensor/cd74hc4067.rst @@ -0,0 +1,118 @@ +cd74hc4067 Analog Multiplexer +============================= + +.. seo:: + :description: Instructions for setting up cd74hc4067 Analog Multiplexer and sensors. + :image: cd74hc4067.jpg + + +The ``cd74hc4067`` Analog Multiplexer component allows you to attach up to 16 analog input sensors to a single ADC pin. +The component is used to activate the right multiplexer pin for each of the defined cd74hc4067 sensors. + +For further information about the cd74hc4067 chip see the `spec sheet `__ +and there are also some guides around like the one from `Adam Meyer `__. + +Actually, the chip is bidirectional and could also be used as output, but this is not supported by the component yet. + +First, you need to configure the component with the digital pins that control the multiplexer. +Then you need to set up a voltage sensor source (e.g. :doc:`ADC sensor `) and pass it to the cd74hc4067 sensors with the ``sensor`` option. +Each cd74hc4067 sensor is configured for one of the 16 input pins of the multiplexer. + +.. code-block:: yaml + + # Example configuration entry + cd74hc4067: + pin_s0: D0 + pin_s1: D1 + pin_s2: D2 + pin_s3: D3 + + sensor: + - platform: adc + id: adc_sensor + pin: A0 + - platform: cd74hc4067 + id: adc_0 + number: 0 + sensor: adc_sensor + - platform: cd74hc4067 + id: adc_1 + number: 1 + sensor: adc_sensor + +Component/Hub +------------- + +Configuration Variables: +************************ + +- **pin_s0** to **pin_s3** (**Required**, :ref:`config-pin`): The I/O pins connected to the S0 to S3 channel selection pins +- **delay** (*Optional*, :ref:`config-time`): A small delay duration needed for the chip to switch inputs, defaults to 2ms. + +Sensor +------ + +Configuration Variables: +************************ + +- **sensor** (**Required**, :ref:`config-id`): The source sensor to measure voltage values from, e.g. :doc:`ADC sensor `. +- **number** (*Required*, int): The number of the cd74hc4067 input pin (0-15) +- All other options from :ref:`Sensor `. + +Application Example +------------------- + +In this example, the component is used to measure the AC power output of two solar inverters to integrate them +as energy sources in `Home Assistant `__. + +For this purpose, :doc:`CT clamp sensors ` are attached on each of the sensors. +Filters are needed to calibrate the output and cut off the noise of near-zero values. +The ``adc`` and ``cd74hc4067`` sensors updates are triggered by the ``ct_clamp`` sensors and have a very high internal update frequency. + +.. code-block:: yaml + + cd74hc4067: + pin_s0: D0 + pin_s1: D1 + pin_s2: D2 + pin_s3: D3 + + sensor: + - platform: adc + id: adc_sensor + pin: A0 + update_interval: 3600s + - platform: cd74hc4067 + id: solar_1_raw + number: 0 + sensor: adc_sensor + update_interval: 3600s + - platform: cd74hc4067 + id: solar_2_raw + number: 1 + sensor: adc_sensor + update_interval: 3600s + - platform: ct_clamp + name: "SolarPower1" + sensor: solar_1_raw + update_interval: 5s + unit_of_measurement: "W" + device_class: "power" + filters: + - lambda: "return x > 0.001 ? x * 56221 : 0;" + - platform: ct_clamp + name: "SolarPower2" + sensor: solar_2_raw + update_interval: 5s + unit_of_measurement: "W" + device_class: "power" + filters: + - lambda: "return x > 0.001 ? x * 57519 : 0;" + +See Also +-------- + +- :doc:`adc` +- :doc:`ads1115` +- :doc:`ct_clamp` +- :ghedit:`Edit` diff --git a/images/cd74hc4067.jpg b/images/cd74hc4067.jpg new file mode 100644 index 000000000..0cc2ec576 Binary files /dev/null and b/images/cd74hc4067.jpg differ diff --git a/index.rst b/index.rst index b2df716c2..80a6afc77 100644 --- a/index.rst +++ b/index.rst @@ -195,6 +195,7 @@ Analogue ADC, components/sensor/adc, flash.svg, ESP internal ADS1115, components/sensor/ads1115, ads1115.jpg, 4-channel ADC + CD74HC4067, components/sensor/cd74hc4067, cd74hc4067.jpg, 16-channel analog multiplexer MCP3008, components/sensor/mcp3008, mcp3008.jpg, 8-channel ADC MCP3204, components/sensor/mcp3204, mcp3204.jpg, 4-channel ADC Resistance, components/sensor/resistance, omega.svg