Integrating Click IO expander with Arduino

Hi,

I am new to Arduino and trying to create a somewhat complex cable continuity testing program. Some of the cables I will be testing have over 100 pins so I cannot control this with one MEGA 2560 board hence, I have purchased 3 IO expansion boards called "Expand 13 Click" sold by Mikroe (Expand 13 Click).

The main issue I am currently having regards interfacing these expander boards with my Arduino. From what I understand, I can use 8 different addresses so 3 of these boards should be possible to use with my Arduino but, I am unsure on how to address individual pins on each of the expander boards.

I am using a library made by Mikroe that is on their LibStock page (LibStock - Expand 13 click) but cannot work out why the test code they have given with the library wont compile on my Arduino IDE.

I have attached the code below that I am trying to compile and would be grateful if anybody can tell me why this wont compile/ what's missing from the code.

#include <expand13.h>


void setup() {
    log_cfg_t log_cfg;  /**< Logger config object. */
    expand13_cfg_t expand13_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.
    expand13_cfg_setup( &expand13_cfg );
    EXPAND13_MAP_MIKROBUS( expand13_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == expand13_init( &expand13, &expand13_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    expand13_enable_device ( &expand13 );
    log_info( &logger, " Application Task " );
}

void loop() {
    uint8_t port_value[ 6 ] = { 0 };
    uint16_t pin_num = 0;

    for ( pin_num = EXPAND13_PIN_0_MASK; pin_num <= EXPAND13_PIN_7_MASK; pin_num <<= 1 )
    {
        if ( !expand13_get_int_pin ( &expand13 ) )
        {
            log_printf( &logger, " External input has occurred.\r\n" );
        }

        memset ( port_value, pin_num, 6 );
        expand13_write_all_ports( &expand13, port_value );

        expand13_read_all_ports( &expand13, port_value );
        for ( uint8_t cnt = EXPAND13_PORT_0; cnt <= EXPAND13_PORT_5; cnt++ )
        {
            log_printf( &logger, " Status port %d : 0x%.2X\r\n", ( uint16_t ) cnt, ( uint16_t ) port_value[ cnt ] );
        }
        log_printf( &logger, "\n" );
        Delay_ms ( 1000 );
    }
}

Thank you.

What error(s) does it produce? What board are you compiling it for?

Hi,

I am only compiling this on the Arduino IDE software at the moment but will be using my final code on an Arduino MEGA 2560.

The error code I have been receiving in the output window is:

 #include "drv_digital_out.h"
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1

How did you install the library for the Expand 13 module?

Yes, I understand. What board is the IDE set to when you compile the code?

Assuming that the compiler error message you posted is incomplete and somewhere it said that it couldn't find drv_digital_out.h then it seems like it's missing from the zip. Although IDK exactly what you downloaded to get the code and library.

Those libraries are not usable with any Arduino board that uses an AVR processir like the Mega 2560.
You need to find a Mega compatible library.

I had a quick look; it seems like the MikroE library relies on further MikroE-specific libraries. Looks like it'd be a chore to try and rework it for Arduino.

@chimney12 try this instead: GitHub - Blueprint-Foundry/PI4IOE5V96248_Arduino_Library: Arduino Library for PI4IOE5V96248
Alternatively stay within the MikroE ecosystem and use their development tools, but I imagine this may turn out to be the more costly option.

Thank you for the help.

Thank you, I will try this library then and hopefully can fiddle it to work.

1 Like