8.6 KiB
OBD2 Bluetooth - Vehicle Diagnostic Application
A modern Android application for communicating with OBD2 ELM327 Bluetooth adapters to read vehicle diagnostics and send custom commands.
🆕 Mejoras Recientes - Solución para CAN ERROR
Cambios en la Comunicación Bluetooth
1. Inicialización Mejorada del ELM327
- ✅ Tiempos de espera más largos: Reset ahora espera 2 segundos (antes 1 segundo)
- ✅ Espacios activados (ATS1): Mejor compatibilidad con más vehículos
- ✅ Adaptive timing conservador (ATAT1): Más confiable que ATAT2
- ✅ Test de comunicación automático: Verifica conexión con el vehículo después de la inicialización
- ✅ Logging detallado: Cada paso de inicialización se registra con su respuesta
2. Formateo Automático de Comandos
- Los comandos OBD ahora se formatean automáticamente con espacios
- Ejemplo:
010C→01 0C - Mejora la compatibilidad con diferentes adaptadores ELM327
3. Timeout Aumentado
- Timeout de lectura: 10 segundos (antes 5 segundos)
- Permite tiempo suficiente para vehículos que responden lentamente
4. Mejor Manejo de Errores
- Detección mejorada de "CAN ERROR"
- Logging de bytes enviados en hexadecimal
- Información detallada de respuestas
Nueva Pantalla: Ayuda de Diagnóstico 🔧
Agregamos una pantalla completa de ayuda para resolver problemas de conexión:
- ✅ Verificaciones rápidas: Lista de chequeo de problemas comunes
- ✅ Comandos de diagnóstico paso a paso: ATZ, ATI, ATDP, 0100, 010C
- ✅ Pruebas de protocolos: Botones para probar protocolos CAN específicos
- ✅ Respuestas en tiempo real: Ve la última respuesta del adaptador
- ✅ Consejos específicos: Explicaciones de errores comunes
Acceso a la Ayuda
Desde la pantalla principal, pulsa en "🔧 Ayuda de Diagnóstico"
Features
🔌 Bluetooth Connection
- Scan and connect to paired ELM327 Bluetooth devices
- Real-time connection status indicator
- Automatic ELM327 initialization
- Connection management
🚗 Vehicle Database
- Comprehensive database of vehicles and OBD signals
- Browse signals by vehicle make and model
- Search functionality for quick access
- Signal details including command, unit, frequency, and description
🔍 Quick Diagnostic
- Safe, read-only diagnostic test suite
- Common diagnostic parameters:
- Engine RPM
- Vehicle Speed
- Coolant Temperature
- Throttle Position
- Fuel Level
- Intake Air Temperature
- MAF Air Flow Rate
- Engine Load
- Automatic response parsing
- Command history with timestamps
⌨️ Custom Commands
- Send custom OBD2 commands
- Command editing before sending
- Response history
- Raw and parsed response display
- Common command shortcuts
- Resend functionality
⚠️ Safety Features
- Warning dialogs before sending any command
- Clear responsibility notices
- Distinction between safe and potentially dangerous commands
- User must explicitly accept risks
Architecture
Technology Stack
- Kotlin - Modern programming language for Android
- Jetpack Compose - Modern declarative UI framework
- Material Design 3 - Latest Material Design implementation
- Room Database - SQLite ORM for vehicle data
- Coroutines & Flow - Asynchronous programming
- MVVM Architecture - Clean architecture pattern
- Navigation Component - Type-safe navigation
Project Structure
app/
├── data/
│ ├── bluetooth/
│ │ └── BluetoothService.kt # Bluetooth communication
│ ├── database/
│ │ ├── entities/ # Room entities
│ │ ├── dao/ # Data Access Objects
│ │ ├── dto/ # Data Transfer Objects
│ │ └── ObdDatabase.kt # Room database
│ ├── obd/
│ │ └── ObdCommands.kt # OBD2 command definitions
│ └── repository/
│ └── ObdRepository.kt # Data repository
├── ui/
│ ├── components/
│ │ └── CommonComponents.kt # Reusable UI components
│ ├── navigation/
│ │ └── Screen.kt # Navigation routes
│ ├── screens/
│ │ ├── HomeScreen.kt # Main dashboard
│ │ ├── BluetoothScreen.kt # Device connection
│ │ ├── VehicleSelectionScreen.kt # Vehicle browser
│ │ ├── DiagnosticScreen.kt # Quick diagnostic
│ │ └── CustomCommandScreen.kt # Custom commands
│ ├── theme/ # App theming
│ └── viewmodel/
│ ├── MainViewModel.kt # Main app state
│ └── VehicleViewModel.kt # Vehicle data state
└── MainActivity.kt # App entry point
Database Schema
Tables
- brands - Vehicle manufacturers
- models - Vehicle models
- generations - Vehicle generations
- obd_signals - OBD command signals
- dtc_codes - Diagnostic Trouble Codes
Views
- vehicles_view - Vehicles with signal counts
- generations_view - Generations with vehicle info
- signals_view - Signals with vehicle info
- database_stats - Database statistics
Bluetooth Communication
ELM327 Protocol
The app communicates with ELM327 adapters using AT commands and OBD2 PIDs:
Initialization Commands
ATZ- Reset deviceATE0- Echo offATL0- Line feeds offATS0- Spaces offATSP0- Set protocol to automatic
Common OBD2 PIDs
010C- Engine RPM010D- Vehicle Speed0105- Coolant Temperature0111- Throttle Position012F- Fuel Level- And many more...
Response Parsing
The app automatically parses common PID responses into human-readable format with appropriate units.
Permissions
Required Permissions
- BLUETOOTH (API ≤ 30) - Bluetooth communication
- BLUETOOTH_ADMIN (API ≤ 30) - Bluetooth management
- BLUETOOTH_CONNECT (API ≥ 31) - Connect to devices
- BLUETOOTH_SCAN (API ≥ 31) - Scan for devices
Setup & Installation
Prerequisites
- Android Studio Hedgehog or newer
- Android SDK 24+ (Android 7.0+)
- ELM327 Bluetooth adapter
- Vehicle with OBD2 port
Build Instructions
- Clone the repository
- Open project in Android Studio
- Sync Gradle dependencies
- Add your vehicle database to
app/src/main/assets/obd_database.db - Build and run on device (Bluetooth requires physical device)
Database Setup
Place your SQLite database file with the required schema in:
app/src/main/assets/obd_database.db
Usage
Connecting to Vehicle
- Pair your ELM327 adapter in Android Bluetooth settings
- Open the app and navigate to "Bluetooth Connection"
- Select your ELM327 device from paired devices list
- Wait for connection confirmation
Running Diagnostics
- Ensure Bluetooth connection is active
- Navigate to "Quick Diagnostic"
- Tap "Run Test" button
- Review diagnostic results
Sending Custom Commands
- Ensure Bluetooth connection is active
- Navigate to "Custom Commands"
- Enter OBD2 command (e.g., "010C")
- Read and accept warning dialog
- View response
Browsing Vehicle Database
- Navigate to "Vehicle Database"
- Search or browse for your vehicle
- Select vehicle to view available signals
- Tap "Send" on any signal to execute (requires connection)
Safety & Disclaimer
⚠️ IMPORTANT: This application allows direct communication with your vehicle's systems.
Warnings
- Incorrect commands can damage your vehicle
- Some commands may void warranties
- Users are fully responsible for any consequences
- Read-only commands are generally safe
- Write commands require expert knowledge
Best Practices
- Start with the safe diagnostic test
- Research commands before sending
- Never send commands while driving
- Keep a record of sent commands
- Consult professional if unsure
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Follow Kotlin coding conventions
- Add documentation for new features
- Submit a pull request
License
This project is provided as-is for educational purposes. Use at your own risk.
Support
For issues, questions, or contributions, please open an issue on the project repository.
Acknowledgments
- ELM327 protocol documentation
- OBD2 standard specifications
- Android Jetpack Compose team
- Material Design team
Note: This application is designed for diagnostic and educational purposes. Always prioritize safety and consult professional mechanics for vehicle repairs.