TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (352 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136714 times)
  2. FAT32 Library (69925 times)
  3. Network Ethernet Library (55937 times)
  4. USB Device Library (46261 times)
  5. Network WiFi Library (41884 times)
  6. FT800 Library (41150 times)
  7. GSM click (28979 times)
  8. PID Library (26411 times)
  9. mikroSDK (26355 times)
  10. microSD click (25353 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

OBDII click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.4

mikroSDK Library: 2.0.0.0

Category: CAN

Downloaded: 142 times

Followed by: 1 user

License: MIT license  

OBDII click offers a unique opportunity to tap into the car diagnostic systems. It features the STN1110 Multiprotocol OBD to UART Interface, developed by the ScanTool technologies. This click can be used for the communication with the Electronic Control Unit (ECU) of a vehicle, via several different OBD II diagnostic protocols such as CAN, K LINE, L LINE and J1850. The STN1110 IC is used to process requests sent by the MCU via the UART interface and return back the responses from the ECU network nodes.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "OBDII click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "OBDII click" changes.

Do you want to report abuse regarding "OBDII click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


OBDII click

OBDII click offers a unique opportunity to tap into the car diagnostic systems. It features the STN1110 Multiprotocol OBD to UART Interface, developed by the ScanTool technologies. This click can be used for the communication with the Electronic Control Unit (ECU) of a vehicle, via several different OBD II diagnostic protocols such as CAN, K LINE, L LINE and J1850. The STN1110 IC is used to process requests sent by the MCU via the UART interface and return back the responses from the ECU network nodes.

obdii_click.png

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jul 2023.
  • Type : UART type

Software Support

We provide a library for the OBDII Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for OBDII Click driver.

Standard key functions :

  • obdii_cfg_setup Config Object Initialization function.

    void obdii_cfg_setup ( obdii_cfg_t *cfg );
  • obdii_init Initialization function.

    err_t obdii_init ( obdii_t *ctx, obdii_cfg_t *cfg );

Example key functions :

  • obdii_send_command This function sends command string by using UART serial interface.

    void obdii_send_command ( obdii_t *ctx, uint8_t *cmd );
  • obdii_generic_read This function reads a desired number of data bytes by using UART serial interface.

    err_t obdii_generic_read ( obdii_t *ctx, uint8_t *data_out, uint16_t len );
  • obdii_reset_device This function resets the device by toggling the RST pin.

    void obdii_reset_device ( obdii_t *ctx );

Example Description

This example demonstrates the use of OBDII click board by reading the engine RPM and vehicle speed and displaying results on the USB UART.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    obdii_cfg_t obdii_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    obdii_cfg_setup( &obdii_cfg );
    OBDII_MAP_MIKROBUS( obdii_cfg, MIKROBUS_1 );
    if ( UART_ERROR == obdii_init( &obdii, &obdii_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    obdii_reset_device ( &obdii );

    obdii_process ( &obdii );
    obdii_clear_app_buf ( );

    log_printf( &logger, "> Reset device\r\n" );
    obdii_send_command ( &obdii, OBDII_CMD_RESET_DEVICE );
    obdii_rsp_check ( &obdii, OBDII_RSP_PROMPT );
    obdii_log_app_buf ( );
    Delay_ms ( 1000 );

    log_printf( &logger, " Disable echo\r\n" );
    obdii_send_command ( &obdii, OBDII_CMD_DISABLE_ECHO );
    obdii_rsp_check ( &obdii, OBDII_RSP_PROMPT );
    obdii_log_app_buf ( );

    log_printf( &logger, " Remove spaces\r\n" );
    obdii_send_command ( &obdii, OBDII_CMD_SPACES_OFF );
    obdii_rsp_check ( &obdii, OBDII_RSP_PROMPT );
    obdii_log_app_buf ( );
}

Application Task

Reads and processes the engine RPM and vehicle speed and displays the results on the USB UART once per second.

void application_task ( void )
{
    uint8_t * __generic_ptr start_ptr = NULL;
    uint8_t data_buf[ 5 ] = { 0 };
    uint16_t rpm = 0;
    uint8_t speed = 0;

    log_printf( &logger, " Get current RPM\r\n" );
    obdii_send_command ( &obdii, OBDII_CMD_GET_CURRENT_RPM );
    obdii_rsp_check ( &obdii, OBDII_RSP_PROMPT );
    start_ptr = strstr( app_buf, OBDII_RSP_CURRENT_RPM );
    if ( start_ptr )
    {
        memcpy ( data_buf, ( start_ptr + 4 ), 4 );
        data_buf[ 4 ] = 0;
        rpm = hex_to_uint16( data_buf ) / 4;
        log_printf( &logger, "RPM: %u\r\n\n>", rpm );
    }
    else
    {
        obdii_log_app_buf ( );
    }

    log_printf( &logger, " Get current speed\r\n" );
    obdii_send_command ( &obdii, OBDII_CMD_GET_CURRENT_SPEED );
    obdii_rsp_check ( &obdii, OBDII_RSP_PROMPT );
    start_ptr = strstr( app_buf, OBDII_RSP_CURRENT_SPEED );
    if ( start_ptr )
    {
        memcpy ( data_buf, ( start_ptr + 4 ), 2 );
        data_buf[ 2 ] = 0;
        speed = hex_to_uint8( data_buf );
        log_printf( &logger, "Speed: %u km/h\r\n\n>", ( uint16_t ) speed );
    }
    else
    {
        obdii_log_app_buf ( );
    }
    Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.OBDII

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

Current 6 click

0

Current 6 Click is a compact add-on board providing a precise and accurate current sensing solution. This board features the MAX40080, a fast-response bi-directional current-sense amplifier from Analog Devices. The device features ultra-low 5uV input offset voltage, very-low 0.2% gain error, and includes an analog-to-digital converter with programmable sample rate and 12-bit resolution featuring I2C compatible interface. It also features a wake-up current-threshold and auto-shutdown mode when the I2C is inactive, both designed to minimize power consumption. The current-shunt monitor can measure voltage signals on common-mode voltages ranging from -0.1V (ground sensing) to 36V, independent of the supply voltage. This Click board™ delivers higher performance to industrial control and automation applications, load and power supplies monitoring, telecom equipment, and many more.

[Learn More]

Boost click

2

Boost click carries Microchip’s MIC2606, a 2MHz, PWM DC/DC boost switching regulator available in a 2mm x 2mm MLF package. The input voltage can be set to 5V from mikroBUS or in range 7-20V from an external DC source connected to VIN screw terminal. The output voltage can be set up to 38V.

[Learn More]

BT Audio 2 click

0

BT Audio 2 Click is Bluetooth audio stream add on board based on BM62 module from Microchip. It's a Stereo Audio module which is fully qualified Bluetooth v5.0 dual-mode (BDR/EDR/BLE) to be added in any wireless audio and voice application. With features like high resolution up to 24-bit, 96 kHz audio data format, Bluetooth Low Energy data rate up to 1Mbits/s, connection of two hosts with HFP/A2DP profiles simultaneously, seamless serial data over UART interface and many more it's perfect solution for applications like portable speakers and headsets.

[Learn More]