Introduction: Sen6-PDU: a Smart Power Distribution Unit

In most cases, when we talk about a PDU we generally mean a box that can power multiple devices at the same time from a single power source. A sort of "multi-socket" with the only advantage of concentrating the cables towards the same source.

This is not the case. 

A friend of mine and I were in the need of a programmable system, equipped with at least 12 sockets that can be individually controlled remotely, which can be integrated into the existing Home Automation system (Node Red) with an indication of the total energy drained by the connected devices. The unit will have to manage an existing multimedia installation and other appliances (audio ampifiers, HDMI matrix, TV-SAT decoders, fans, audio player, etc.)

This is how the Sen6-PDU project was born.

Supplies

Step 1: The Box

We first started looking for a suitable box. The idea was to find an economical PDU in which to install our project, removing the components, but the main limitation was that we needed 12 separate outlets and no commercial box seemed to be right for us. Additionally, cheap commercial PDUs typically didn't have enough internal space to house all of our components.


At that point the most drastic decision was: let's go to a blacksmith and have it custom built!

The pictures show the newly made box, made of sheet metal, and subsequently painted.

Step 2: The "smart" Thing

The main requirement of the project was to make the 12 sockets individually controllable and integrated into the existing Home Automation system, managed by Node Red. Therefore, the most efficient solution seemed to be the MQTT protocol, while as regards the hardware the choice fell on an ESP32 microcontroller, with WiFi connection capability. The ESP32 was also well suited to the high number (12) of control channels needed. It has a total of 36 GPIO pins that can be used for various purposes, including interfacing with sensors, controlling relays and communicating with other devices. We opted to a model with an external antenna connector on the board, as the ESP32 had to be installed in a closed metallic box, therefore we could not know if the sensitivity of the internal antenna was enough to connect to the nearest AP.

Instead of developing a specific control software, we preferred to install the Tasmota-32 firmware in the device. This is because Tasmota provides the stability, updateability and configurability we needed to handle the whole project. It deploy a full MQTT communication for any command available and reports, through a configurable telemetry, all sensors data.

To manage the outlets we chose to use three 4-channels, opto-isolated relay modules. Each relay is capable of driving a device up to 10A at 220v, so the electrical sizing of the system had to take this data into account. This makes the project really scalable: installing more or less relays modules, you can customize the total sockets to your best needs.

Step 3: Energy Monitoring

Once we had the full project designed on schematics, we asked ourselves: "Why not report the total energy consumption too?". Energy monitoring for the whole load on all the sockets would have been an useful information. After a quick search, the choice fell on the module PZEM-004T: it is capable of measuring four interrelated electrical variables as voltage, current, power, and energy with an accuracy of 0.5%. The sensor is composed of a Current Transformer that detects the parameters and a tiny electronic board which communicates with the ESP32 by means of a TTL Serial Communication in the RX/TX pins. The board is electrically isolated from the AC channel by means of 2 opto-isolators.

As the sensor is designed to work with 5v, but the ESP32 GPIOs can handle only up to 3.3v, we had to lower the resistance of a resistor on the board in order to power it with 3.3v, as it defines the current through the light emitter of the opto-isolator.

The PZEM-004T is also compatible with Tasmota firmware, so we closed the circle.

Step 4: Schematics and Configuration

Although it may appear complex, the schematic is real straighforward. The power supply is a 220-12v switching unit, which directly powers the 3 relay modules. A step-down converter is installed to power the ESP32 and the PMEZ-004T.

The ESP32 configuration is shown in the pictures: 12 GPIOs are directly connected to the respective relay modules inputs, while TX and RX are inversely connected to RX and TX of the PZEM-004T. The configuration of the ESP32 was then completed with the assignment of the MQTT broker address. 

Step 5: Home Automation

In the picture there is a screenshot of a partial Node Red implementation for the PDU. In addition to the 12 switches to directly control the sockets, there are several other flows. For instance, one of them controls only a subgroup of the sockets: this is because often you don't need to switch ON/OFF the whole 12 outlets at once, instead you can define one or more groups (i.e.: audio rack, video devices, etc) to be operated individually.

Another flow takes care of a specific device which has its own power on procedure (i.e.: it has to be powered on only 30 seconds after a related device has been turned on). Every outlet can then be individually assigned to a scheduled ON/OFF calendar. The power of the MQTT communication protocol allows you to have an unlimited flexibility in using this smart PDU.

Step 6: Specifications

Model:                  Sen6-PDU (twelve)
Input Voltage: 100-240 VAC
Output Voltage/Current: 100-240 VAC / 10A total (or 10A on 1 socket)
Communication: WiFi 2Ghz
Network protocols: TCP/MQTT
Sockets: 12
Dimensions: 250x500x60 mm
Monitoring: Individual output monitoring and control - Total unit power monitoring