Measurement Electrical consumption with Ubidots Industrial & ESP32 + PZEM-004T

On this occasion I have proposed to measure the electricity consumption of my entire house to make comparative estimates with the collection of my energy bill and analyze.

On this occasion I will use the IoT platform Ubidots in its Industrial version, previously we had done tests with the educational version, but this industrial version has special features for data analysis and more visual dynamism allowing to create very dynamic dashboards.

Previous tests with Ubidots Educational: Meter PZEM-004 + ESP8266 & Platform IoT Ubidots

I will use a PeaceFair PZEM-004T meter and an ESP32 (ESP-WROOM-32) FireBeetle Modules from the DFRobot online store.

Recommendation: below you can see data in real time

Warning

Before starting, I recommend you to be very careful regarding connections or electrical assemblies, if you do not have enough knowledge of Electricity please do not try it.

Video: 1# Measurement Electrical Consumption with Ubidots Industrial & ESP32 + PZEM-004T

Create an account in Ubidots Industrial

In a few seconds I created a test account in industrial Ubidots.

Official Website: ubidots.com

Ubidots Industrial

Unlike the Educational version, the Industrial version has more features that facilitate not only the visualization of information but also the analysis and processing of data, better grouping for applications of hundreds of devices, then I will mention some of the characteristics of the platform:

  • List of table in devices: A better design to manage thousands of devices
  • Device types: It’s like a template for devices, where you define variables and properties to apply each time a new device is created
  • Device groups: Possibility of grouping devices for actions in pothole
  • Global events: Possibility of creating an event that applies to an entire group of devices
  • New dashboards: Redesigned dashboards, with date picker at the dashboard level and not at the individual widget level.
  • Dynamic dashboards: Possibility of having a device drop down by dashboard and, when changing it, all the widgets are updated.
  • Voice call alert

The industrial version would easily allow designing solutions or applications in agriculture, automated manufacturing, education, health, home automation, manufacturing processes and smart cities.




Tests Performed

The objective of these tests is to make the record of electrical consumption measurements in an uninterrupted way of my house and have an approximate reference or estimated in costs.

I simply want to compare my measurements, calculate costs and compare with local billing and really observe how much they consume the appliances and in the process generate a bit of awareness in the process.

The cost of kilowatt-hour in my city or zone is in my case $ 514 COP or 0.16 USD approximately, for now I will simply multiply the $ 514 COP for the kWh of the meter, later I could calculate the cost hour by hour, day, week and month.

You have to be realistic a house does not consume too much compared to the industry where this application would have good results, with industrial Ubidots could register 500 machines with one meter each without problems.

Materials




Other recommended equipment for upcoming tests

Recommendation: For a more detailed explanation step by step I recommend watching the full video  1# Measurement Electrical Consumption with Ubidots Industrial & ESP32 + PZEM-004T available on our Youtube PDAControl.

HTTP or HTTPS protocol

We have used this protocol for a long time in previous applications, technically any devices with TCP/IP capability can apply for its use, it is one of the most used protocols for IoT applications, Ubidots has a very detailed documentation including example and applications for Bash, ESP, Arduino and Python.

Recommendation: below you can see data in real time




Arduino IDE Code

The original example I have taken directly from the documentation of the Ubidots API HTTP , I have adapted it to the ESP32 modules and I have added the functions for reading the PeaceFair Meter with the help of the PZEM-004T libraries created by olehs, below Some characteristics of the code in question:

  • Reading of meters PZEM-004 and PZEM-004T (Voltage, Amperes, Power, Energy)
  • Internal temperature reading ESP32 module
  • Reading signal strength received signal or RSSI
  • Boolean alert for failure in communication with meter.
  • Re-connection connection with Wifi every 5 minutes
  • Recommended: Examples API Hardware HTTP Ubidots

RECOMMENDED : Meter PZEM-004T with Arduino ESP32 ESP8266 Python & Raspberry Pi

Meter PZEM-004T with Arduino ESP32 ESP8266 Python & Raspberry Pi

The device in Ubidots

Connections

Note: the meter PZEM-004T requires a modification to operate at 3.3V adding a 1 resistance complete documentation: Meter PZEM-004T with Arduino ESP32 ESP8266 Python & Raspberry Pi

Recommendation: For a more detailed explanation step by step I recommend watching the full video  1# Measurement Electrical Consumption with Ubidots Industrial & ESP32 + PZEM-004T available on our Youtube PDAControl.




Electrical Assembly

This is a very risky part, in my case the power supply reaches this board that distributes throughout the house, facilitating the assembly of the current transformer “CT”, previously with a multimeter and/or amperimetric clamp I have made the Measurements of Voltage and Current, for which I have determined a “CT” of 100A.

The current transformer is split core, facilitates its installation, it must be placed in phase “L”.

It is not necessary to exactly measure the Voltage in my case 120VAC of the same board, I have chosen to measure voltage in a normal current outlet, which does not affect the measurement and facilitates the assembly.

Note: If you intend to replicate this application, keep in mind that electricity knowledge is required if you do not possess the knowledge, please do not risk it.

Recommendation: below you can see data in real time




Dashboard design

Modify Widgets

Ubidots has special widgets that allow customization of certain attributes in the designs, with great help of languages such as HTML CCS and Javascript.

I initially designed a basic dashboard initially.

Certain Widgets as in this case Metric.

They allow through editors of HTML code CSS and Javascript embedded in the Widget we can make some improvements, press the open editor button.

Modifications of styles with the help of CCS, we can modify font size, color among many features.

I have changed the fonts or the typeface, I have used Chakra Petch from Google Fonts  gives a little character to the design.

Recommendation: For a more detailed explanation step by step I recommend watching the full video  1# Measurement Electrical Consumption with Ubidots Industrial & ESP32 + PZEM-004T available on our Youtube PDAControl.

Design Widgets from Zero

Another Widget that has great functionality is HTML canvas, allows you to create from scratch Widgets, of course with the help of HTML code CCS and Javascript

Ubidots does not have Widgets to capture data from dashboard, but with HTML canvas you can design a small form that stores the value in a variable “RAW”, in my case take this example of Ubidots: HTML Canvas Widget Examples  and apply a bit of Bootstrap

  • Widget Created, for data capture

Final Dashboard

Technically so far I can modify the price of kWh and multiply it by the read kWh of the meter, it’s just the beginning.

See dashboard publicly in this link: Ubidots-pdacontrol

Recommendation: For a more detailed explanation step by step I recommend watching the full video  1# Measurement Electrical Consumption with Ubidots Industrial & ESP32 + PZEM-004T available on our Youtube PDAControl.

Real Time Dashboard Values

The following widgets have been embedded directly from Ubidots, if you detail a few seconds you can see the change in real time.

See dashboard publicly in this link: Ubidots-pdacontrol



Conclusions

Some visual characteristics are remarkable as you can see, it was a great success to create that widget that allows CCS HTML code and Javascript.

I confess I am not a web developer, everything I have learned about HTML CSS and Javascript is technically empirical with the help of colleagues and great help from Google. I learned a little about everything, with all this I say that anyone can design these dashboards.

The creation of type variables is very useful “RAW” and “Synthetics”.

The variables Synthetics type allowed me to calculate the conversion kWh to COP “Colombian Pesos” and conversion kWh to USD “American Dollars”.

The meter sends Watts and Watts per hour with variables type Synthetics, performed the conversion of W to kW and Wh to kWh

The variables type “RAW” use it to store the value of a 1kWh = 514 COP in “Colombian Pesos” or 0.16 USD.

We still need to do more things such as:

  • Calculation of consumption day by day.
  • Calculation of consumption week to week.
  • Calculation of consumption month by month.
  • Or at defined intervals.

Ubidots has many features that I have not yet explored such as Analytics Types and Funtions.

Finally thanks to Bangood for the meter PZEM-004T and DFRobot for the ESP32 FireBeetle and thanks to Ubidots.com.




Downloads

References

Leave a Reply