A comprehensive, full-stack IoT solution designed to monitor electrical energy consumption in real-time. This project simulates a smart energy meter, captures live power usage, and visualizes the data through an interactive, responsive web dashboard with automated billing capabilities.
- Real-Time Data Visualization: Live Area Charts displaying the most recent power usage trends using Recharts.
- Smart Budget Tracker: Interactive slider allowing users to set monthly kWh goals, with dynamic progress bars and over-limit warning alerts.
- Automated PDF Billing: Generates professional, downloadable PDF energy bills filtered by specific date ranges using
jsPDFandautoTable. - Historical Data Filtering: Search and filter historical energy consumption data using an intuitive dual-calendar interface.
- Modern UI/UX: Clean, enterprise-level interface utilizing soft gradients, Bootstrap typography, and Lucide-React icons.
This project integrates hardware simulation, a middleware bridge, a robust backend, and a dynamic frontend. Here is the step-by-step data flow:
-
Hardware Simulation (Arduino + Proteus)
- An Arduino circuit is simulated using Proteus. A potentiometer acts as the variable electrical load (simulating household power usage).
- The Arduino reads the analog values, calculates the current power demand (kW) and total consumed units (kWh) over time.
- This data is serialized into a JSON string and transmitted via a virtual serial port (COM1).
-
Middleware Serial Bridge (Python)
- A Python script (
bridge.py) utilizing thepyseriallibrary listens to the virtual serial port (COM2 via VSPE). - It captures the live JSON data stream from the Proteus simulation, decodes it, and instantly forwards it to the web backend via HTTP POST requests.
- A Python script (
-
Backend API (Laravel + MySQL)
- A Laravel RESTful API receives the incoming POST requests from the Python bridge.
- It calculates the estimated bill amount based on a predefined unit price and securely stores the
meter_id,current_usage,total_units, andbill_amountinto a MySQL database. - It provides
GETendpoints to serve this data, supporting date-range filtering for the frontend.
-
Frontend Dashboard (React + Vite)
- The React application continuously polls the Laravel API to fetch the latest readings.
- State management is used to instantly update the UI summary cards, alert systems, and live charts without requiring a page refresh.
- Frontend: React.js, Vite, Bootstrap, Recharts, jsPDF, Lucide-React.
- Backend: Laravel (PHP), Eloquent ORM, MySQL.
- Middleware Bridge: Python 3, PySerial, Requests.
- IoT / Hardware: Arduino (C++), Proteus Design Suite, Virtual Serial Port Emulator (VSPE).
cd smart-meter-api
composer install
cp .env.example .env
php artisan key:generate
# Update your .env file with your database credentials
php artisan migrate
php artisan serve