---
url: /dyad/stable/stdlib/ElectricalComponents/components/Analog.Sensors.PowerSensor.md
description: >-
  Dyad Analog.Sensors.PowerSensor docs.  Measures the instantaneous electrical
  power flowing through or consumed by a circuit.
---

# `Analog.Sensors.PowerSensor` {#Analog.Sensors.PowerSensor}

Measures the instantaneous electrical power flowing through or consumed by a circuit.

This component utilizes an internal `VoltageSensor` and an internal `CurrentSensor` to determine electrical power. The voltage is measured between pins `pv` (positive voltage) and `nv` (negative voltage). The current is measured as it flows from pin `pc` (positive current) to pin `nc` (negative current). The instantaneous power is calculated as the product of these two measurements:

$$P = V \cdot I$$

where `V` is the voltage measured by `voltage_sensor.v` and `I` is the current measured by `current_sensor.i`.

## Usage {#Usage}

`ElectricalComponents.Analog.Sensors.PowerSensor()`

## Connectors {#Connectors}

* `pc` - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. ([`Pin`](/stdlib/Dyad/connectors/Pin#Pin))

* `nc` - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. ([`Pin`](/stdlib/Dyad/connectors/Pin#Pin))

* `pv` - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. ([`Pin`](/stdlib/Dyad/connectors/Pin#Pin))

* `nv` - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. ([`Pin`](/stdlib/Dyad/connectors/Pin#Pin))

* `power` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{power}\left( t \right) &= \mathtt{current_sensor.i}\left( t \right) ~ \mathtt{voltage_sensor.v}\left( t \right) \\
0 &= \mathrm{connect}\left( pv, voltage\_{sensor\_{+}p} \right) \\
0 &= \mathrm{connect}\left( voltage\_{sensor\_{+}n}, nv \right) \\
0 &= \mathrm{connect}\left( pc, current\_{sensor\_{+}p} \right) \\
0 &= \mathrm{connect}\left( current\_{sensor\_{+}n}, nc \right) \\
\mathtt{voltage_sensor.p.i}\left( t \right) &= 0 \\
\mathtt{voltage_sensor.n.i}\left( t \right) &= 0 \\
\mathtt{voltage_sensor.v}\left( t \right) &=  - \mathtt{voltage_sensor.n.v}\left( t \right) + \mathtt{voltage_sensor.p.v}\left( t \right) \\
\mathtt{current_sensor.p.v}\left( t \right) &= \mathtt{current_sensor.n.v}\left( t \right) \\
\mathtt{current_sensor.p.i}\left( t \right) &= \mathtt{current_sensor.i}\left( t \right) \\
\mathtt{current_sensor.n.i}\left( t \right) &=  - \mathtt{current_sensor.i}\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Measures the instantaneous electrical power flowing through or consumed by a circuit.

This component utilizes an internal `VoltageSensor` and an internal `CurrentSensor` to
determine electrical power. The voltage is measured between pins `pv` (positive voltage)
and `nv` (negative voltage). The current is measured as it flows from pin `pc`
(positive current) to pin `nc` (negative current).
The instantaneous power is calculated as the product of these two measurements:
```math
P = V \cdot I
```
where `V` is the voltage measured by `voltage_sensor.v` and `I` is the
current measured by `current_sensor.i`.
"""
component PowerSensor
  "Positive pin for current measurement path"
  pc = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
    }
  }
  "Negative pin for current measurement path"
  nc = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
    }
  }
  "Positive pin for voltage measurement"
  pv = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "pos", "x1": 450, "y1": -50, "x2": 550, "y2": 50}}
    }
  }
  "Negative pin for voltage measurement"
  nv = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "neg", "x1": 450, "y1": 950, "x2": 550, "y2": 1050}}
    }
  }
  "Internal subcomponent to measure voltage"
  voltage_sensor = ElectricalComponents.Analog.Sensors.VoltageSensor()
  "Internal subcomponent to measure current"
  current_sensor = ElectricalComponents.Analog.Sensors.CurrentSensor()
  "Output signal representing the calculated instantaneous power"
  power = RealOutput() {
    "Dyad": {
      "placement": {"icon": {"x1": 150, "y1": 950, "x2": 250, "y2": 1050, "rot": 90}}
    }
  }
relations
  connect(pv, voltage_sensor.p)
  connect(voltage_sensor.n, nv)
  connect(pc, current_sensor.p)
  connect(current_sensor.n, nc)
  power = voltage_sensor.v * current_sensor.i
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 1200, "rot": 0},
      {"label": "P", "x": 500, "y": 713, "rot": 0}
    ],
    "icons": {"default": "dyad://ElectricalComponents/PowerSensor.svg"}
  }
}
end
````

````dyad
"""
Measures the instantaneous electrical power flowing through or consumed by a circuit.

This component utilizes an internal `VoltageSensor` and an internal `CurrentSensor` to
determine electrical power. The voltage is measured between pins `pv` (positive voltage)
and `nv` (negative voltage). The current is measured as it flows from pin `pc`
(positive current) to pin `nc` (negative current).
The instantaneous power is calculated as the product of these two measurements:
```math
P = V \cdot I
```
where `V` is the voltage measured by `voltage_sensor.v` and `I` is the
current measured by `current_sensor.i`.
"""
component PowerSensor
  "Positive pin for current measurement path"
  pc = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
    }
  }
  "Negative pin for current measurement path"
  nc = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
    }
  }
  "Positive pin for voltage measurement"
  pv = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "pos", "x1": 450, "y1": -50, "x2": 550, "y2": 50}}
    }
  }
  "Negative pin for voltage measurement"
  nv = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "neg", "x1": 450, "y1": 950, "x2": 550, "y2": 1050}}
    }
  }
  "Internal subcomponent to measure voltage"
  voltage_sensor = ElectricalComponents.Analog.Sensors.VoltageSensor()
  "Internal subcomponent to measure current"
  current_sensor = ElectricalComponents.Analog.Sensors.CurrentSensor()
  "Output signal representing the calculated instantaneous power"
  power = RealOutput() {
    "Dyad": {
      "placement": {"icon": {"x1": 150, "y1": 950, "x2": 250, "y2": 1050, "rot": 90}}
    }
  }
relations
  connect(pv, voltage_sensor.p)
  connect(voltage_sensor.n, nv)
  connect(pc, current_sensor.p)
  connect(current_sensor.n, nc)
  power = voltage_sensor.v * current_sensor.i
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 1200, "rot": 0},
      {"label": "P", "x": 500, "y": 713, "rot": 0}
    ],
    "icons": {"default": "dyad://ElectricalComponents/PowerSensor.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Sensors`](Analog.Sensors.PowerSensor.md)
