Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

πŸš— OBD2 Dashboard

---------------------------------------------------------------------------#

CI

---------------------------------------------------------------------------

πŸ“‹ Overview

OBD2 Dashboard is a real-time vehicle monitoring application that provides live insights into your vehicle's performance using OBD2 data. Built with .NET 8.0 backend and React frontend, it features a Mustang-themed dashboard with WebSocket-based real-time updates.

✨ Features

  • πŸ“Š Real-time vehicle diagnostics via WebSocket
  • 🎨 Mustang-themed interactive dashboard with custom gauges
  • 🏎️ RPM gauge, speedometer, coolant temperature, and gear indicator
  • πŸ”Œ Direct ELM327 OBD2 adapter support
  • 🐳 Docker containerized deployment
  • πŸ“± Raspberry Pi deployment support
  • πŸ”§ OBD2 emulator for testing without a vehicle

πŸ› οΈ Prerequisites

  • .NET for backend
  • Node.js for frontend
  • React with TypeScript
  • Python (for OBD2 emulator only)
  • OBD2 Emulator (optional, for testing)
  • socat (for virtual serial port emulation)
  • Docker & Docker Compose (for containerized deployment)
  • ELM327-compatible OBD2 adapter (for real vehicle connection)

πŸ—οΈ Architecture

  • Backend: .NET 8.0 C# with WebSocket communication for real-time data streaming
  • Frontend: React 18 with TypeScript and custom dashboard components
  • Communication: AT command manager for OBD2 protocol handling
  • Deployment: Docker Compose for containerized services
  • Target Platforms: Linux (x64, ARM), Raspberry Pi, Windows (development)

πŸ“¦ Setup and Installation

Quick Start with Docker Compose

  1. Clone the repository
git clone https://github.com/hitmanpc/obd2dashboard.git
cd obd2dashboard
  1. Start all services (backend, frontend, and emulator)
docker-compose up --build -d
  1. Access the dashboard

Stop Services

docker-compose down

Production Deployment

For production deployment with nginx reverse proxy:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

Raspberry Pi Deployment

See the Quick Start Guide for streamlined Raspberry Pi deployment, or detailed Raspberry Pi deployment docs for step-by-step instructions.

# One-command deployment on Raspberry Pi
curl -fsSL https://raw.githubusercontent.com/hitmanpc/obd2dashboard/main/deploy-pi.sh -o deploy-pi.sh
chmod +x deploy-pi.sh
./deploy-pi.sh

πŸš€ Development Setup

Running Backend Locally (without Docker)

  1. Navigate to backend directory
cd backend
  1. Build the project
dotnet build
  1. Run the application
dotnet run

Or use the VS Code tasks:

  • Press Ctrl+Shift+B to build
  • Use "watch" task for auto-reload during development

Running Frontend Locally (without Docker)

  1. Navigate to frontend directory
cd frontend
  1. Install dependencies
npm install
  1. Start development server
npm start

The frontend will be available at http://localhost:3000

πŸ§ͺ Running with OBD2 Emulator (No Vehicle Required)

Start OBD2 Emulator

Before starting the application, start the OBD2 emulator to simulate vehicle data:

cd emulator
python -m elm -n 35000 --daemon

You should see: ELM327-emulator daemon service STARTED on /dev/pts/<x>

Check emulator status:

ps aux | grep elm

Stop emulator:

kill <pid>

Using Virtual Serial Port (tcp2UsbScript.sh)

To create a virtual serial port mapped to the emulator:

cd emulator
./tcp2UsbScript.sh

This script will:

  • Start the ELM327 emulator as a daemon on TCP port 35000
  • Create a virtual serial port at /virtual/usb1 using socat
  • Monitor and auto-restart the emulator if it crashes
  • Clean up processes on exit

πŸ”Œ Connecting to Real OBD2 Adapter

  1. Connect your ELM327 OBD2 adapter via USB to your computer/Raspberry Pi
  2. Find the device: ls /dev/ttyUSB* or ls /dev/ttyACM*
  3. Set the OBD_PORT environment variable:
    export OBD_PORT=/dev/ttyUSB0
  4. Update docker-compose.yml to map the correct device:
    devices:
      - "/dev/ttyUSB0:/dev/ttyUSB0"

βœ… Verify Installation

Check Backend

Open your browser and navigate to:

http://localhost:8000

You should see WebSocket connection status.

Check Frontend

Open your browser and navigate to:

http://localhost:3000

You should see the Mustang-themed dashboard:

Mustang Dashboard

πŸ”§ Configuration

Backend Configuration

Main files:

Environment Variables:

  • OBD_PORT - Serial port for OBD2 adapter (default: /virtual/usb1)

Frontend Configuration

Main files:

Customize the dashboard:

  • Modify gauge components in frontend/src/components/
  • Update styling in *.css files
  • Configure OBD PIDs in backend configuration

OBD2 PID Configuration

Configure which OBD2 parameters to query in:

πŸ› οΈ Troubleshooting

OBD2 Connection Issues

  • ❗ Cannot connect to OBD2 adapter

    • Verify device is connected: ls /dev/ttyUSB* or ls /dev/ttyACM*
    • Check permissions: sudo chmod 666 /dev/ttyUSB0
    • Add user to dialout group: sudo usermod -aG dialout $USER && sudo reboot
    • Verify OBD_PORT environment variable is correct
  • ❗ Emulator not working

    • Ensure Python ELM327 emulator is installed: pip install ELM327-emulator
    • Check if emulator is running: ps aux | grep elm
    • Verify virtual serial port exists: ls /virtual/usb1
    • Ensure socat is installed: sudo apt-get install socat

Backend Issues

  • ❗ Backend won't start

    • Verify .NET 8.0 SDK is installed: dotnet --version
    • Check for port conflicts on port 8000
    • Review logs: docker-compose logs obd_backend
    • Ensure serial port device is accessible
  • ❗ WebSocket connection failed

    • Check backend is running and accessible
    • Verify firewall allows WebSocket connections
    • Ensure CORS is properly configured for your domain

Frontend Issues

  • ❗ Dashboard not loading

    • Verify Node.js is installed: node --version
    • Clear npm cache: npm cache clean --force
    • Delete node_modules and reinstall: rm -rf node_modules && npm install
    • Check for port conflicts on port 3000
  • ❗ No data displayed

    • Verify WebSocket connection in browser console
    • Check backend logs for OBD2 communication errors
    • Ensure OBD2 adapter/emulator is responding

Docker Issues

  • ❗ Permission denied

    • Add user to docker group: sudo usermod -aG docker $USER
    • Reboot system: sudo reboot
  • ❗ Cannot access devices in container

    • Verify device mapping in docker-compose.yml
    • Use --privileged flag if necessary (not recommended for production)

Raspberry Pi Specific

  • ❗ Insufficient memory

    • Increase swap size
    • Use production build instead of development: docker-compose -f docker-compose.prod.yml up -d
  • ❗ Slow performance

    • Ensure using ARM-optimized images
    • Consider pre-building on faster machine and deploying image

For more help, check the Raspberry Pi deployment guide or create an issue on GitHub.

πŸ“ Project Structure

obd2dashboard/
β”œβ”€β”€ backend/              # .NET 8.0 C# backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Program.cs              # Application entry point
β”‚   β”‚   β”œβ”€β”€ Commands/               # AT command definitions
β”‚   β”‚   β”œβ”€β”€ Communication/          # OBD2 communication layer
β”‚   β”‚   β”œβ”€β”€ Configuration/          # OBD PID configurations
β”‚   β”‚   └── Services/               # ObdService, WebSocketService
β”‚   β”œβ”€β”€ appsettings.json           # App configuration
β”‚   └── ObdDashboard.csproj        # .NET project file
β”œβ”€β”€ frontend/             # React TypeScript frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/            # Dashboard UI components
β”‚   β”‚   β”‚   └── MustangDashboard.tsx
β”‚   β”‚   β”œβ”€β”€ hooks/                 # React hooks (WebSocket)
β”‚   β”‚   └── types/                 # TypeScript definitions
β”‚   └── package.json
β”œβ”€β”€ emulator/             # OBD2 emulator for testing
β”‚   β”œβ”€β”€ tcp2UsbScript.sh          # Virtual serial port setup
β”‚   └── Dockerfile
β”œβ”€β”€ docs/                 # Documentation
β”‚   └── raspberry-pi-deployment.md
β”œβ”€β”€ docker-compose.yml    # Development setup
β”œβ”€β”€ docker-compose.prod.yml        # Production setup
β”œβ”€β”€ deploy-pi.sh          # Raspberry Pi deployment script
└── README.md

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch
    git checkout -b feature/your-feature-name
  3. πŸ’Ύ Commit your changes
    git commit -m "Add your feature description"
  4. πŸ“€ Push to the branch
    git push origin feature/your-feature-name
  5. πŸ”€ Create a Pull Request

Development Guidelines

  • Follow C# coding conventions for backend (.NET guidelines)
  • Use TypeScript and follow React best practices for frontend
  • Write meaningful commit messages
  • Test your changes with both emulator and real OBD2 adapter (if possible)
  • Update documentation as needed

πŸ“„ License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software, provided you give appropriate credit.

πŸ”— Resources

πŸ“ž Contact

Email: [email protected]
Issues: https://github.com/hitmanpc/obd2dashboard/issues


Built with ❀️ for car enthusiasts and developers

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages