ADE7953 Power Sensor
====================

.. seo::
    :description: Instructions for setting up ADE7953 power sensors
    :image: ade7953.png

.. note::

    This page is incomplete and could some work. If you want to contribute, please read the
    :doc:`contributing guide </guides/contributing>`. This page is missing:

      - A complete configuration example for the Shelly 2.5
      - An image for the front page

The ``ade7953`` sensor platform allows you to use ADE7953 single phase energy metering ICs
(`datasheet <https://www.analog.com/media/en/technical-documentation/data-sheets/ADE7953.pdf>`__)
with ESPHome. These are commonly found in **Shelly 2.5** devices.

This sensor can measure voltage and has two channels for reading current and active power (A & B).

The :ref:`I²C Bus <i2c>` is
required to be set up in your configuration for this sensor to work.

.. code-block:: yaml

    # Example configuration entry
    sensor:
      - platform: ade7953
        voltage:
          name: ADE7953 Voltage
        current_a:
          name: ADE7953 Current A
        current_b:
          name: ADE7953 Current B
        active_power_a:
          name: ADE7953 Active Power A
        active_power_b:
          name: ADE7953 Active Power B
        update_interval: 60s

Configuration variables:
------------------------

- **address** (*Optional*, int): Manually specify the i^2c address of the sensor. Defaults to ``0x38``.
- **voltage** (*Optional*): Use the voltage value of the sensor in volt. All options from
  :ref:`Sensor <config-sensor>`.
- **current_a** (*Optional*): Use the current value of the A channel in amperes. All options from
  :ref:`Sensor <config-sensor>`.
- **current_b** (*Optional*): Use the current value of the B channel in amperes. All options from
  :ref:`Sensor <config-sensor>`.
- **active_power_a** (*Optional*): Use the power value of the A channel in watts. All options from
  :ref:`Sensor <config-sensor>`.
- **active_power_b** (*Optional*): Use the power value of the A channel in watts. All options from
  :ref:`Sensor <config-sensor>`.
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.

Use with Shelly 2.5
-------------------

The Shelly 2.5 device contains this sensor for power monitoring. An example config for the Shelly 2.5
is given below.

There are two oddities with the Shelly 2.5:

- First, the A and B channels are mixed up - the chip's A channel is label B on the outside and
  vice versa. Probably to make the PCB easier to manufacture.
- Secondly, due to the first point the active_power values are inverted. This is fixed by
  using a multiply filter as seen in the config below.

Additionally, the device has an ::doc:`NTC temperature sensor <ntc>`.

.. code-block:: yaml

    i2c:
      sda: GPIO12
      scl: GPIO14

    sensor:
      - platform: ade7953
        voltage:
          name: Shelly Voltage
        current_a:
          name: Shelly Current B
        current_b:
          name: Shelly Current A
        active_power_a:
          name: Shelly Active Power B
          filters:
            - multiply: -1
        active_power_b:
          name: Shelly Active Power A
          filters:
            - multiply: -1
        update_interval: 60s

      # NTC Temperature
      - platform: ntc
        sensor: temp_resistance_reading
        name: "Shelly Temperature"
        calibration:
          b_constant: 3350
          reference_resistance: 10kOhm
          reference_temperature: 298.15K
      - platform: resistance
        id: temp_resistance_reading
        sensor: temp_analog_reading
        configuration: DOWNSTREAM
        resistor: 32kOhm
      - platform: adc
        id: temp_analog_reading
        pin: A0

See Also
--------

- :ref:`sensor-filters`
- :apiref:`ade7953/ade7953.h`
- :ghedit:`Edit`