Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

35 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PiezoRoad Logo

โšก PiezoRoad

Turning Every Journey Into Clean Energy

A real-time 3D simulation of piezoelectric road energy harvesting โ€”
visualizing the future of sustainable urban infrastructure.


Live Demo GitHub Deploy Status


React Three.js TypeScript Vite Tailwind License


divider


๐ŸŒ The Problem We're Solving

Every day, billions of vehicles travel across roads worldwide โ€” each one exerting thousands of newtons of force on the road surface. That mechanical energy is entirely wasted, absorbed silently into asphalt and concrete.

Meanwhile, the world urgently needs clean, renewable energy sources embedded into existing infrastructure โ€” without requiring new land, new towers, or new disruption.

What if every car that drove past generated electricity?


๐Ÿ’ก The Concept: Piezoelectric Roads

Piezoelectricity is the ability of certain materials (like crystals, ceramics, and polymers) to generate an electric charge in response to mechanical stress โ€” in other words, pressure becomes power.

PiezoRoad envisions embedding a dense grid of piezoelectric sensors directly into road surfaces. When vehicles drive over them, the weight and vibration of traffic is converted into electrical energy that is captured, stored, and fed into the grid.

๐Ÿš— Vehicle Weight
       โ†“
๐ŸŸฆ Piezoelectric Sensor  โ†’  โšก Electrical Pulse  โ†’  ๐Ÿ”‹ Battery Storage  โ†’  ๐Ÿ™๏ธ City Grid

Real-World Impact

Metric Estimate
Energy per vehicle pass ~0.05 โ€“ 0.20 kWh
1 km of busy road (daily) ~200 โ€“ 400 kWh
COโ‚‚ offset (per 100 kWh) ~40 kg of COโ‚‚
Sensor lifespan 5 โ€“ 10 years

๐ŸŽฎ What This Simulation Does

PiezoRoad is an interactive 3D real-time simulation built with React and Three.js that lets you visualize this concept in action.

Core Features

Feature Description
๐Ÿš— Live Traffic Simulation 4 cars continuously drive across the road at varying speeds, each triggering energy pulses on the piezo grid
โšก Energy Pulse Visualization Every time a vehicle passes a sensor, a blue energy pulse animates toward the battery unit in real time
๐Ÿ”‹ Live kWh Counter Total energy generated is tallied live and displayed as an accumulating kWh readout
๐ŸŒฟ COโ‚‚ Offset Tracker Converts energy generated to equivalent kilograms of COโ‚‚ avoided (0.4 kg/kWh)
๐ŸŸฆ 1,000-Sensor Smart Grid A 10ร—100 grid of piezoelectric modules covers the road surface, each color-coded by health status
๐Ÿ–ฑ๏ธ Clickable Sensor Inspection Click any individual sensor to open a panel showing its damage level and operational status
๐ŸŒ™ Day / Night Toggle Switch between a bright daytime city scene and a dark night mode with a starfield sky
๐ŸŽฅ Orbit Camera Drag to orbit, scroll to zoom โ€” explore the full road simulation from any angle

Sensor Health System

The simulation models sensor degradation with a realistic damage model:

๐ŸŸข Green   (0โ€“30% damage)   โ€” Optimal: generating full power
๐ŸŸก Yellow  (31โ€“70% damage)  โ€” Degraded: operating at reduced efficiency
๐Ÿ”ด Red     (71โ€“100% damage) โ€” Critical: maintenance required immediately

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
Frontend Framework React 19 Component architecture & state management
3D Rendering Three.js + React Three Fiber WebGL-powered 3D scene
3D Helpers @react-three/drei OrbitControls, Stars, Environment, Shadows
Animations Motion (Framer Motion) UI enter/exit transitions, micro-animations
Styling Tailwind CSS v4 Utility-first responsive design
Icons Lucide React Clean, consistent iconography
Build Tool Vite 6 Lightning-fast HMR dev server + production builds
Language TypeScript Type-safe component interfaces
CI/CD GitHub Actions Auto-deploy to GitHub Pages on every push

๐Ÿš€ Getting Started

Prerequisites

  • Node.js v18 or higher
  • npm v9 or higher

Installation

# 1. Clone the repository
git clone https://github.com/AounYoussef/PiezoRoad.git
cd PiezoRoad

# 2. Install dependencies
npm install

# 3. Start the development server
npm run dev

Open http://localhost:3000 in your browser. The simulation starts immediately โ€” no API keys, no accounts, no setup required.

Available Scripts

npm run dev      # Start local development server (port 3000)
npm run build    # Build optimized production bundle โ†’ dist/
npm run preview  # Preview the production build locally
npm run lint     # Type-check with TypeScript

๐Ÿ—‚๏ธ Project Structure

PiezoRoad/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ Simulation.tsx    # 3D scene: road, cars, sensors, battery, energy pulses
โ”‚   โ”‚   โ””โ”€โ”€ UI.tsx            # HUD: energy counter, COโ‚‚ tracker, sensor panel, controls
โ”‚   โ”œโ”€โ”€ App.tsx               # Root component โ€” wires simulation + UI state
โ”‚   โ”œโ”€โ”€ main.tsx              # React entry point
โ”‚   โ””โ”€โ”€ index.css             # Global styles + glassmorphism utilities
โ”œโ”€โ”€ img/
โ”‚   โ””โ”€โ”€ logo_v2.png           # Project logo
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ deploy.yml        # GitHub Actions โ†’ GitHub Pages CI/CD pipeline
โ”œโ”€โ”€ index.html                # HTML entry point
โ”œโ”€โ”€ vite.config.ts            # Vite build configuration
โ”œโ”€โ”€ tsconfig.json             # TypeScript configuration
โ””โ”€โ”€ package.json              # Dependencies & scripts

๐Ÿ”ฌ Technical Deep-Dive

Energy Generation Model

Each car uses useFrame (Three.js render loop) to track its real-time position. Every 5 road units traversed, it fires an energy pulse:

// Energy per sensor pass: random between 0.05โ€“0.20 kWh
// Models variability based on vehicle weight, speed, and sensor wear
onPass(Math.random() * 0.15 + 0.05, currentPos);

The 1,000-Sensor Smart Grid

The road contains a 10 ร— 100 grid of individually-addressable piezoelectric modules. Each module:

  • Has a randomly assigned damage percentage (0โ€“100%)
  • Is rendered with color-coded glow based on health status
  • Is clickable โ€” opening a real-time inspection panel
  • Uses emissiveIntensity to make critical sensors visually alarming
const color = isSelected ? "#2563EB"
            : isCritical ? "#ef4444"   // >70% damage โ€” red alert
            : isWarning  ? "#FACC15"   // >30% damage โ€” yellow warning
            :              "#22C55E";  // healthy โ€” green

Energy Pulse Animation

When energy is harvested, a glowing plane spawns at the sensor's world position and smoothly lerps toward the battery storage unit using Three.js's built-in interpolation โ€” visualizing real energy flow through the road system.


๐ŸŒ Live Demo

Deployed automatically via GitHub Actions on every push to main:

๐Ÿ”— https://AounYoussef.github.io/PiezoRoad/


๐Ÿ”ญ Future Roadmap

  • Real sensor hardware integration via WebSocket
  • Traffic density slider (rush hour / off-peak simulation)
  • Historical energy analytics dashboard with charts
  • Multi-road comparison mode
  • Economic ROI calculator (installation cost vs. energy revenue)
  • Mobile-optimized responsive layout
  • Road type selector (highway, city street, roundabout)
  • Export data as CSV / JSON report

๐Ÿค Contributing

Contributions, ideas, and feedback are welcome!

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add your feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License.


Built with โค๏ธ for a cleaner, smarter planet.

PiezoRoad โ€” Because the road to the future should power the future.

Releases

Packages

Contributors

Languages