Holiday Notice: We will be on holiday from Oct.1st to Oct.6th (GMT+8). Orders can still be placed and will be shipped right after the holiday. Read More>>

user-img

MUHAMMAD Najib

+ Follow

IoT Smart Energy Cost Monitoring for Electric Motorcycles: A

This project presents an IoT-Based Smart Energy Cost Monitoring System for Electric Motorcycles, designed to provide real-time insights into power consumption and operational costs as a sustainable alternative to fuel. The system is built around the ESP32 microcontroller, which serves as the core for data acquisition and wireless connectivity. Power usage is precisely measured using the HLW8012 energy metering sensor, while a 20x4 LCD display delivers instant on-device feedback for the user

IoT Smart Energy Cost Monitoring for Electric Motorcycles: A
 
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
 

Hardware Components

  • Esp32

    X 1
  • HLW8012

    Hiliwei Tech
    X 1 fenxiang
  • LCD 20x4 Blue Light

    X 1 fenxiang
  • Power Supply SMPS 5V 12V 24V AC-DC 220V TO 12V 24V 5V 1A 1.5A 2A

    X 1 fenxiang
  • push button

    X 1 fenxiang

Tools, APP Software Used etc.

  • Arduino IDE

    Arduino IDE

    Arduino

Story

This project is an IoT-based Smart Energy Cost Monitoring System designed for electric motorcycles.
The main goal is to help riders understand the real-time cost of electricity consumption, making it easier to compare with fuel-based motorcycles. By knowing the exact electricity cost per ride, users gain confidence that switching to electric motorcycles is not only environmentally friendly but also economically beneficial.

How does it work?

 

  1. Power Measurement (HLW8012 Sensor)
    The HLW8012 sensor measures voltage, current, and active power consumed by the charger/motor. From this data, the system calculates the total energy used (in kWh).

  2. Cost Calculation
    Using the official local electricity tariff (Rp 1444.7 per kWh in this demo), the system automatically converts energy consumption into real-time cost.

  3. Display on LCD (20x4)
    The LCD shows:

    • Current time (from NTP server)

    • Selected user (e.g., Mio, Pespa)

    • Current power usage (W)

    • Total energy consumed (Wh/kWh)

    • Total cost (Rp)

  4. IoT Integration with Adafruit IO
    Data is also sent to the cloud dashboard (Adafruit IO), so users can monitor cost and usage history remotely via smartphone or PC.

  5. User Interaction (Buttons)

    • Button 1 → Switch between user profiles (different motorcycles).

    • Button 2 → Switch LCD display mode (time, power, cost, energy).

    • Button 3 → Reset accumulated energy data

Step-by-step tutorial

1. Hardware Setup

  • Microcontroller: ESP32

  • Sensor: HLW8012 (energy measurement IC)

  • Display: LCD 20x4 I2C

  • Connectivity: WiFi (for Adafruit IO)

  • Buttons: For user profile, screen change, and reset

???? Connections:

  • HLW8012 → ESP32 (pins CF, CF1, SEL)

  • LCD → I2C pins (SDA, SCL)

  • Buttons → GPIO (with INPUT_PULLUP)

2. Software Requirements

  • Arduino IDE

  • Libraries:

    • WiFi.h

    • Adafruit_MQTT.h

    • HLW8012.h

    • LiquidCrystal_I2C.h

3. Code Highlights

  • Energy integration:

     
    double deltaWh = (P * deltaSeconds) / 3600.0; energi_Wh += deltaWh; double energi_kWh = energi_Wh / 1000.0; double biaya = energi_kWh * TARIFF_RP_PER_KWH;
  • IoT Publish:

     
    iot_user.publish(user.c_str()); iot_biaya.publish(biaya);

4. Deployment

  • Upload code to ESP32

  • Connect to WiFi

  • Open Adafruit IO dashboard → create feeds for biaya and user

  • Monitor data online


Why is this project significant?

  • For Users: Helps riders directly compare the real cost of electricity vs fuel, breaking the myth that charging is expensive.

  • For Community: Supports the transition to sustainable transportation, reducing CO₂ emissions and fuel dependency.

  • For Students/Makers: Demonstrates how to build a complete IoT project from hardware sensing to cloud monitoring.


Lessons Learned (Common Pitfalls)

  • HLW8012 calibration is tricky → if voltage/current values look odd, adjust multipliers with a reference load.

  • WiFi connection drops → implement reconnection logic for stable IoT data.

  • Power factor fluctuations → remember that charging circuits are not purely resistive, so PF < 1 is normal.

Code
  • code

    nodemcu32_chargin_monitor_35807142568c82b678a47f.zip
    Download(2)
Schematic and Layout
Topic
View All

IoT Smart Energy Cost Monitoring for Electric Motorcycles: A

This project presents an IoT-Based Smart Energy Cost Monitoring System for Electric Motorcycles, designed to provide real-time insights into power consumption and operational costs as a sustainable alternative to fuel. The system is built around the ESP32 microcontroller, which serves as the core for data acquisition and wireless connectivity. Power usage is precisely measured using the HLW8012 energy metering sensor, while a 20x4 LCD display delivers instant on-device feedback for the user

428
 
4
4
0

Share your project on social media to expand its influence! Get more people to support it.

  • Comments( 4 )
  • Like( 4 )
/1000
Upload a photo:
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP

You May Also Like

View All
Add to cart
Board Type : GerberFile :
Layer : Dimensions :
PCB Qty :
Different PCB Design
PCB Thickness : PCB Color :
Surface Finish : Castellated Hole :
Copper Weight : 1 oz Production Time :
Total: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.

PCB Assembly

PCBA Qty: BomFile:
NO. OF UNIQUE PARTS: NO. of Components:
Country: Shipping Way:
Assembly Cost: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
3dPrintingFile : Size :
Unit : Volumn :
3D Printing Qty : Material :
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Acrylic Type : AcrylicFile :
Dimensions: Engrave:
Acrylic Qty :
Acrylic Thickness:
Acrylic Color:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
CNC Milling File : Size:
Unit: Volumn:
CNC Milling Qty : Material:
Type of Aluminum: Surface Finish:
Tolerance:
Surface Roughness:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Item Price Qty Subtotal Delete
Total: US $0.00
Certified Product | Supported Purchase: Full After-sales Protection