RAK11160 WisDuo LoRaWAN + BLE + WiFi Module Interface Access Using RUI3
This guide shows how to use RUI3 APIs to access the pinouts of RAK1160. It includes code examples for digital I/O, analog input, UART, and I2C, as well as pinout information for SPI.
Before using the examples in this guide, make sure you have completed the hardware setup and Arduino IDE installation described in the RAK11160 WisDuo Module Quick Start Guide.
Digital I/O Pins
Here‘s the available Digital IO Pins in RAK11160 (with notes on pins with Analog capability).
| Pad | GPIO |
|---|---|
| 3 | ST_PA8 |
| 4 | ST_PA9 |
| 7 | ST_PB2 / Analog(A2) |
| 8 | ST_PB12 |
| 9 | ST_PA10 / Analog(A3) |
| 14 | ST_PA15 / Analog(A4) |
| 32 | ST_PB3 / Analog(A0) |
| 33 | ST_PB4 / Analog(A1) |
| 34 | ST_PB5 |
| 35 | ST_PA1 |
The GPIO pins of the ESP8684 cannot be controlled by the STM32WLE5 directly.
Any of the pins listed in the table above can be used. Pins with specific functions, such as UART and I2C, are also usable but with limitations. Those dedicated pins have been excluded from this illustration of digital IO pins.
Click to view the example code.
/*
RAK11160 Digital I/O Example
You can use any of the following as Digital I/O:
ST_PA8 PA8
ST_PA9 PA9
ST_PB2 PB2
ST_PA10 PA10
ST_PB12 PB12
ST_PB3 PB3
ST_PB4 PB4
ST_PB5 PB5
ST_PA1 PA1
ST_PA15 PA15
*/
void setup()
{
pinMode(PA8, OUTPUT); //Change the PA8 to any digital pin you want. Also, you can set this to INPUT or OUTPUT
}
void loop()
{
digitalWrite(PA8,HIGH); //Change the PA8 to any digital pin you want. Also, you can set this to HIGH or LOW state.
delay(1000); // delay for 1 second
digitalWrite(PA8,LOW); //Change the PA8 to any digital pin you want. Also, you can set this to HIGH or LOW state.
delay(1000); // delay for 1 second
}
Analog Input Pins
Here‘s the available Analog input Pins in RAK11160.
| Pad | Analog in |
|---|---|
| 32 | ST_A0 |
| 33 | ST_A1 |
| 7 | ST_A2 |
| 9 | ST_A3 |
| 14 | ST_A4 |
Click to view the example code.
/*
RAK11160 Analog Input Pins
ST_PB5 PB5
ST_PA10 PA10
ST_PB3 PA3
ST_PB4 PB4
*/
#define analogPin PB5 // or you can use PB5
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(115200);
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Serial Interfaces
The RAK11160 provides UART, I2C, and SPI interfaces for communication with external devices.
UART
There is one UART peripheral available on the RAK11160. There are also different Serial Operating Modes possible in RUI3, namely AT Mode, and Custom Mode.
| Serial Port | Serial Instance Assignment | Default Mode |
|---|---|---|
| UART0 (Pin 41 - PB6)/(Pin 0 - PB7) | Serial | AT Command |
Click to view the example code.
void setup()
{
Serial.begin(115200); // By default Serial is used for FW update and AT command.
}
```c
void loop()
{
Serial1.println("RAK11160 TEST!");
delay(1000); // delay for 1 second
}
I2C
Make sure you have an I2C device connected to the specified I2C pins to run the example code.
| I2C | Pad | GPIO |
|---|---|---|
| SDA | 10 | PA11 |
| SCL | 11 | PA12 |
Click to view the example code.
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(115200);
while (!Serial);
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
SPI
Here‘s the available SPI Pins in RAK11160.
| SPI | Pad | GPIO |
|---|---|---|
| NSS | 42 | PA4 |
| SCK | 43 | PA5 |
| MISO | 44 | PA6 |
| MOSI | 45 | PA7 |
