OPEN-SOURCE DC ENERGY METER FEATURING BLYNK CLOUD MONITORING

by adriancubas in Circuits > Arduino

1145 Views, 19 Favorites, 0 Comments

OPEN-SOURCE DC ENERGY METER FEATURING BLYNK CLOUD MONITORING

Thumbnail.jpg
02.jpg
13.JPG
01.jpeg
03.JPG

If you’ve ever worked on a tech project involving voltage and current measurements, you’ve likely felt the need to record those values for future analysis and decision-making. Personally, I’ve faced this challenge many times, especially when trying to determine the performance of Windturer Wind Turbine. Dealing with interconnecting cables to multimeters, ensuring the wind turbine doesn’t interfere with the cables, and making sure the camera correctly captures the values can be tedious and error-prone due to the number of variables to manage simultaneously.

In this project, I present the solution I developed to overcome this problem. Unable to find any commercial solution, I decided to create my own. I designed a device that measures current and voltage at short intervals and calculates other variables such as consumed energy and power. These short-interval measurements are then integrated to continuously record the values for the duration of the measurement. All these values are sent via a WiFi connection to Blynk’s cloud servers, from where they can be monitored from any internet-connected device anywhere in the world.

To ensure the device operates effectively in regions that are difficult to access but not too far from civilization, an internet connection can be established using a combination of technologies. One viable option is to use a cellular network, leveraging 4G or 5G connectivity to provide reliable internet access. In areas where cellular coverage is limited, a satellite internet connection can be employed as a backup. Additionally, the use of long-range WiFi extenders or mesh networks can help bridge the gap between the device and the nearest internet access point. These solutions ensure that the device remains connected to the internet, allowing for continuous monitoring and control, even in challenging environments.

The Blynk platform also allows for automation, such as triggering alarms in case of overvoltage, controlling other safety devices like electromagnetic brakes for wid turbines, suspending battery charging, among other possibilities.

One of the key advantages of this project is its versatility. It can be used to monitor remote devices such as a solar charging system or a remote camera. Additionally, it can monitor multiple devices simultaneously and program automations to manage them efficiently. This capability is crucial for ensuring the reliability and safety of various systems, especially those located in hard-to-reach areas.

The importance of this project cannot be overstated. By providing a reliable and efficient way to monitor and control electrical systems, it helps prevent potential failures and optimizes performance. This is particularly valuable in applications like renewable energy systems, where maintaining optimal performance is essential for sustainability. Moreover, the ability to automate responses to specific conditions enhances safety and reduces the need for constant human supervision.

As always, I hope you enjoy this project and, if you find it useful, let me know in the comments. Feel free to reach out if you have any modification proposals or need any answers.

I have included two models for this project. One of the models includes a space to place a single-cell 18650 Power Bank. This way, the module can be powered directly through a small USB cable. The other model does not include this compartment for the Power Bank, and you will need to power the module using another Power Bank or a 5V USB adapter. When it is required for this project to operate for very long periods, the compact solution of a single-cell 18650 Power Bank may not be sufficient.


Supplies

01.JPG
02.JPG
03.JPG
04.JPG

The components selected for this invention were chosen based on their unique features and advantages that make them ideal for creating a precise, efficient, and remotely controllable monitoring system. Each component plays a crucial role in ensuring the device’s functionality and reliability.

  1. ESP8266 WiFi Module:
  2. Advantages:
  3. WiFi Connectivity: Enables connection to WiFi networks, facilitating remote communication and control of the device from anywhere.
  4. Low Cost: An economical module, perfect for IoT projects.
  5. Compatibility: Compatible with various platforms and programming languages.
  6. Adafruit INA219:
  7. Advantages:
  8. Precise Measurement: Provides accurate measurements of voltage, current, and power.
  9. I2C Interface: Simplifies communication with microcontrollers via the I2C protocol.
  10. Low Power Consumption: Ideal for applications where power consumption is critical.
  11. Adafruit SSD1306 OLED Display:
  12. Advantages:
  13. High Resolution: Offers clear and sharp resolution for displaying information.
  14. Low Power Consumption: Consumes less power compared to other types of displays.
  15. Compact Size: Its small size makes it ideal for portable and compact projects.

This project is significant for several reasons:

  1. Remote Monitoring: Thanks to the WiFi connectivity provided by the ESP8266 and integration with Blynk, you can monitor and control the device remotely. This is especially useful in IoT applications where constant supervision is required.
  2. Accurate Energy Measurement: With the INA219 sensor, you can obtain precise measurements of voltage, current, and power, which is crucial for applications requiring detailed energy consumption monitoring.
  3. Real-Time Visualization: The use of the OLED display allows real-time visualization of the measured data, facilitating immediate interpretation and analysis of the information.
  4. Diverse Applications: This type of device can be used in a wide range of applications, from educational projects to industrial monitoring systems.

“As an Amazon affiliate, I earn money from qualifying purchases made through the affiliate links provided below.”

  1. ESP8266 WeMos Mini D1 Module 
  2. INA219 I2C Bi-Directional Power Sensor 
  3. 2.1mm Female Socket 
  4. I2C Display Module 0.91 Inch I2C OLED Display Module
  5. Pin Header Strip (2.54 mm) for Arduino Connector 
  6. PCB for interconnection 
  7. USB C DIY Connector 24Pin Female Socket Port or Micro USB Interface Power Adapter
  8. Single-cell 18650 Power Bank (No Battery)
  9. 18650 Battery Pack

The PCB for component interconnection has been uploaded as a shared project on the PCBWay platform. From there, you can download the G-code files if you want to make your own PCB, or you can directly order its fabrication from the platform. This way, you ensure that you will get the same PCB that I have tested, free of errors and with exceptional quality.

There was an error when writing Blynk on the PCB silkscreen; instead, it was written as Blink.

Optimizing Your 3D Printer to Print the Container Box With PETG Filament

LLK4PRO_02 - UltiMaker Cura 9_2_2024 1_19_20 PM.png
Captura de pantalla 2024-09-05 092954.png
16.JPG
01.JPG
20240903_193001.jpg

If you are looking for a suitable material to print the case of this Energy Meter, I recommend considering the use of PETG (Polyethylene Terephthalate Glycol). This material offers several advantages that make it ideal for this type of application:

  1. Strength and Durability: PETG is known for its high mechanical strength and durability. This ensures that the energy meter case can withstand impacts and stresses without breaking or deforming easily.
  2. Temperature Resistance: PETG has good temperature resistance, which is crucial for electronic devices that may generate heat during operation.
  3. Ease of Printing: PETG is relatively easy to print compared to other materials like ABS. It has good adhesion to the print bed and fewer warping issues, resulting in more precise and high-quality prints.
  4. Chemical Resistance: PETG is resistant to many chemicals, making it suitable for environments where it may be exposed to corrosive substances.

I recommend the following parameters that you should configure in your favorite slicer.

  1. Nozzle Temperature: Set your nozzle temperature between 220 to 240 degrees Celsius. For this tutorial, we’ll use 235 degrees Celsius.
  2. Bed Temperature: Adjust your bed temperature to 50 to 85 degrees Celsius. We’ll set it to 85 degrees Celsius for optimal adhesion.
  3. Layer Height: Use a layer height of 0.16 mm for finer details. This setting ensures a smooth finish and accurate prints. If you want a faster print, you can set it to 0.28mm.
  4. Perimeters: Set your slicer to print with 4 perimeters. This provides additional strength and durability to your prints.
  5. Print Speed: Adjust your print speed to 40 to 60 millimeters per second. This range balances quality and efficiency.
  6. Fan Speed: Set your fan speed between 0% to 100%. Lower speeds enhance strength, while higher speeds improve visual quality, especially for bridges and overhangs.
  7. Retraction Distance: For a stock Bowden extruder, set the retraction distance to 5 to 7 millimeters. This helps prevent stringing and ensures clean prints.
  8. Brim: Use a brim to improve adhesion and prevent warping. A brim increases the surface area of the first layer, helping it stick better to the print bed. It also provides additional support to the base of the print and makes it easier to remove the print from the bed without damaging the model.

Feel free to adjust the settings based on your specific needs and printer performance.

During the execution of this project, I had issues with the 3D printer, specifically with the extruder mechanism (See the PIC), and the parts I obtained didn’t turn out to be as attractive as I would have liked LOL.

Interconnection of Hardware Elements

Captura de pantalla 2024-09-03 094025.png
Captura de pantalla 2024-09-03 093915.png
Captura de pantalla 2024-09-03 094140.png

The Energy Meter is composed of several key components that work together to measure and display energy consumption. Below is a description of the interconnection of these components and the reasoning behind their configuration:

  1. ESP8266 Microcontroller: This is the brain of the system. It handles WiFi communication and connects to the Blynk platform for remote monitoring.
  2. INA219 Current Sensor: This sensor measures the current and voltage in the circuit. It is connected to the ESP8266 via the I2C bus (address 0x40).
  3. SSD1306 OLED Display: This display shows the measured data in real-time. It is also connected to the ESP8266 via the I2C bus (address 0x3C).
  4. Built-in LED: Indicates the connection status with Blynk. It blinks at different speeds depending on whether it is connected or not.

Connection Details

ESP8266 Connections

  1. VCC: Connected to the 3.3V or 5V power supply.
  2. GND: Connected to ground.
  3. SDA (GPIO4): Connected to the SDA pin of the INA219 sensor and the OLED display.
  4. SCL (GPIO5): Connected to the SCL pin of the INA219 sensor and the OLED display.
  5. D4 (GPIO2): Connected to the built-in LED.

INA219 Sensor Connections

  1. VCC: Connected to the 3.3V power supply.
  2. GND: Connected to ground.
  3. SDA: Connected to the SDA pin of the ESP8266.
  4. SCL: Connected to the SCL pin of the ESP8266.

SSD1306 OLED Display Connections

  1. VCC: Connected to the 3.3V power supply.
  2. GND: Connected to ground.
  3. SDA: Connected to the SDA pin of the ESP8266.
  4. SCL: Connected to the SCL pin of the ESP8266.

Connection Variants

Depending on the available components and specific project needs, the following variants can be considered:

  1. Using Different GPIO Pins: If GPIO4 and GPIO5 are occupied, other available GPIO pins on the ESP8266 can be used for the SDA and SCL connections.
  2. Power Supply: Although a 3.3V power supply is used in this case, some components may work with 5V. It is important to check the specifications of each component.
  3. LED Connection: The built-in LED is connected to GPIO2, but any other available GPIO pin can be used if necessary.

Advantages of Using Fritzing for Initial Design

The initial design of the connections was done using Fritzing software. This offers several advantages:

  1. Clear Visualization: Fritzing allows for the creation of clear and easy-to-understand visual schematics, facilitating circuit planning and assembly.
  2. Error Detection: Designing the circuit in Fritzing makes it easier to detect and correct errors before physical assembly.
  3. Documentation: Schematics created in Fritzing serve as visual documentation of the project or sharing with others.

Download the Fritzing File and Software

I have shared the Fritzing file for you to download and review. You can download the Fritzing software from its official website https://fritzing.org/

I have included the datasheet of the INA219 in this project. It provides detailed technical specifications and performance characteristics, which are essential for future design changes and ensuring reliable operation.

Electrical Connections Between Components

05.JPG
06.JPG
07.JPG
08.JPG
09.JPG
10.JPG
11.JPG
12.JPG
13.JPG
14.JPG
15.JPG

Soldering Header Pins:

First, solder the Header Pins to the interconnection board.

Soldering the ESP8266 Module:

Next, solder the ESP8266 module to these pins, respecting the position shown on the interconnection board and in the images. Maintain a separation between the ESP8266 board and the interconnection PCB to improve cooling and allow the connection of the micro USB programming cable to the integrated micro USB port on the ESP8266 module.

Soldering the INA219:

After soldering the ESP8266, solder the INA219 following the same recommendations as for the ESP8266.

Connecting Wires to the ESP8266:

To the 5V and GND pins of the ESP8266, solder two thin wires to the USB chassis connector. This way, when the USB cable is externally inserted, it provides power to the entire assembly.

Connecting the LCD:

The connection to the small LCD is indicated in the initial interconnection diagrams in Freezing.

Connecting the INA219:

In the Terminal Block of the INA219, screw in the wires that will be soldered to the side legs of the DC connectors for the chassis, as shown in the photos. The central leg of each DC connector is connected to each other and, in turn, to the GND connection pin indicated on the interconnection board.

Configuration of the Arduino IDE to Load the Firmware on the ESP8266

Captura de pantalla 2024-08-24 131625.png
Captura de pantalla 2024-08-24 135214.png
Captura de pantalla 2024-08-24 135407.png
Captura de pantalla 2024-08-26 080949.png
Captura de pantalla 2024-08-26 081115.png
Captura de pantalla 2024-08-26 081220.png
Captura de pantalla 2024-08-26 090925.png

To get started with programming your ESP8266 WeMos D1 Mini, you’ll need to install the Arduino IDE on your PC. This guide will walk you through the process of downloading and installing the Arduino IDE, configuring it to support the ESP8266, and writing and uploading the proposed code to the WeMos D1 Mini. In this case, the code provided is for an energy meter, which you will need to upload after replacing the placeholders (X) with the appropriate values derived from the next step of configuring the Blynk platform. By following these steps, you’ll be able to connect your device to a WiFi network and monitor the variables on the Blynk Console.

Installing the Arduino IDE

  1. Download the Arduino IDE:
  2. Go to the official Arduino website and download the version suitable for your operating system (Windows, macOS, Linux).
  3. Install the Arduino IDE:
  4. Run the downloaded file and follow the installer instructions.

Configuring the Arduino IDE for ESP8266

  1. Open the Arduino IDE:
  2. Once installed, open the Arduino IDE.
  3. Add support for ESP8266:
  4. Go to File > Preferences.
  5. In the “Additional Boards Manager URLs” field, add the following URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json.
  6. Click OK.
  7. Install the ESP8266 boards:
  8. Go to Tools > Board > Boards Manager.
  9. Search for esp8266 and click Install.

Programming the ESP8266 WeMos D1 Mini

  1. Select the board:
  2. Go to Tools > Board and select LOLIN(WEMOS) D1 R2 & mini.
  3. Select the port:
  4. Connect your WeMos D1 Mini to the PC using a USB cable.
  5. Go to Tools > Port and select the port corresponding to your device.
  6. Copy and Paste this code:
#define BLYNK_TEMPLATE_ID "xxxxxxxxxx"
#define BLYNK_TEMPLATE_NAME "xxxxxxxxxx"

#define BLYNK_PRINT Serial
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_INA219.h>
#include <Adafruit_SSD1306.h>

char auth[] = "xxxxxxxxxx";
char ssid[] = "your Wifi SSID";
char pass[] = "your Wifi password";

#define I2C_ADDRESS 0x40
Adafruit_INA219 ina219(I2C_ADDRESS);

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

float shuntVoltage_mV = 0.0;
float Load_Voltage = 0.0;
float Source_Voltage = 0.0;
float Current = 0.0;
float Power = 0.0;
float Wh = 0;

unsigned long lastmillis = millis();
unsigned long previousMillis = 0; // will store the last time the Wh was updated

void setup()
{
Serial.begin(115200);

// Initialize the OLED display and show a message
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10,10);
display.print("Powered and");
display.setCursor(10,20);
display.print("trying to connect...");
display.display();

Blynk.begin(auth, ssid, pass); // Start Blynk
delay(1000);
while (!Serial);
Wire.begin();
ina219.begin();
display.clearDisplay();

Serial.println("INA219 Current Sensor Example Sketch - Continuous");

// Define the built-in LED pin and set it as output
#define LED_BUILTIN 2
pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
Blynk.run(); // Initiates Blynk

unsigned long currentMillis = millis();

if (Blynk.connected()) { // If connected to Blynk
// Your existing code to read from the sensor and display on the OLED
shuntVoltage_mV = ina219.getShuntVoltage_mV();
Source_Voltage = ina219.getBusVoltage_V();
Current = ina219.getCurrent_mA() / 1000;
Power = ina219.getPower_mW() / 1000;
Load_Voltage = Source_Voltage + (shuntVoltage_mV / 1000);

// Interpret any voltage less than 1V and greater than 0 as 0V
if (Source_Voltage < 1.0 && Source_Voltage > 0.0) {
Source_Voltage = 0.0;
}

// Update Wh once every second
if (currentMillis - previousMillis >= 1000) {
previousMillis = currentMillis;
Wh = Wh + Power / 3600.0;
}

// Send to Blynk
Blynk.virtualWrite(V0, Source_Voltage);
Blynk.virtualWrite(V1, Load_Voltage);
Blynk.virtualWrite(V2, Current);
Blynk.virtualWrite(V3, Power);
Blynk.virtualWrite(V4, Wh);

//Display on OLED
display.clearDisplay();
display.setCursor(10,10);
display.print("V: ");
display.print(Source_Voltage, 2);
display.setCursor(74,10);
display.print("A: ");
display.print(Current, 2);
display.setCursor(10,20);
display.print("W: ");
display.print(Power, 2);
display.setCursor(74,20);
display.print("Wh: ");
display.print(Wh, 2);
display.display();
} else { // If not connected to Blynk
// Display a message on the OLED
display.clearDisplay();
display.setCursor(10,10);
display.print("Failed to");
display.setCursor(10,20);
display.print("connect to Blynk");
display.display();
}

// Call the blinkLED function
blinkLED();
}

void blinkLED() {
if (Blynk.connected()) { // If connected to Blynk
digitalWrite(LED_BUILTIN, HIGH); // Turn on the LED
delay(1000); // Wait a second
digitalWrite(LED_BUILTIN, LOW); // Turn off the LED
delay(1000); // Wait a second
} else { // If not connected to Blynk
digitalWrite(LED_BUILTIN, HIGH); // Turn on the LED
delay(100); // Wait a tenth of a second
digitalWrite(LED_BUILTIN, LOW); // Turn off the LED
delay(100); // Wait a tenth of a second
}
}


You should not upload the code to the ESP8266 yet without first advancing and completing the step of configuring Blynk. It would not be able to connect correctly to Blynk servers. You will need to replace the Xs with the values provided by Blynk after creating an account and setting up a new template and a new device. You also need to enter the SSID of your WiFi network and its password into the code.

Explaining the Code

the code thumbnail.png

Overview

This code is for an ESP8266 microcontroller that connects to a WiFi network and uses the Blynk platform to monitor and display sensor data. It reads data from an INA219 current sensor and displays it on an OLED screen. It also sends the data to the Blynk app.

Code Breakdown

Definitions and Libraries:

#define BLYNK_TEMPLATE_ID "xxxxxxxxxx"

#define BLYNK_TEMPLATE_NAME "xxxxxxxxxx"

#define BLYNK_PRINT Serial

#include <Wire.h>

#include <ESP8266WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp8266.h>

#include <Adafruit_INA219.h>

#include <Adafruit_SSD1306.h>

  1. Defines Blynk template ID and name.
  2. Includes necessary libraries for WiFi, Blynk, INA219 sensor, and OLED display.

WiFi and Blynk Credentials:

char auth[] = "xxxxxxxxxx";

char ssid[] = "your wifi name";

char pass[] = "your wifi password";

  1. Stores the authentication token for Blynk and WiFi credentials.

Sensor and Display Initialization:

#define I2C_ADDRESS 0x40

Adafruit_INA219 ina219(I2C_ADDRESS);

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 32

#define OLED_RESET -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

  1. Initializes the INA219 sensor and the OLED display with specified parameters.

Variables for Sensor Data:

float shuntVoltage_mV = 0.0;

float Load_Voltage = 0.0;

float Source_Voltage = 0.0;

float Current = 0.0;

float Power = 0.0;

float Wh = 0;

unsigned long lastmillis = millis();

unsigned long previousMillis = 0;

  1. Declares variables to store sensor data and time.

Setup Function:

void setup() {

Serial.begin(115200);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

display.clearDisplay();

display.setTextSize(1);

display.setTextColor(SSD1306_WHITE);

display.setCursor(10,10);

display.print("Powered and");

display.setCursor(10,20);

display.print("trying to connect...");

display.display();

Blynk.begin(auth, ssid, pass);

delay(1000);

while (!Serial);

Wire.begin();

ina219.begin();

display.clearDisplay();

Serial.println("INA219 Current Sensor Example Sketch - Continuous");

#define LED_BUILTIN 2

pinMode(LED_BUILTIN, OUTPUT);

}

  1. Initializes serial communication, OLED display, Blynk, and INA219 sensor.
  2. Displays a message on the OLED screen.
  3. Sets up the built-in LED pin.

Loop Function:

void loop() {

Blynk.run();

unsigned long currentMillis = millis();

if (Blynk.connected()) {

shuntVoltage_mV = ina219.getShuntVoltage_mV();

Source_Voltage = ina219.getBusVoltage_V();

Current = ina219.getCurrent_mA() / 1000;

Power = ina219.getPower_mW() / 1000;

Load_Voltage = Source_Voltage + (shuntVoltage_mV / 1000);

if (Source_Voltage < 1.0 && Source_Voltage > 0.0) {

Source_Voltage = 0.0;

}

if (currentMillis - previousMillis >= 1000) {

previousMillis = currentMillis;

Wh = Wh + Power / 3600.0;

}

Blynk.virtualWrite(V0, Source_Voltage);

Blynk.virtualWrite(V1, Load_Voltage);

Blynk.virtualWrite(V2, Current);

Blynk.virtualWrite(V3, Power);

Blynk.virtualWrite(V4, Wh);

display.clearDisplay();

display.setCursor(10,10);

display.print("V: ");

display.print(Source_Voltage, 2);

display.setCursor(74,10);

display.print("A: ");

display.print(Current, 2);

display.setCursor(10,20);

display.print("W: ");

display.print(Power, 2);

display.setCursor(74,20);

display.print("Wh: ");

display.print(Wh, 2);

display.display();

} else {

display.clearDisplay();

display.setCursor(10,10);

display.print("Failed to");

display.setCursor(10,20);

display.print("connect to Blynk");

display.display();

}

blinkLED();

}

  1. Runs the Blynk process.
  2. Reads sensor data and updates variables.
  3. Sends data to Blynk and displays it on the OLED screen.
  4. Displays a message if not connected to Blynk.
  5. Calls the blinkLED function.

Blink LED Function:

void blinkLED() {

if (Blynk.connected()) {

digitalWrite(LED_BUILTIN, HIGH);

delay(1000);

digitalWrite(LED_BUILTIN, LOW);

delay(1000);

} else {

digitalWrite(LED_BUILTIN, HIGH);

delay(100);

digitalWrite(LED_BUILTIN, LOW);

delay(100);

}

}

  1. Blinks the built-in LED at different rates depending on the Blynk connection status.

Downloads

How to Configure Blynk.Cloud

Setting Up Blynk with ESP8266 for DC Power Meter
00ANUEVO DASHBOARD DOUBLE VARIABLES.png
00NUEVO DASHBOARD DOUBLE VARIABLES.png

1. Accessing Blynk

  1. Type Blynk.cloud in the address bar, and the authentication screen will appear.
  2. If you don’t have an account, select the option to create a new account.
  3. Enter your email and confirm that you agree with the terms and conditions.
  4. You will receive a link in your email to create a password for accessing the platform. We suggest using a secure password.
  5. Enter a username, and you will automatically access the Blynk console.

2. Getting Familiar with Blynk

  1. I suggest reading the Blynk Tour to familiarize yourself with the possibilities it offers.
  2. Pause on each screen if you wish to read it.

3. Blynk Plans

  1. The Blynk platform offers several plans, but the free option will provide us with the necessary tools for our basic objectives in this example.

4. Organization and Templates

  1. Each user must be integrated into an organization. By default, the platform assigns a predetermined name that we will not change in this case.
  2. The first thing you should do after completing the organization information is to create a new template.
  3. Templates are digital variants of our physical devices like Arduino, ESP, etc.
  4. In our case, we associate this template with an ESP8266 that we will use in our DC Power Meter.
  5. Communication will be established via WiFi, so select that option. You can add a description if you wish.

5. Template Configuration

  1. Once inside the template you just created, you will need to complete four steps.
  2. Before that, I suggest copying and pasting the Power Meter code into the Arduino, specifically the template name and its ID.
  3. By clicking on the corresponding icon, it will be copied to the clipboard.
  4. The copied data should replace the ones indicated in lines 1 and 2 of the code you downloaded.
  5. Then, add a new device associated with this template, we call it ENERGY METER DEVICE ESP8266.
  6. Immediately after, an authentication token will be generated, which you should also paste into the code, replacing the Xs in line 12.
  7. This way, the code will be ready to upload to the ESP8266.

6. Datastreams Configuration

  1. To monitor the variables in Blynk sent by the ESP8266, it will be necessary to configure the Datastreams.
  2. Create a new Datastream by selecting the Virtual PIN option.
  3. Fill in this information as shown to succeed in this step.

7. Dashboard Configuration

  1. The way the variables sent by the ESP8266 will be displayed can vary and will depend on the options you use for your dashboard.
  2. Move and arrange the widgets on the canvas. You can follow the way I do it here or make changes according to your preferences.
  3. When you complete this step, you will have everything you need to receive and monitor the variables sent by the ESP8266 in the Blynk console.

If you want to enable other functionalities of the Blynk Platform in addition to displaying the data obtained by the ESP8266, I suggest changing the data type from String to Double as shown in the images. This way, you can indicate the units of measurement for each magnitude.

How to Set Up the Blynk App for Your Energy Meter

How to Set Up the Blynk App for Your Energy Meter
  1. Download and install Blynk: Download the Blynk app on your mobile phone and install it.
  2. Log in: Open the app and select “login” to enter with your existing account.
  3. Configuration: Go to the configuration section in Blynk.
  4. Add widget: Add a new widget. With the free plan, some options won’t be available, but you can use the “value display” widget.
  5. Select data: Tap on the white rectangle of the created widget and select the Datastream you want to display (e.g., voltage).
  6. Customization: Configure the title, color, and size of the widget according to your preferences.
  7. Adjust size and position: Press and hold the widget to adjust its size and position on the dashboard.
  8. Duplicate widget: You can make several duplicates of the widget and customize them with different titles and colors based on the selected Datastream.

A Brief Demonstration and Final Words.

A brief demonstration of the Energy Meter ESP8266
Testing WindTurer: Measuring Energy Output with My Energy Meter Design
17.JPG
18.JPG
19.JPG

Thank you for following along with this project on creating an energy meter using the ESP8266, INA219, and an OLED display. In this guide, we have covered how to configure the Blynk platform to view the results on your mobile device and the web. We also explained how to print the enclosure and the PCB to support the ESP8266, INA219, and LCD, and how to interconnect them.

If you have any questions or need further assistance, feel free to reach out. I am more than happy to help with any doubts you may have. Additionally, I encourage you to make your own modifications and improvements to this project.

Happy Making!!!