npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-obd-retriver

v1.0.4

Published

A React Native hook library to manage Bluetooth Low Energy connections and communication with ELM327 OBD-II adapters.

Readme

React Native OBD Retriever

A React Native library for accessing raw OBD-II data from ELM327 adapters via Bluetooth Low Energy (BLE) connections. This library provides direct access to the raw data received from the ELM327 device without interpretation or conversion, giving you complete control over how to display or process the information.

Features

  • 🚗 Direct BLE communication with ELM327 OBD-II adapters
  • 📊 Raw data access from various OBD-II protocols (CAN, ISO9141, KWP, J1850)
  • 🔍 Raw DTC data retrieval (Mode 03, 07, 0A)
  • 🧩 ECU protocol detection and adaptation
  • 🔄 Command interface for ELM327 with proper timing and retry logic
  • 📱 iOS and Android support via BLE
  • ⚡ Complete TypeScript support

Installation

npm install react-native-obd-retriver
# or
yarn add react-native-obd-retriver

Dependencies

This library requires the following peer dependencies:

  • react-native-bluetooth-obd-manager: For Bluetooth OBD communication
  • react-native-permissions: For handling Bluetooth permissions

Install them using:

npm install react-native-bluetooth-obd-manager react-native-permissions
# or
yarn add react-native-bluetooth-obd-manager react-native-permissions

Quick Start

1. Set up providers

Wrap your application with the required providers:

import { BluetoothProvider } from 'react-native-bluetooth-obd-manager';
import { ECUProvider } from 'react-native-obd-retriver';

function App() {
  return (
    <BluetoothProvider>
      <ECUProvider>
        <YourApp />
      </ECUProvider>
    </BluetoothProvider>
  );
}

2. Connect to ECU

import { useECU } from 'react-native-obd-retriver';

const ConnectionComponent = () => {
  const { state, connectWithECU, disconnectECU } = useECU();
  
  return (
    <View>
      <Text>Status: {state.status}</Text>
      <Button
        title={state.status === 'CONNECTED' ? 'Disconnect' : 'Connect'}
        onPress={state.status === 'CONNECTED' ? disconnectECU : connectWithECU}
      />
    </View>
  );
};

3. Retrieve Raw DTC Data

import { useDTCRetriever } from 'react-native-obd-retriver';

const DTCComponent = () => {
  const { get03DTCObject, get07DTCObject, get0ADTCObject } = useDTCRetriever();
  const [currentDTCs, setCurrentDTCs] = useState(null);
  
  const fetchCurrentDTCs = async () => {
    try {
      // Raw DTC data from Mode 03 (Current DTCs)
      const rawDTCs = await get03DTCObject();
      setCurrentDTCs(rawDTCs);
    } catch (error) {
      console.error('Failed to retrieve raw DTC data:', error);
    }
  };
  
  return (
    <View>
      <Button title="Get Current DTCs" onPress={fetchCurrentDTCs} />
      {currentDTCs && (
        <Text>
          Raw DTC data: {currentDTCs.rawString}
        </Text>
      )}
    </View>
  );
};

Core Concepts

ECU Connection

The library manages the connection to the vehicle's ECU through the ELM327 adapter:

  • Connection State: Tracks the current connection status (DISCONNECTED, CONNECTING, CONNECTED, CONNECTION_FAILED)
  • Protocol Detection: Automatically detects and configures the appropriate OBD protocol
  • ECU Information: Provides protocol details, voltage information, and detected ECU addresses

Raw Data Access

All data from the vehicle is provided in raw format with no interpretation:

  • Raw DTC Data: Access to complete raw data from the three DTC modes (03, 07, 0A)
  • VIN Retrieval: Get the raw VIN string from the vehicle
  • Direct Commands: Send any command directly to the ELM327 adapter

API Reference

Hooks

useECU()

Core hook for ECU connection management with the following functionality:

const {
  state,                  // Current ECU state
  connectWithECU,         // Connect to ECU
  disconnectECU,          // Disconnect from ECU
  getECUInformation,      // Update ECU information (voltage, etc.)
  getActiveProtocol,      // Get active protocol information
  getVIN,                 // Get raw VIN string
  clearDTCs,              // Clear DTCs (Mode 04)
  getRawCurrentDTCs,      // Get raw current DTCs
  getRawPendingDTCs,      // Get raw pending DTCs
  getRawPermanentDTCs,    // Get raw permanent DTCs
  sendCommand,            // Send raw command to adapter
} = useECU();

useDTCRetriever()

Specialized hook for retrieving raw DTC data:

const {
  get03DTCObject,         // Get raw current DTCs (Mode 03)
  get07DTCObject,         // Get raw pending DTCs (Mode 07)
  get0ADTCObject,         // Get raw permanent DTCs (Mode 0A)
} = useDTCRetriever();

Raw DTC Response Format

The RawDTCResponse object contains:

{
  rawString: string | null,                  // Raw string response
  rawResponse: number[] | null,              // Response as number array
  response: string[][] | null,               // Parsed response structure
  rawBytesResponseFromSendCommand: string[], // Raw bytes from adapter
  isCan: boolean,                            // Whether CAN protocol is used
  protocolNumber: number,                    // Protocol number
  ecuAddress: string | undefined,            // ECU address if available
}

Examples

See the src/examples directory for complete working examples:

  • DTCManagerExample: Display raw DTC data from all modes
  • ClearDTCExample: Clear DTCs and verify they're gone
  • VINRetrievalExample: Get and display VIN information
  • LiveDataExample: Monitor real-time vehicle data
  • CustomCommandExample: Send custom commands to the adapter

Troubleshooting

Common Issues

  1. Bluetooth Connection Problems

    • Ensure Bluetooth is enabled and permissions are granted
    • Verify the adapter is powered and in range
    • Check that the adapter is ELM327 compatible
  2. Protocol Detection Issues

    • Some vehicles require the engine to be running
    • Try connecting with the ignition on but engine off first
    • Some older vehicles may need specific protocols selected manually
  3. Data Retrieval Problems

    • Some vehicles don't support all OBD modes
    • Command timing may need adjustment for certain vehicles
    • Verify the ELM327 firmware version is compatible

License

MIT