Mcp3204 docs (#1712)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
rsumner 2022-01-09 17:04:58 -06:00 committed by GitHub
parent ecdb160f56
commit 6844b41ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,81 @@
MCP3204 4-Channel 12-Bit A/D Converter
======================================
.. seo::
:description: Instructions for setting up MCP3204 12-Bit Analog to Digital Converter in ESPHome.
:keywords: MCP3204
:image: mcp3204.jpg
The Microchip Technology Inc. MCP3204
devices are successive approximation 12-bit Analog-to-Digital (A/D) converters with on-board sample and
hold circuitry.
.. figure:: images/mcp3204.jpg
:align: center
:width: 50.0%
.. _mcp3204-component:
Component/Hub
-------------
The MCP3204 component allows you to use MCP3204 4-Channel 12-Bit A/D Converter
(`datasheet <https://ww1.microchip.com/downloads/en/DeviceDoc/21298e.pdf>`__) in ESPHome.
It uses the :ref:`SPI Bus <spi>` for communication.
Once configured, you can use any of the 4 pins as
sensors for your projects.
Each pin will respond with a voltage calculated off of the ``reference_voltage`` (default is 3.3V).
It calculates the voltage by multiplying the ``reference_voltage * value`` on the pin (basically the percentage of VREF)
Most configurations will set the ``reference_voltage`` = VREF (pin 13 on the chip)
.. code-block:: yaml
# Example configuration entry
mcp3204:
cs_pin: GPIO15
reference_voltage: 3.3V
# Example config of sensors.
# This is a small 1.5v solar panel power rail attached to pin 0
# of the MCP3204
sensor:
- platform: mcp3204 # Attached to pin 0 of the MCP3204.
update_interval: 1s
id: solar_voltage
number: 0 # MCP3204 pin number
Configuration variables:
************************
- **id** (**Required**, :ref:`config-id`): The id to use for this MCP3204 component.
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The SPI cable select pin to use.
- **reference_voltage** (*Optional*, float): The reference voltage. Defaults to ``3.3V``.
Sensor
------
The ``mcp3204`` sensor allows you to use your MCP3204 12-Bit A/D Converter sensors with ESPHome.
First, setup a :ref:`MCP3204 Hub <mcp3204-component>` for your MCP3204 sensor and then use this
sensor platform to create individual sensors that will report the voltage to Home Assistant.
Configuration variables:
************************
- **mcp3204_id** (**Required**, :ref:`config-id`): The id of the parent MCP3204 component.
- **name** (**Required**, string): The name of the voltage sensor.
- **number** (**Required**, int): The pin number of the MCP3204
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
See Also
--------
- :ref:`spi`
- :apiref:`mcp3204/mcp3204.h`
- :ghedit:`Edit`

BIN
images/mcp3204.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -196,6 +196,7 @@ Analogue
ADC, components/sensor/adc, flash.svg, ESP internal
ADS1115, components/sensor/ads1115, ads1115.jpg, 4-channel ADC
MCP3008, components/sensor/mcp3008, mcp3008.jpg, 8-channel ADC
MCP3204, components/sensor/mcp3204, mcp3204.jpg, 4-channel ADC
Resistance, components/sensor/resistance, omega.svg