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?
-
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). -
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. -
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)
-
-
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. -
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:
-
IoT Publish:
4. Deployment
-
Upload code to ESP32
-
Connect to WiFi
-
Open Adafruit IO dashboard → create feeds for
biaya
anduser
-
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.