How we taught a smart socket to measure power
Greetings!
We are a company Rubetek, engaged in the development of solutions for smart homes.
In this article, we will talk about how, during the development of one of the devices in our Wi-Fi line, we chose a solution for accurately measuring the power of connected electrical appliances.
Our Wi-Fi outlet
What kind of device did you do?
Rubetek Wi-Fi socket is a device designed for remote power management of connected electrical appliances with power up to 3000 watts. The outlet is controlled using the button located on the case, locally (smartphone - WiFi socket, smartphone - WiFi router - Wi-Fi socket) and remotely when the router is connected to the Internet.
The device status changes by triggering of sensors connected to the RF socket or by means of scripts pre-configured by the user.
One of the key functions of the device is to control the power consumption of the connected load.
To display the load level, the socket uses an LED indicator that changes the color of the glow in accordance with the power consumed by the load.
The device allows you to connect compatible sensors with the EV1527 protocol (433.92 MHz, ASK) RF sensors (movement, opening, water leakage, gas and smoke leakage) and create interaction scenarios between the connected devices.
In addition, the smart outlet is compatible with the Apple Homekit platform and supports management with Siri's voice assistant. Remote Homekit control over the Internet is only possible using Apple TV, but you can locally control voice from your iPhone without using Apple TV.
First attempts
At the first stage, the Z-Wave module was chosen as the basis for the future outlet (Fig. 2).
According to the terms of reference, the socket was supposed to measure the consumed electricity in single-phase circuits, in the range from 0 W to 3000 W., with an error of not more than 1%.
- To measure the current consumed by the load and the voltage at the load, a circuit was used from a dual TSV522 op amp, a current shunt and a resistive amplifier.
The first prototype on the Z-Wave module
The calculation of the active power consumed by the load was calculated by the formula:
where:
P is the active power consumed by the load.
U is the effect. voltage on the load, equal to the mains voltage
I - effect. load current strength
φ - phase shift between current and voltage at the load
- The advantages were a low input current (1 μA) and a low bias voltage (0.8 mV). The input and output signal had a voltage swing (rail-to-rail).
- The accuracy of measuring the load current with a power consumption of up to 100 W in the range from 0 to 3000 W did not suit us, and to increase it, we used two operational amplifiers operating from a common current shunt and having different amplification factors: the amplifier with a large gain worked in range from 0 W to 100 W, and the amplifier with a lower gain worked in the range from 100 W to 3000 watts.
When developing a Wi-Fi outlet, one of the main requirements was the compactness of the product, so we considered the use of several cases of amplifiers and ADCs to be irrational. In addition, the analog signal at the output of the amplifiers was very “noisy”, the level of interference did not allow us to achieve the specified error in measuring the power consumed by the load. This was especially noticeable on the amplifier, operating in the range from 0 W to 100 watts. (fig. 3).
Oscillogram from the current shunt of the ADC of the Z-Wave module at a power of 10 W load
At this stage, in order to increase the accuracy of measurements and increase the degree of integration, it was necessary to find a new solution for implementing power measurements. It was decided to abandon the Z-Wave module, due to the high cost and low performance, and op-amp. The new basis was the Wi-Fi MCU.
The rejection of Z-Wave in favor of Wi-Fi was due to the obvious advantages of the latter: the
presence of Wi-Fi in any smartphone, which allows you to directly control the outlet from the application, the ability to connect to a router to remotely control the outlet from anywhere in the world. This determined the further path of development of the line of our smart devices.
In search of a solution
The search for power measurement implementation options has led us to specialized RMS measurement chips.
We chose a relatively inexpensive RMS - STPM14A.
Prototype STPM14A module
This RMS measures active, reactive and apparent power, current values of current, voltage and frequency, supports current transformers and shunts, is characterized by low power consumption, high measurement accuracy, reliable data transmission and storage. In general, STPM14 suited us in many ways.
Block Diagram STPM14A
But there were some cons.
When using STPM14A, difficulties arose at the data processing stage: this measuring microcircuit did not have a digital output, only a frequency output, which required resources from the Wi-Fi MCU to process the frequency signal. Our Wi-Fi MCU was already loaded with a host of other functions: processing discrete signals, interacting with the server, encryption, timers, scripts. It turned out that the processing of the frequency signal was not possible to implement without consequences for the rest of the functional.
We had to return to the search for alternative solutions also because the STPM14A did not have a digital output. Having studied several options, we decided to stay on the STPM32 chip. The Wi-Fi MCU STPM32 connected via UART.
STPM32 is a mixed signal processing device. The processor consists of analog and digital units.
Analogue includes:
- two low-noise amplifiers with programmable gain and low bias;
- four 24-bit second-order delta-sigma ADCs;
- two sources of voltage reference based on the forbidden zone with independent temperature compensation;
- low drop voltage regulator;
- DC buffers.
The digital unit consists of a digital filtering stage, a hardware digital signal processor, buffer stages for input signals and serial interfaces (UART or SPI).
The STPM32 measuring microcircuit contained two channels for processing analog current and voltage signals, followed by conversion into a digital signal and a high-precision digital signal processor DSP, designed to process digitized signals in real time.
The main and most noticeable drawback, against the background of all these advantages, turned out to be that when working with small signals, at maximum gain (16x), the error in measuring current increased.
Block diagram of STPM32
How to test?
To test the performance and testing, we developed a breadboard.
And it looks like a prototype power measurement on STPM32
Testing took place at various loads with power from several units of watts to 3.5 kW. Incandescent lamps, heating elements (resistive load), fluorescent lamps and power tools (resistive-inductive load), electrical appliances with switching power supplies without a power factor corrector (resistive-capacitive load) were used as the load.
During prototyping on the debug board, we got positive results that completely satisfied us. STPM32 coped well with the task and could be used in our smart socket.
Later it became clear that the total measurement error of the device did not match the actual readings. We obtained these data by measuring indicators with several household power meters of different price categories.
To achieve the specified accuracy of measuring the load power, it was decided to calibrate serial products at the production stage. For this purpose, a special stand was designed and manufactured (Fig. 6), which contained a separate stand calibrated using the STPM32 reference power meter.
The stand had galvanic isolation from the network in order to ensure electrical safety.
Each product after assembly was connected to the contact device of the stand.
The operator launched a program that provided electrical testing of the outlet for the absence of errors during installation and firmware. In addition, the main functionality of the outlet was tested and the STPM32 was calibrated.
Calibration stand
Using the stand provided high accuracy of power measurement, manufacturability and reliability of the product.
In the process of flashing the outlet, a color palette was also laid (a proportional ratio of red, blue, and green). This color scale is used in the socket by an LED rim to display the power consumed by the load connected to the device.
What is the result?
This was our first attempt to implement such functionality. Despite the fact that we went through a lot of options, there is also a positive side to this - by experience, we decided on the necessary microcircuit for work, having studied the pros and cons of all samples.
Our Wi-Fi outlet, having the opportunity to measure power, from a conventional device that can remotely control power supply, has turned into a smart device that greatly simplifies the life of the user.
There is still a lot of work ahead, above we mentioned a whole Wi-Fi line, which is being developed right now. In addition to a power outlet, for example, a control module is already available for purchase. Many other smart devices are getting ready.
We will certainly tell about them in the following articles.