mirror of
https://github.com/esphome/esphome-docs.git
synced 2025-03-20 15:00:06 +01:00
add SPI support to ADE7953 (#3217)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
9464776bc1
commit
ad5c46bc8c
@ -15,7 +15,7 @@ ADE7953 Power Sensor
|
||||
|
||||
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.
|
||||
with ESPHome. These are commonly found in **Shelly** devices.
|
||||
|
||||
This sensor can measure voltage and has two channels for reading current and active power (A & B).
|
||||
|
||||
@ -23,42 +23,235 @@ This sensor can measure voltage and has two channels for reading current and act
|
||||
|
||||
SAFETY HAZARD: Some devices such as Sonoff POWs/Shelly/etc, have the digital GND connected directly to mains voltage so **the GPIOs become LIVE during normal operation**. Our advice is to mark these boards to prevent any use of the dangerous digital pins.
|
||||
|
||||
The :ref:`I²C Bus <i2c>` is
|
||||
required to be set up in your configuration for this sensor to work.
|
||||
The :ref:`I²C Bus <i2c>`
|
||||
or :ref:`SPI Bus <spi>`
|
||||
is required to be set up in your configuration for this sensor to work.
|
||||
|
||||
Over I²C
|
||||
--------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
# Example configuration entry for i2c
|
||||
sensor:
|
||||
- platform: ade7953
|
||||
- platform: ade7953_i2c
|
||||
irq_pin: GPIO16
|
||||
voltage:
|
||||
name: ADE7953 Voltage
|
||||
frequency:
|
||||
name: ADE7953 Frequency
|
||||
current_a:
|
||||
name: ADE7953 Current A
|
||||
current_b:
|
||||
name: ADE7953 Current B
|
||||
power_factor_a:
|
||||
name: "ADE7953 Power Factor A"
|
||||
power_factor_b:
|
||||
name: "ADE7953 Power Factor B"
|
||||
apparent_power_a:
|
||||
name: "ADE7953 Apparent Power A"
|
||||
apparent_power_b:
|
||||
name: "ADE7953 Apparent Power B"
|
||||
active_power_a:
|
||||
name: ADE7953 Active Power A
|
||||
active_power_b:
|
||||
name: ADE7953 Active Power B
|
||||
update_interval: 60s
|
||||
reactive_power_a:
|
||||
name: "ADE7953 Reactive Power A"
|
||||
reactive_power_b:
|
||||
name: "ADE7953 Reactive Power B"
|
||||
|
||||
Configuration variables:
|
||||
------------------------
|
||||
************************
|
||||
|
||||
- **address** (*Optional*, int): Manually specify the I²C address of the sensor. Defaults to ``0x38``.
|
||||
- **irq_pin** (*Optional*, :ref:`config-pin`): The pin connected to the ADE7935 IRQ line (if connected)
|
||||
- **voltage** (*Optional*): Use the voltage value of the sensor in volt. All options from
|
||||
- **voltage** (*Optional*): Use the voltage value of the sensor in volts. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **frequency** (*Optional*): Use the frequency value of the sensor in hertzs. 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>`.
|
||||
- **power_factor_a** (*Optional*): Use the power factor of the A channel in percentage. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **power_factor_b** (*Optional*): Use the power factor of the B channel in percentage. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **aparent_power_a** (*Optional*): Use the apparent power value of the A channel in volt ampers. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **aparent_power_b** (*Optional*): Use the apparent power value of the B channel in volt ampers. 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 B channel in watts. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **reactive_power_a** (*Optional*): Use the rective power value of the A channel in volt ampers. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **reactive_power_b** (*Optional*): Use the rective power value of the B channel in volt ampers. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **voltage_pga_gain** (*Optional*, mapping): Set the input PGA voltage amplification. Defaults to ``1x``. Possible values are:
|
||||
|
||||
- ``1x``
|
||||
- ``2x``
|
||||
- ``4x``
|
||||
- ``8x``
|
||||
- ``16x``
|
||||
- ``22x``
|
||||
|
||||
- **current_pga_gain_a** (*Optional*, mapping): Set the input PGA current amplification of the A channel. Defaults to ``1x``. Possible values are:
|
||||
|
||||
- ``1x``
|
||||
- ``2x``
|
||||
- ``4x``
|
||||
- ``8x``
|
||||
- ``16x``
|
||||
- ``22x``
|
||||
|
||||
- **current_pga_gain_b** (*Optional*, mapping): Set input PGA current amplification of the B channel. Defaults to ``1x``. Possible values are:
|
||||
|
||||
- ``1x``
|
||||
- ``2x``
|
||||
- ``4x``
|
||||
- ``8x``
|
||||
- ``16x``
|
||||
|
||||
- **voltage_gain** (*Optional*, int): Set the voltage amplification. Defaults to ``0x400000``.
|
||||
- **current_gain_a** (*Optional*, int): Set the current amplification of the A channel. Defaults to ``0x400000``.
|
||||
- **current_gain_b** (*Optional*, int): Set the current amplification of the B channel. Defaults to ``0x400000``.
|
||||
- **active_power_gain_a** (*Optional*, int): Set the active power amplification of the A channel. Defaults to ``0x400000``.
|
||||
- **active_power_gain_b** (*Optional*, int): Set the active power amplification of the B channel. Defaults to ``0x400000``.
|
||||
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
|
||||
|
||||
Over SPI
|
||||
--------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Example configuration entry for SPI (taken from a Shelly Pro 4PM)
|
||||
sensor:
|
||||
- platform: ade7953_spi
|
||||
cs_pin: GPIO04
|
||||
irq_pin: GPIO35
|
||||
current_pga_gain_a: 2x
|
||||
current_pga_gain_b: 2x
|
||||
current_gain_a: 0x600000
|
||||
current_gain_b: 0x600000
|
||||
voltage:
|
||||
name: "Voltage"
|
||||
filters:
|
||||
- delta: 1
|
||||
frequency:
|
||||
name: ADE7953 Frequency
|
||||
filters:
|
||||
- delta: 0.1
|
||||
current_a:
|
||||
name: "Current A"
|
||||
filters:
|
||||
- delta: 0.01
|
||||
current_b:
|
||||
name: "Current B"
|
||||
filters:
|
||||
- delta: 0.01
|
||||
power_factor_a:
|
||||
name: "Power Factor A"
|
||||
filters:
|
||||
- delta: 5
|
||||
power_factor_b:
|
||||
name: "ADE7953 Power Factor B"
|
||||
filters:
|
||||
- delta: 5
|
||||
apparent_power_a:
|
||||
name: "Apparent Power A"
|
||||
filters:
|
||||
- delta: 1
|
||||
apparent_power_b:
|
||||
name: "Apparent Power B"
|
||||
filters:
|
||||
- delta: 1
|
||||
active_power_a:
|
||||
name: "Power A"
|
||||
id: active_power_1
|
||||
# active_power is inverted, so multiply by -1
|
||||
filters:
|
||||
- multiply: -1
|
||||
- delta: 1
|
||||
active_power_b:
|
||||
name: "Power B"
|
||||
id: active_power_2
|
||||
# active_power is inverted, so multiply by -1
|
||||
filters:
|
||||
- multiply: -1
|
||||
- delta: 1
|
||||
reactive_power_a:
|
||||
name: "Reactive Power A"
|
||||
filters:
|
||||
- delta: 1
|
||||
reactive_power_b:
|
||||
name: "Reactive Power B"
|
||||
filters:
|
||||
- delta: 1
|
||||
|
||||
Configuration variables:
|
||||
************************
|
||||
|
||||
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The chip select pin.
|
||||
- **irq_pin** (*Optional*, :ref:`config-pin`): The pin connected to the ADE7935 IRQ line (if connected)
|
||||
- **voltage** (*Optional*): Use the voltage value of the sensor in volts. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **frequency** (*Optional*): Use the frequency value of the sensor in hertzs. 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>`.
|
||||
- **power_factor_a** (*Optional*): Use the power factor of the A channel in percentage. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **power_factor_b** (*Optional*): Use the power factor of the B channel in percentage. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **aparent_power_a** (*Optional*): Use the apparent power value of the A channel in volt ampers. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **aparent_power_b** (*Optional*): Use the apparent power value of the B channel in volt ampers. 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 B channel in watts. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **reactive_power_a** (*Optional*): Use the rective power value of the A channel in volt ampers. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **reactive_power_b** (*Optional*): Use the rective power value of the B channel in volt ampers. All options from
|
||||
:ref:`Sensor <config-sensor>`.
|
||||
- **voltage_pga_gain** (*Optional*, mapping): Set the input PGA voltage amplification. Defaults to ``1x``. Possible values are:
|
||||
|
||||
- ``1x``
|
||||
- ``2x``
|
||||
- ``4x``
|
||||
- ``8x``
|
||||
- ``16x``
|
||||
- ``22x``
|
||||
|
||||
- **current_pga_gain_a** (*Optional*, mapping): Set the input PGA current amplification of the A channel. Defaults to ``1x``. Possible values are:
|
||||
|
||||
- ``1x``
|
||||
- ``2x``
|
||||
- ``4x``
|
||||
- ``8x``
|
||||
- ``16x``
|
||||
- ``22x``
|
||||
|
||||
- **current_pga_gain_b** (*Optional*, mapping): Set input PGA current amplification of the B channel. Defaults to ``1x``. Possible values are:
|
||||
|
||||
- ``1x``
|
||||
- ``2x``
|
||||
- ``4x``
|
||||
- ``8x``
|
||||
- ``16x``
|
||||
|
||||
- **voltage_gain** (*Optional*, int): Set the voltage amplification. Defaults to ``0x400000``.
|
||||
- **current_gain_a** (*Optional*, int): Set the current amplification of the A channel. Defaults to ``0x400000``.
|
||||
- **current_gain_b** (*Optional*, int): Set the current amplification of the B channel. Defaults to ``0x400000``.
|
||||
- **active_power_gain_a** (*Optional*, int): Set the active power amplification of the A channel. Defaults to ``0x400000``.
|
||||
- **active_power_gain_b** (*Optional*, int): Set the active power amplification of the B channel. Defaults to ``0x400000``.
|
||||
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
|
||||
|
||||
Use with Shelly 2.5
|
||||
@ -84,7 +277,7 @@ Additionally, the device has an ::doc:`NTC temperature sensor <ntc>`.
|
||||
scl: GPIO14
|
||||
|
||||
sensor:
|
||||
- platform: ade7953
|
||||
- platform: ade7953_i2c
|
||||
irq_pin: GPIO16
|
||||
voltage:
|
||||
name: Shelly Voltage
|
||||
|
Loading…
Reference in New Issue
Block a user