EcoSphere-Smart Energy Usage and Environmental Prediction

by gustifir in Circuits > Microcontrollers

147 Views, 0 Favorites, 0 Comments

EcoSphere-Smart Energy Usage and Environmental Prediction

Ass Drawing v1.png
Ass v2.png
IMG20260602112455.jpg

Introduction

In today’s modern world, electrical energy has become an essential part of daily life. However, the increasing use of electricity also has a direct impact on the environment, particularly in contributing to carbon emissions and global warming. Many people still do not fully realize how their energy consumption habits affect the environment around them.

To address this issue, EcoSphere – Smart Energy Usage & Environmental Prediction was developed as an intelligent monitoring and prediction system designed to help users understand their electricity usage and its environmental impact in real time.

EcoSphere is capable of monitoring several important electrical parameters, including:

  1. Voltage
  2. Current
  3. Power Consumption (Watt)
  4. Energy Usage
  5. Average Energy Consumption

The collected data is processed automatically to provide informative and easy-to-understand insights regarding energy consumption behavior.

The main innovation of EcoSphere lies in its Environmental Prediction feature, which transforms electricity consumption data into meaningful environmental impact estimations. Instead of only displaying numerical energy usage data, the system provides users with a more relatable environmental perspective, such as:

  1. If users successfully reduce energy consumption, the system estimates how many trees are equivalent to being planted through carbon emission reduction.
  2. If users consume electricity excessively or inefficiently, the system estimates the environmental impact equivalent to the loss or cutting down of a certain number of trees due to increased carbon emissions.

This approach allows users not only to monitor electrical energy usage but also to better understand the environmental consequences of their daily energy consumption habits.

In addition to functioning as a monitoring device, EcoSphere is designed as an interactive educational platform that promotes awareness about energy efficiency and environmental sustainability. With a modern real-time monitoring interface, intelligent data processing, and intuitive environmental visualization, the system encourages users to adopt smarter, more energy-efficient, and environmentally friendly behaviors.

By integrating Internet of Things (IoT) technology, real-time electrical monitoring, and environmental impact prediction, EcoSphere – Smart Energy Usage & Environmental Prediction offers an innovative solution that bridges smart energy management with ecological awareness to support a more sustainable future.

Supplies

Desain tanpa judul (3).png

Tools and Materials

All components used in the EcoSphere – Smart Energy Usage & Environmental Prediction project are easy to find in the market and relatively affordable. In addition, the assembly process is simple, making this project suitable for Internet of Things (IoT) development, electrical energy monitoring systems, and technology-based educational applications.

Electronic Components (Hardware)

The following are the main electronic components used in this project:

  1. ESP32S Development Board
  2. PZEM-004T V3 + Current Transformer (CT) Sensor
  3. LCD 16x2 + I2C Module
  4. AC to 5V DC Step-Down Module
  5. Perfboard (Prototype PCB Board)
  6. Jumper Wires
  7. Project Enclosure / Black Box
  8. Black enclosure with dimensions:
  9. Width : 11 cm
  10. Length : 18 cm
  11. Height : 6 cm
  12. USB Data Cable

Software Requirements

The following software tools are used in developing the EcoSphere system:

  1. Arduino IDE
  2. PZEM004T Library
  3. LCD I2C Library
  4. ESP32 Driver
  5. ThingSpeak

By combining these hardware and software components, the EcoSphere system can operate efficiently in monitoring electrical energy usage while also providing real-time environmental impact predictions.

Wiring Diagram

wiring_bb.png

Wiring Connection

PZEM-004T V3 to ESP32S

  1. PZEM VCC → ESP32 5V
  2. PZEM GND → ESP32 GND
  3. PZEM TX → ESP32 GPIO16 (RX2)
  4. PZEM RX → ESP32 GPIO17 (TX2)
  5. CT Sensor → PZEM CT Terminal
  6. AC Input Line → PZEM AC Terminal

LCD 16x2 I2C to ESP32S

  1. LCD VCC → ESP32 5V
  2. LCD GND → ESP32 GND
  3. LCD SDA → ESP32 GPIO33
  4. LCD SCL → ESP32 GPIO32

Step-Down AC to 5V DC

  1. AC Input → AC Power Source
  2. 5V Output (+) → ESP32 5V
  3. GND Output (-) → ESP32 GND

USB Connection

  1. USB Data Cable → ESP32 USB Port
  2. USB Data Cable → Computer / Laptop

Downloads

Hardware Setup and Assembly

WhatsApp Image 2026-05-30 at 15.36.44.jpeg
WhatsApp Image 2026-05-30 at 15.36.45.jpeg
WhatsApp Image 2026-05-30 at 15.36.45 (1).jpeg
IMG20260602112036.jpg
IMG20260602112245.jpg

Step 1 – Soldering Connectors and Preparing Connection Lines

Before assembling the main circuit, prepare all connectors that will be used to connect the components in the system. Male headers and female headers are used to ensure that each component can be easily installed, removed, and maintained during testing and future modifications.

  1. Prepare the required materials, including male headers, female headers, a soldering iron, solder wire, and a perfboard.
  2. Cut the headers according to the number of pins required by each component.
  3. Place the headers on the perfboard based on the planned circuit layout.
  4. Carefully solder each header pin to ensure a strong and reliable connection.
  5. Inspect the solder joints to ensure there are no short circuits or unwanted connections between adjacent pins.
  6. After all headers have been soldered, perform a visual inspection to verify that the soldering is neat and that every connection is secure.
  7. Connect the male and female headers according to the wiring diagram to facilitate the installation of the ESP32, PZEM-004T V3 sensor, LCD 16×2 I2C module, and power supply module in the following assembly steps.

The primary objective of this step is to create a neat, durable, and modular connection system that simplifies assembly, testing, troubleshooting, and future maintenance of the EcoSphere device.

Note: Ensure that no power source is connected during the soldering process to prevent component damage and ensure safe working conditions.

Step 2 – Connecting the Wires According to the Wiring Diagram

After all male and female connectors have been securely mounted on the perfboard, the next step is to connect the wires between the components according to the designed wiring diagram.

  1. Prepare jumper wires or connecting wires with appropriate lengths for the assembly.
  2. Cut and strip the ends of the wires as needed to facilitate soldering or connector installation.
  3. Connect each wire to the corresponding connector on the perfboard following the wiring diagram.
  4. Ensure that the communication lines between the ESP32, PZEM-004T V3 sensor, LCD 16×2 I2C module, and power supply module are connected to the correct pins.
  5. Pay special attention to the VCC, GND, TX, RX, SDA, and SCL connections to avoid wiring errors.
  6. Once all wires have been connected, carefully inspect each connection to ensure that no wires are loose or connected to the wrong terminals.
  7. Organize the wiring neatly using cable ties or other suitable cable management methods to improve the appearance and simplify future maintenance.

At this stage, accuracy is essential because incorrect wiring may cause the system to malfunction or potentially damage the electronic components.

Note: Always perform a final inspection of all connections and compare them with the wiring diagram before proceeding to component installation and system testing.

Program Arduino IDE

Screenshot 2026-05-30 160057.png

Before uploading the program to the ESP32 using Arduino IDE, several configuration parameters must be adjusted according to the hardware setup and user account settings. In the WiFi configuration section, replace the SSID with the name of the WiFi network to be used and replace the Password with the corresponding network password to enable the ESP32 to connect to the internet.

Next, in the ThingSpeak configuration section, update the Channel ID and Write API Key with the values associated with the user's ThingSpeak account. In addition, ensure that each ThingSpeak Field is configured according to the measurement parameters transmitted by the system. In this project, the following field assignments are used:

  1. Field 1 : Voltage
  2. Field 2 : Current
  3. Field 3 : Power
  4. Field 4 : Energy
  5. Field 5 : Avg Energy
  6. Field 6 : Tree

It is important to verify that the field order in the ThingSpeak channel matches the field order defined in the program. This ensures that the data displayed on the ThingSpeak dashboard accurately represents the measured electrical parameters.

If an I2C LCD is used, verify the I2C address configured in the program. The most commonly used addresses are 0x27 and 0x3F. If the LCD does not display any information, perform an I2C address scan using an I2C Scanner sketch to identify the correct address of the LCD module.

After all configuration parameters have been properly adjusted, compile and upload the program to the ESP32. Ensure that the ESP32 is connected to the computer via a USB cable and that the correct communication port has been selected in Arduino IDE before starting the upload process.

The complete Arduino program used in this project is provided in the Appendix section of this report for reference and future implementation.

Downloads

ThingSpeak Configuration

Screenshot 2026-05-30 161950.png
Screenshot 2026-05-30 211842.png

Step 1 – Create a ThingSpeak Account

  1. Visit the ThingSpeak website.
  2. Click Sign Up and create a new account.
  3. Verify your email address and log in to the dashboard.

Step 2 – Create a New Channel

  1. Select ChannelsNew Channel.
  2. Enter the channel name and description.
  3. Configure the fields as follows:
  4. Field 1 : Voltage
  5. Field 2 : Current
  6. Field 3 : Power
  7. Field 4 : Energy
  8. Field 5 : Avg Energy
  9. Field 6 : Tree
  10. Click Save Channel.

Step 3 – Get the API Key

  1. Open the API Keys tab.
  2. Copy the Write API Key.
  3. Paste the API key into the Arduino IDE program.
  4. Upload the code to the ESP32.

Step 4 – Verify Data Upload

  1. Connect the EcoSphere device to Wi-Fi.
  2. Run the system.
  3. Open the ThingSpeak channel dashboard.
  4. Confirm that Voltage, Current, Power, Energy, Avg Energy, and Tree data are displayed correctly.

Step 5 – Configure MATLAB Analysis

  1. Open AppsMATLAB Analysis.
  2. Create a new analysis script.
  3. Read data from Energy and Avg Energy fields.
  4. Process the data to calculate the environmental impact.

Step 6 – Generate Tree Prediction

  1. Convert energy consumption data into an equivalent tree value.
  2. Lower energy consumption results in a higher tree value.
  3. Store the calculation result in Field 6 (Tree).


MATLAB Analysis Code

% 1. YOUR CHANNEL CREDENTIALS

channelID = 123;

readAPIKey = 'ex123';


% FIX: Extra spaces inside quotes are automatically removed using strtrim

writeAPIKey = strtrim('ex123');


fieldAvgEnergi = 5; % Field for hourly average energy consumption

fieldPohon = 6; % Output field for "Tree Contribution" on the website


% 2. RETRIEVE HISTORICAL AVERAGE ENERGY DATA (Last 30 Hours)

[dataAvgHistori, ~] = thingSpeakRead(channelID, 'Fields', fieldAvgEnergi, ...

'NumPoints', 30, 'ReadKey', readAPIKey);


if ~isempty(dataAvgHistori) && length(dataAvgHistori) > 1

% Current hour energy value (latest data point)

avgEnergiJamIni = dataAvgHistori(end);

% Calculate baseline (normal average usage from previous hours)

avgBaselineHarian = mean(dataAvgHistori(1:end-1), 'omitnan');

% 3. ENERGY SAVING LOGIC BASED ON AVERAGE ENERGY

if avgEnergiJamIni < avgBaselineHarian

% Calculate energy saving difference for this hour (in Watts)

energiDihematWatt = avgBaselineHarian - avgEnergiJamIni;

% Convert to kiloWatt-Hour (kWh) since the interval is 1 hour

kWhDihemat = (energiDihematWatt * 1) / 1000;

% Convert kWh to CO2 reduction (1 kWh = 0.85 kg CO2)

co2BerkurangKg = kWhDihemat * 0.85;

% Convert CO2 reduction to tree equivalent

% (1 tree absorbs ~0.06 kg CO2 per day)

jumlahPohon = co2BerkurangKg / 0.06;

else

% If current usage is above normal average, no tree contribution

jumlahPohon = 0;

end

% Round to 2 decimal places for cleaner output

jumlahPohon = round(jumlahPohon, 2);

% 4. FIX: Correct syntax for thingSpeakWrite function

thingSpeakWrite(channelID, jumlahPohon, 'Fields', fieldPohon, 'WriteKey', writeAPIKey);

disp('=== PROCESS COMPLETED SUCCESSFULLY ===');

disp(['Current energy saving compared to baseline: ', num2str(avgBaselineHarian - avgEnergiJamIni), ' Watts.']);

disp(['Equivalent tree contribution: ', num2str(jumlahPohon), ' trees.']);

end

Working Principle

Screenshot 2026-05-30 201435.png
Screenshot 2026-05-30 215243.png
IMG20260602112421.jpg

This device operates by recording electrical energy consumption in real-time, which is then analyzed using MATLAB based on sensor readings to estimate the energy wasted into the environment, represented as an equivalent number of trees. The system is also directly integrated with an internet-based monitoring dashboard, allowing the home's electrical conditions to be monitored remotely from anywhere, even while traveling. Through this dashboard, users can visualize the average energy consumption over the past few hours while evaluating their consumption patterns—whether they fall into an efficient category or tend to be wasteful. Consequently, this device not only maintains electrical efficiency in our homes but also serves as an environmentally-based smart solution for a better future

Conclusion

EcoSphere-Smart Energy Usage and Environmental Prediction Video
IMG20260602112417.jpg
Assembly

This device is more than a standard electrical monitoring innovation; it is an environmentally-based smart solution that bridges modern technology with ecological awareness. Through the integration of sensors, MATLAB analysis, and an internet-based dashboard, this tool effectively transforms abstract electricity consumption data into concrete visualizations monitorable from anywhere—including an estimated environmental impact equated to a number of trees. With the ability to evaluate average energy usage in real-time, this innovation is capable of shifting user behavior from wasteful to more efficient. This is a tangible step for digital technology in maintaining household energy efficiency while actively contributing to the sustainability of the Earth's future.