Module for UART type sensors

I’ve several sensors with UART output, Is there any examples how to access UART with wisblock module? Regards

Hi @siwilis ,

If you are using RAK4631 then you have 2 UART available. RAK4631 has a native USB peripheral onboard (Serial) which is used for programming and Serial debugging and two usable hardware UART1 and UART2 (Serial 1 and Serial 2). UART1 is accessible to WisBlock Slot A, WisBlock IO slot, and the exposed header pins. UART2 is accessible only on the WisBlock IO slot. You need an WisBlock Interface module to have access with UART2.

Have a look on some details here.

You can use these WisBlock Interface modules to have access on the UART2.

Could you provide a code example to use UART with the RAK 13002? On your page, RAK13002 Quick Start Guide | RAKwireless Documentation Center, there is only I2C, GPIO, and ADC. I’d like a minimal working example to find an entry working with UART. My setup is two RAK4630 + RAK13002 wisblocks where I want to send some data back and forth. Thanks!

Welcome to RAK forum @jrs ,

As a quick test, you can do this connection for your two RAK13002.

You need to connect
GND-GND
TX1-RX1
RX1-TX1

image

For the TX code:

#include"Wire.h"   //needed by RAK4631 if Serial is used

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() 
{
  if (Serial.available())   // check if input from USB
  {
    int inByte = Serial.read();  // get the input data
    Serial1.write(inByte);   // transmit via UART1
  }
}

For RX code:

#include"Wire.h"  //needed by RAK4631 if Serial is used

void setup() 
{
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() 
{
  if (Serial1.available())  // Check if new data is received via UART1
  {
    int inByte = Serial1.read(); // Get the data received.
    Serial.write(inByte);  // Print it via USB
  }
}

You should have something like this.

image

The left Hello is the transmitter message (input via USB).

The right Hello is just a display of message via USB too.

1 Like

Thank you very much, this worked! My problem was that I used the Rx0/Tx0 pins. I have two small questions:

  1. What’s the difference between the Rx0/Tx0 vs Rx1/Tx1?
  2. How do you input via USB, is there a special adapter for it you use?
  1. There are two UART peripherals on the RAK4631 chip. However, the RX0/TX0 is not yet supported by now. It will be on the next Arduino BSP update and can be accessed via Serial2.

  2. Do you mean how to input via USB on those pins? You need to use a USB-Serial adapter modules. There are many available. Our RAKDAP1 tool has that functionality too.

1 Like