Power & Energy Monitoring System Components
Updated: 29Aug2024 19:42:12 UTC 2024-08-29T19:42:12Z
Rating: (0 reviewsThis article has not been rated yet)
A power and energy monitoring system can record and display the voltage, current, power, and total energy consumption of electronic devices, appliances, and mains electricity.
The basic components of a power and energy monitoring system consists of a power sensor, microcontroller (MCUMicrocontroller Unit), wireless transceiver (RFRadio Frequency or WiFi), and a computer. An additional option would be to include a sensor status indicator (e.g., LEDLight Emitting Diodes, LCDLiquid Crystal Display, or other visual display) near the sensor to visually indicate if the sensor is operational and interacting with the microcontroller.
The power sensor can output either an analog or digital signal that is read by a microcontroller where the embedded software responds by sending a wireless signal over WiFi (LANLocal Area Network) or RF to a gateway computer to record the data.
Having measurements recorded on a computer allows the data to be analyzed, displayed on a dashboard in real-time, and provides the capability of setting up alert notifications remotely by phone texts and/or email.
This overview of power and energy monitoring system components covers sensors, microcontrollers, transceivers, communication, and computer hardware and software.
Input Signals
Direct Current (DC) and Alternating Current (AC) are two main types of input signals that are have their own properties and are measured by two different types of power sensors.
DC Signals
Direct Current (DC) signals are defined as a one directional flow of current in a circuit. A DC signal has only one electrical polarity of voltage and current, which are either constant, zero frequency, or variable with a slowly varying local mean value. Three examples of DC signals are shown in the figure below.
AC Signals
Alternating Current (AC) signals are defined by a current flow that changes direction periodically. The voltage and current in an AC signal changes polarity and can be out of phase. The most basic type of AC signal is a sinusoidal waveform shown in the figure below.
An AC signal is characterized by its amplitude, period, frequency, phase, and DC offset.
- Amplitude:
- The height of the signal from a reference level such as zero.
- Period:
- The amount of time (T) the signal completes one cycle.
- Frequency:
- The number of repetitions (cycles) that occur in a specified amount of time, expressed in cycles/second or Hertz (Hz). A signal's frequency (f) is inversely related its period: f = 1/T.
- Phase:
- The amount of horizontal shift relative to time zero, usually expressed in degrees or radians. A phase shift of 360 degrees (or 2π radians) gives the same wave with no shift.
- DC Offset:
- The amount of vertical shift in the waveform, where the waveform has DC and AC components as shown in the figure below.
Sensors
In order to determine the energy consumed by an electrical circuit, the voltage and current needs to be measured continuously over time. This can be done with a separate voltage sensor and current sensor, but power sensors have the capability of sensing and synchronizing both measurements on the same board.
Electrical power is the "rate" at which energy is consumed (or transferred) in a circuit and computed by the product of voltage and current measurements. The SIThe International System of Units (SI) is the modern form of the metric system and the world's most widely used system of measurement employed in science, technology, industry, and everyday commerce. unit of electrical power is a Watt, equal to 1 Joule per second (J/s). A Kilowatt (kW) is 1000 Watts.
The total energy consumed (or transferred) is computed by integrating the power over time and often expressed in units of kilowatt-hours (kWh) for electric utilities. For battery applications specified in amp-hours (Ah), the total energy in kWh is determined by multiplying the number of amp-hours by the battery voltage and dividing by 1000.
Power Sensor Input
DC or AC Input
Different power sensors are used for DCDirect Current and ACAlternating Current circuits. In a DC circuit with a constant voltage and current, the power is also constant from the product of voltage and current. In an AC circuit, the voltage and current are both varying, changing direction, and can be out of phase, so the instantaneous power as the product of the two is also changing.
The voltage, current, and power measured from the AC power sensors discussed here is actually the RMSRoot Mean Square voltage, RMS current, and average active power (also known as real power). RMS stands for Root-Mean-Square that is computed by taking the square root of the mean of the values squared. The active power is computed using the RMS voltage, RMS current, and phase angle difference between the voltage and current sinusoidal waveforms. The total energy reported by AC power sensors is from integrating the instantaneous power over time.
Interfacing Inputs
Power sensor inputs are connected between the device and power source. Many devices that operate on DC power are plugged into an outlet with an AC to DC converter that is internal or external (e.g., wall wart). There are a couple issues to consider.
- If DC power measurements are made on the power line coming from the wall wart, then the power dissipation by the wall wart will be unaccounted for (which may be desired).
- To measure DC power the sensor probes need a bare connection, so you may have to either splice the DC power line from a wall wart, open the device and tap inside the circuit, or create a DC inline interface box with the appropriate I/OInput/Output jacks (USB, 5.5mm ODOuter Diameter / 2.1mm IDInner Diameter barrel jack, etc.).
One benefit of AC power monitoring is the use of standardized plugs per region, where you can create an interface junction box with outlets on both sides that can accommodate different devices and appliances.
Power Sensor Output
All of the power sensors discussed here output a digital signal (e.g., I2CInter-Integrated Circuit. Also referred to as IIC or I2C., TTLTransistor-Transistor Logic, or RS485RS485 (or RS-485) is a standard defining the electrical characteristics of serial lines for serial communications systems. It allows multiple 485 devices on the same bus and adopts a balanced transmission and differential reception with the ability to suppress common mode interference.) that can be read in by a microcontroller. Internally they can measure high input voltage and current levels with circuitry that drops their levels down to make it suitable for logic devices to processes and output the signal.
DC Power Sensors
The DC power consumed by a load can be obtained by measuring the bus voltage and current across a load. The bus voltage is often measured directly from the load power supply to ground.
The most common way power sensors measure DC current is to convert it into a voltage by inserting a precision shunt resistor within the circuit in series with the load. The shunt resistor creates a voltage across it that is proportional to the current flow. The shunt resistance is often very low, on the order of milliohms, so it does not steal voltage from the load or affect the current flow being measured. This means the voltage across the shunt resistor is also quite small, and often requires amplification before being converted by an ADCAnalog-to-Digital Converter (ADC, A/D, or A-to-D).
There are two ways the shunt resistor can be placed in series with the load, called low-side sensing or high-side sensing. In low-side sensing, the shunt resistor (RS) is placed after the load and to the ground terminal of the power supply as shown in the figure below.
In high-side sensing, the shunt resistor is placed between the positive terminal of the power supply and the supply input of the load as shown in the figure below.
Low-side sensing is preferred for measuring current in applications with very high voltages/current or where the supply voltage may be prone to spikes or surges. One disadvantage of low-side sensing is its inability to detect ground faults (a short to ground) within the load. Another problem with low-side sensing is ground loop issues that can result in noise and interference, due to the shunt resistor placed between the load and ground where the load may not be at the exact same ground potential as the rest of the circuitry.
Different DC power modules are listed below with low-side sensing, high-side sensing, or both.
Model | Voltage Measurement |
Current Measurement |
Output |
---|---|---|---|
INA219 | 0V to 26V |
0 to 3.2A
0.1Ω 1% Shunt High Side |
I2C |
INA226 | 0V to 36V |
0 to 0.8A
0.1Ω 1% Shunt High/Low Side |
I2C |
INA260 | 0V to 36V |
Up to 15A
2mΩ 0.1% Internal Shunt High/Low Side |
I2C |
INA3221 | 0V to 26V |
Up to 1.6A
0.1Ω 1% Shunt High Side |
I2C |
MAX471 | 3V to 36V |
Up to 3A
35mΩ 1% Internal Shunt High Side |
Analog |
PZEM-003 | 0.05V to 300V |
0.01 to 10A
1mΩ 1% Internal Shunt Low Side |
2-Wire RS485 |
PZEM-017 | 0.05V to 300V |
0.02A to 300A
50A/100A/200A External Shunt Low Side |
2-Wire RS485 |
AC Power Sensors
The PZEM AC power sensor modules in this section can be used on mains electricity to measure single-phase RMSRoot Mean Square voltage, RMS current, active power, power factor, frequency, and active energy consumption.
The PZEM modules have an onboard single-phase V9881D SoCSystem On a Chip from Vango with an 8052 MCUMicrocontroller Unit core and serial output (9600 buad rate). The V9881D makes instantaneous voltage and current measurements with internal ADCAnalog-to-Digital Converter (ADC, A/D, or A-to-D)s and computes the RMS voltage, RMS current, phase, power factor, active power, active energy accumulation, and frequency.
According to the V9881D Datasheet (PDF), in section 18.3 Metering Data Registers, the update time for power samples can take up to 100ms (10SPSSamples Per Second). These samples are cached and then read out serially (TXTransmit, RXReceive) by the 8052 MCU when a request is made by the user, which also has some overhead.
The firmware on the 8052 MCU for the PZEM modules does not provide full access to the registers of the V9881D, but only RMS voltage, RMS current, active power, power factor, frequency, and active energy consumption.
The figure below shows how to make power measurements with the PZEM sensor on a load that uses an AC outlet as the power source. A microcontroller is used to read serial data from the sensor over the (TX, RX) lines.
- Voltage Measurement:
- The voltage is measured from the power hot line (L) and return Neutral (N) using an internal resistor divider or step down transformer in the sensor.
- Current Measurement:
- The current is measured by a shunt resistor for lower currents or a current transformer (CTCurrent Transformer) for higher currents. Greater accuracy is obtained with a shunt resistor at the cost of a limited range of current that can be measured. The convenience of a split core current transformer is that it can be clamped onto the current carrying wire without breaking the circuit.
- Power Factor:
-
The power factor in AC circuits relates the apparent power (the product of the RMS current and RMS
voltage) to the active power absorbed by a load. The active power is the average energy rate that
represents the capacity for performing work.
The power factor typically has values between 0 and 1.0. Purely resistive circuits have a power factor of 1.0. Values lower than 1.0 occur in circuits with reactive components (i.e., capacitors, inductors) where AC voltage and current are not in phase which reduces the average product of the two. - Frequency:
- The frequency of an AC circuit is the number cycles per second, expressed as HZ, that quantifies how often an AC voltage or current wave repeats itself. For mains electricity, this is usually between 50Hz to 60Hz.
- Energy Consumption:
- The amount of energy an AC circuit load consumes from a power source is computed by integrating the power over time as an accumulation sum. Energy consumption is often expressed in units of kilowatt-hours (kWh) for electric utilities.
There are different AC power modules available with their own capabilities and measurement ranges. The input current measurement range depends on whether a shunt resistor or current transformer is used, where more accuracy is obtained with a shunt resistor at the cost of a limited range of current that can be measured.
The output of these devices is a digital signal (TTL) that is converted to USB signal with an TTL to USB adapter so a computer can read and display the data. The PZEM modules have their own PCPersonal Computer software that displays the measurements in real-time, however the communication protocol is ModbusModbus or MODBUS is a client-server serial data communications protocol. A Modbus message contains a destination address, a command (e.g., read/write register), the data, and a check sum (LRC or CRC). which can be read in by any programming language with a library that interprets Modbus (e.g., MinimalModbus and PyModbus libraries are available in Python).
Model | Voltage Measurement |
Current Measurement |
Power Factor | Frequency | Output |
---|---|---|---|---|---|
PZEM-004T-10A | 80V to 260V AC RMS |
0 to 10A
1mΩ Internal Shunt Low Side |
0 to 1.00 | 45Hz to 65Hz |
2-Wire
UART TTL |
PZEM-004T-100A | 80V to 260V AC RMS |
0 to 100A
External CTCurrent Transformer |
0 to 1.00 | 45Hz to 65Hz |
2-Wire
UART TTL |
PZEM-014 | 80V to 260V AC RMS |
0 to 10A
1mΩ Internal Shunt Low Side |
0 to 1.00 | 45Hz to 65Hz |
2-Wire
TTL to USB |
PZEM-016 | 80V to 260V AC RMS |
0 to 100A
External CTCurrent Transformer |
0 to 1.00 | 45Hz to 65Hz |
2-Wire
TTL to USB |
MCU & Transceiver
The output signals from the power sensors discussed here all have low data rates (around 5 - 20 SPSSamples Per Second), so you don't need a high end microcontroller for processing the data. A low speed microcontroller with a UART and I2C communication ports and small size will do the job, such as any of the options listed below.
A transmitter and receiver (or both combined in a transceiver) is needed for wireless communication. Many microcontroller boards have a WiFi transceiver integrated into the board, which would be the simplest setup.
Alternatively, you could connect an external WiFi module to the serial port of the microcontroller to establish a WiFi connection.
Another option is to use an RFRadio Frequency transceiver module to transmit data to the computer. Using RF modules would require more hardware compared to WiFi, since most computers already have WiFi, but RF modules generally have greater range, less power consumption, and are less prone to interference and/or traffic over your WiFi network.
You would need at least two RF modules, a transmitter connected to the microcontroller at the sensor and a receiver connected to the computer. RF modules transfer data to a computer over a UARTUniversal Asynchronous Receiver-Transmitter or SPISerial Peripheral Interface interface, which most SBCSingle Board Computers have, but if the computer does not have this interface then a conversion to USB with a microcontroller or USB Serial Adapter can be used.
Communication
When designing a monitoring system where a power sensor and microcontroller communicates with a computer or other device, some requirements need to be established on what data content will be exchanged and when that data is sent. Some things to consider are the following:
- Data transmission and communication failures
- Control of the measurement sampling rate
- Sensor health status
- Disabling/Enabling sensors remotely
Data Transmission
Measurements from the power sensors can be transmitted immediately when they occur so you can monitor and be alerted in real-time. If the communication fails, the data can be stored in the microcontroller memory temporarily while it continues trying to send the message until it is received. When the communication is successful, the record in the microcontroller memory can be cleared.
Measurement Sampling Rate
The power sensors discussed here have sampling rates up to 10 - 20 SPS. However, sending this high of a message rate to the computer may be too much for the monitoring system software. If you really want to capture that much data, one solution is to combine multiple power sensor readings into a single message on the microcontroller to reduce the message rate. Another option is to reduce the amount of data sent by averaging the measurements on the microcontroller before transmission.
The sampling rate and/or number of samples averaged should be controllable from the computer so you can change it without reloading the embedded software on each microcontroller connected to the sensors. This means the embedded software on each microcontroller should include the capability of accepting commands from the computer to adjust the sensor sampling rate.
Sensor Health Status
If your sensor or microcontroller stopped running for some reason, you would have no way of knowing without some kind of periodic operational health status check. If the sensor and microcontroller is powered from a battery or has a backup battery, then the battery level should also be checked periodically.
How often the health status should be sent depends on your sensor and microcontroller power consumption requirements: more frequent status checks will consumes more power. You can setup the microcontroller to send the status over regular intervals like a beacon or you can ping the microcontroller from the computer or other device.
One advantage of the beacon approach it can provide a status over smaller time intervals (e.g., every second) if power consumption is not an issue. The advantage of pinging the microcontroller status from the computer is when and who to ping can easily be adjustable in the computer program for all your sensors, which avoids sensor transmission collisions when you have multiple sensors sending their status at the same time.
Disabling/Enabling Sensors
There are circumstances where you would want to temporarily disable a sensor from the computer or remotely, such as when making adjustments to the sensor or system. The embedded software in the microcontroller can be setup to accept a wireless command that would turn off sensor readings until another command is received to turn it back on.
Computer
The computer receives data from all the power sensors from a WiFi or RF receiver, reads in the data with a software interface, records the data, and can display the results on a monitor with some kind of dashboard.
If you don't have a computer available, it's worth mentioning that some WiFi microcontrollers, such as the ESP32 and the RPi Pico W, can also have a web server on them to create a web page displaying sensor results to your devices (phone, computer, tablet) over your network. Storing data on the microcontroller is limited, but you could store more data on an external SD card with a module or a USB flash drive with a USB host board.
Hardware
The computer hardware constantly monitors for any transmissions of power sensor data and records the data. This means that the computer needs to be on 24/7. A desktop computer will work if left on all the time, but are often used heavily on a daily basis which may be an issue sharing resources and updating the operating system constantly would interrupt your monitoring system.
Single Board Computers (SBCSingle Board Computers) are relatively inexpensive compared to desktop or laptop computers, have a small form factor, can be left on all the time, don't require as many updates, and are typically not used for daily activities as much as a desktop computer. SBCs also consume a lot less power than a desktop computer and can last much longer on battery backup in the event of a power outage.
Software
The computer software can be designed to continuously read in the transmitted power sensor data, record the data, and display the results. The software can also be programmed to control the behavior of the sensors, such as changing the sampling rate, turning it off/on, or setting specific time intervals to make measurements.
I/O Interface
RF Interface
For RF modules the receiver is usually connected serially to the computer. This can be done directly through a UARTUniversal Asynchronous Receiver-Transmitter or SPISerial Peripheral Interface interface on the GPIOGeneral Purpose Input Output of a SBC or through USB with a microcontroller or USB Serial Adapter. To collect data from the UART/SPI/USB port on the computer you can use the Python PySerial software interface. The functionality of this interface is described in more detail in the article Python PySerial I/O.
WiFi Interface
For WiFi communication, the software interface could be a TCP socket connection or a client-server configuration with the use of a standard protocol, such as HTTPHypertext Transfer Protocol, WebSocketWebSocket is a communication protocol, providing simultaneous two-way communication channels over a single Transmission Control Protocol (TCP) connection. WebSockets are typically run from a web browser connected to an application server that allows messages to be passed back and forth while keeping the connection open., or MQTTMQ Telemetry Transport (MQTT) is a lightweight publish-subscribe messaging protocol for small sensors and mobile devices, optimized for high-latency or unreliable networks. Historically, the "MQ" in "MQTT" came from the IBM MQ (then 'MQSeries') product line, where it stands for "Message Queue". However, the protocol provides publish-and-subscribe messaging (no queues, in spite of the name)..
Power sensor data consist of short messages, but high message rates may be a concern. The power sensors discussed here have sampling rates up to 10 - 20 SPSSamples Per Second. This may be beyond the maximum message rate the system can handle, so you may need to experiment by trial and error to determine what message rate provides reliable performance.
To reduce the message rate you can combine multiple power sensor readings into a single message on the microcontroller. Another option is to average measurements on the microcontroller before transmission.
Graphical Interface
The user interface can be a desktop application GUIGraphical User Interface or web server developed by the programming language of your choice (Python, C++, Java, etc.). In Python, there are many desktop GUI frameworks you can use like TKinter, wxPython, PyQT, PySide 2, Kivy, PySimpleGUI, and PyGUI. All of these frameworks are cross-platform that work in Windows, macOS, and Linux. TKinter is a built-in module in Python and the easiest to get up and running and learn, has a small footprint, and is a good choice for small applications.
Another option for data monitoring is using a web page as the GUI from a server that can be ran locally or by a hosting service over the internet. The advantage of using a web page as the front end of a monitoring system is that it can be accessed remotely either by hosting it yourself using port forwarding on your local network or from a hosting service. Python has web frameworks such as Flask, FastAPI, or Django. Flask is the easiest to get setup and running (you can get set up with just a few lines of code).
An example of displaying data from power sensors is shown in the figure below. Gauge charts can be used to display the most current measurements. Time series plots can show measurements throughout the day or whatever time period you want. Monthly averages throughout the year can be shown as a bar chart.
Alert Notifications
When you are away from your computer, the server back end can include the capability of automatically sending alert notifications by email and/or text messages that you can see on your phone when any of the power sensor measurements are outside their normal range. This additional feature of your monitoring system can be setup to allow you to turn the alert notifications on/off when not needed.
In Python you can automatically send emails using the built-in smtplib module and the ssl module can provide TLSTransport Layer Security encryption. If you are using a Python web framework (Flask, FastAPI, or Django), there are extensions for these frameworks that can send the email for you. For example, Flask has the extension Flask-Mail to automatically send emails.
Text messages can be sent using services such as Twilio or Textbelt, but they can also be sent for free through your email server with SMSShort Message Service Gateways using the same routines used for sending emails.
Conclusion
Implementing a power and energy monitoring system gives you the capability recording and displaying the voltage, current, power, and total energy consumption of electronic devices, appliances, and mains electricity. The hardware in this system includes power sensors, microcontrollers, transceivers, and a computer.
Power sensors are chosen based on whether you're measuring DC or AC circuits and other requirements of the application (ease of use, accuracy, power consumption, etc.). You could also have a separate voltage sensor and current sensor, then combine the measurements to compute the power in software.
Before working on monitoring AC mains electricity that is more complicated than DC and can be a safety hazard if you don't know what you're doing, it may be best to start out simple with DC power monitoring of low voltage and current devices (e.g., 5V devices with up to a few hundred milliamps) to get the system up and running, then upgrade the system for AC mains electricity monitoring.
(0) Comments
Sign in to leave a comment
Sign In