Getting Started
Shiny.Obd is a .NET library for communicating with vehicles through OBD-II (On-Board Diagnostics) adapters. It uses a command-object pattern with generic return types, pluggable transports, and adapter auto-detection.
Features
Section titled “Features”- Command-object pattern — OBD commands are objects, not methods. Pass built-in commands or create your own for custom PIDs.
- Generic return types — each command declares its return type (
int,double,string,TimeSpan, etc.) with compile-time safety. - Pluggable transports —
IObdTransportabstracts the communication channel. Ships with BLE; add WiFi or USB later. - Device discovery —
IObdDeviceScannerfinds available adapters before connecting. BLE scanner included. - Adapter auto-detection — detects ELM327 vs OBDLink (STN) adapters via ATI and runs the appropriate initialization sequence.
- Task-based async — fully async/await throughout, no Reactive Extensions required in consuming code.
- 9 standard commands included — speed, RPM, coolant temp, throttle, fuel level, engine load, intake air temp, runtime, and VIN.
Packages
Section titled “Packages”| Package | Target | Description |
|---|---|---|
Shiny.Obd | net10.0 | Core library — commands, connection, transport abstraction |
Shiny.Obd.Ble | net10.0 | BLE transport using Shiny.BluetoothLE |
Quick Start
Section titled “Quick Start”<PackageReference Include="Shiny.Obd" /><PackageReference Include="Shiny.Obd.Ble" />using Shiny.Obd;using Shiny.Obd.Ble;using Shiny.Obd.Commands;
// Scan for an adaptervar scanner = new BleObdDeviceScanner(bleManager, new BleObdConfiguration{ DeviceNameFilter = "OBDLink"});var cts = new CancellationTokenSource();ObdDiscoveredDevice? selected = null;await scanner.Scan(device =>{ selected = device; cts.Cancel();}, cts.Token);
// Connect using the discovered devicevar transport = new BleObdTransport(selected!, new BleObdConfiguration());var connection = new ObdConnection(transport);await connection.Connect();
// Execute commandsvar speed = await connection.Execute(StandardCommands.VehicleSpeed); // int (km/h)var rpm = await connection.Execute(StandardCommands.EngineRpm); // intvar vin = await connection.Execute(StandardCommands.Vin); // stringArchitecture
Section titled “Architecture”┌─────────────────────────────────────────────────┐│ Your App ││ await connection.Execute(StandardCommands.*) │└──────────────────────┬──────────────────────────┘ │┌──────────────────────▼──────────────────────────┐│ ObdConnection ││ • Adapter detection (ATI probe) ││ • Profile-based initialization ││ • ELM327 response parsing (hex → bytes) ││ • Error handling (NO DATA, UNABLE TO CONNECT) │└──────────────────────┬──────────────────────────┘ │┌──────────────────────▼──────────────────────────┐│ IObdDeviceScanner ──▶ IObdTransport ││ Discover adapters Pluggable transport layer ││ ┌────────────────┐ ┌────────┐ ┌─────────┐ ││ │ BleObdTransport│ │ WiFi │ │ USB │ ││ │ (Shiny BLE) │ │(future)│ │(future) │ ││ └────────────────┘ └────────┘ └─────────┘ │└─────────────────────────────────────────────────┘