Skip to main content

RAK13003 WisBlock IO Expansion Module Quick Start Guide

Prerequisite

What Do You Need?

Before going through each and every step on using RAK13003 WisBlock module, make sure to prepare the necessary items listed below:

Hardware

Software

Arduino

Product Configuration

Hardware Setup

The RAK13003 is an IO expansion module that can be mounted to the IO slot of the WisBlock Baseboard. It offers 16 bidirectional I/O ports by using MCP23017 IC from Microchip. The configuration of this module is via the I2C interface, and it supports both standard and fast I2C modes.

Row/ColumnColumn 1Column 2Column 3Column 4
Row 1PA0PA1PB6PB7
Row 2PA2PA3PB4PB5
Row 3PA4PA5PB2PB3
Row 4PA6PA7PB0PB1
Row 5GNDVCCGNDVCC

For more information about RAK13003, refer to the Datasheet.

Figure 3022: RAK13003 Connection to WisBlock Base module

Assembling and Disassembling of WisBlock Modules

Assembling Procedure

The RAK13003 module can be mounted on the IO slot of the WisBlock Base board, as shown in Figure 2. Also, always secure the connection of the WisBlock module by using the compatible screws.

Figure 3023: RAK13003 mounting connection to WisBlock Base module
Disassembling Procedure

The procedure in disassembling any type of WisBlock modules is the same.

  1. First, remove the screws.
Figure 3024: Removing screws from the WisBlock module
  1. Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
Figure 3025: Detaching silkscreen on the WisBlock module
  1. Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the baseboard.
Figure 3026: Applying even forces on the proper location of a WisBlock module
NOTE

If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin Mapper tool for possible conflicts.

Software Configuration and Example

In the following example, you will be using the RAK13003 WisBlock IO Expansion Module to power LEDs.

Initial Test of the RAK13003 WisBlock Module

  1. Install the RAKwireless Arduino BSP's for WisBlock by using the package_rakwireless_index.json board installation package, the WisBlock Core should now be available on the Arduino IDE.

  2. Shown in Figure 6 is the illustration on how to use the RAK13003 IO Expansion Module to power ON LEDs using digitalWrite function.

Figure 3027: RAK13003 as Output to LEDs
  1. You need to select first the WisBlock Core you have, as shown in Figure 7 to Figure 9.
Figure 3028: Selecting RAK4631 as WisBlock Core
Figure 3029: Selecting RAK11200 as WisBlock Core
Figure 3030: Selecting RAK11300 as WisBlock Core
  1. Next, copy the following sample code into your Arduino IDE.
Click to view the code
/**
@file RAK13003_GPIO_Expander_IO_MCP32.ino
@author rakwireless.com
@brief Use IIC to expand 16 GPIO.
Configure PA input PB output, or PA output PB input.Serial port print GPIO status.
@version 0.2
@date 2022-5-11
@copyright Copyright (c) 2022
**/
#include <Wire.h>
#include "Adafruit_MCP23X17.h" //http://librarymanager/All#Adafruit_MCP23017

#define PAIN_PBOUT //PB is set as output here and PA as input.
//#define PAOUT_PBIN

Adafruit_MCP23X17 mcp;

void setup()
{
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, 1);

// Reset device
pinMode(WB_IO4, OUTPUT);
digitalWrite(WB_IO4, 1);
delay(10);
digitalWrite(WB_IO4, 0);
delay(10);
digitalWrite(WB_IO4, 1);
delay(10);

// Initialize Serial for debug output
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}

Serial.println("MCP23017 GPIO Input Output Test.");

mcp.begin_I2C(); // use default address 0.

#ifdef PAIN_PBOUT
for(int i=0 ;i < 8 ;i++)
{
mcp.pinMode(i, INPUT); // PA input.
}
for(int j=8 ;j < 16 ;j++)
{
mcp.pinMode(j, OUTPUT); // PB output.
}
mcp.digitalWrite(8, LOW); // The output state of the PB port can be changed to high or low level.
mcp.digitalWrite(9, HIGH); //PIN PB1
mcp.digitalWrite(10, LOW); //PIN PB2
mcp.digitalWrite(11, LOW); //PIN PB3

mcp.digitalWrite(12, LOW); //PIN PB4
mcp.digitalWrite(13, LOW); //PIN PB5
mcp.digitalWrite(14, LOW); //PIN PB6
mcp.digitalWrite(15, HIGH);//PIN PB7

Serial.println();
for(int i=0; i < 8; i++ )
{
if(mcp.digitalRead(i) == 1)
Serial.printf("GPIO A %d Read High\r\n",i);
else
Serial.printf("GPIO A %d Read Low\r\n",i);
}
#endif

#ifdef PAOUT_PBIN
for(int i=0 ;i < 8 ;i++)
{
mcp.pinMode(i, OUTPUT); // PA output.
}
for(int j=8 ;j < 16 ;j++)
{
mcp.pinMode(j, INPUT); // PB input.
}
mcp.digitalWrite(0, LOW); // The output state of the PA port can be changed to high or low level.
mcp.digitalWrite(1, HIGH); // PA1
mcp.digitalWrite(2, LOW); // PA2
mcp.digitalWrite(3, HIGH); // PA3

mcp.digitalWrite(4, LOW); // PA4
mcp.digitalWrite(5, HIGH); // PA5
mcp.digitalWrite(6, LOW); // PA6
mcp.digitalWrite(7, HIGH); //PA7
Serial.println();
for(int i=8; i < 16; i++ )
{
if(mcp.digitalRead(i) == 1)
Serial.printf("GPIO B %d Read High\r\n",i-8);
else
Serial.printf("GPIO B %d Read Low\r\n",i-8);
}
#endif
}
void loop()
{
mcp.digitalWrite(8, HIGH); //PIN PB0
delay(1000);
mcp.digitalWrite(8, LOW); //PIN PB0
delay(1000);
}
NOTE

If you experience any error in compiling the example sketch, check the updated code for the all WisBlock Core Module that can be found on the RAK13003 WisBlock Example Code Repository. Other examples like interrupt and pooling can be found in the github repository as well.

  1. Install the required library, as shown in Figure 10.
Figure 3031: Installing the Library
NOTE

The library version required must be at least ver 2.1.0 to compile the example code successfully.

  1. Select the correct port and upload your code, as shown in Figure 11 and Figure 12.
NOTE

If you're using the RAK11200 as your WisBlock Core, the RAK11200 requires the Boot0 pin to be configured properly first before uploading. If not done properly, uploading the source code to RAK11200 will fail. Check the full details on the RAK11200 Quick Start Guide.

Figure 3032: Selecting the correct Serial Port
Figure 3033: Uploading code
  1. When you have successfully uploaded the example sketch, you can see that the LEDs are powered ON and PB0 will have LED blinking output. You can also switch PB as INPUT and PA as OUTPUT by changing this line of code shown in Figure 13.
Figure 3034: Switching between PA and PB
NOTE

You can use mcp.digitalWrite(pin_no,state) and mcp.digitalRead(pin_no) to send or read states.