RAK3172 Communication with Arduino UNO (RAK3172 cannot receive)

I want the RAK3172 module to communicate between UART2 and Arduino UNO using the Software.Serial library and to set the module as a transmitter when the button connected to the Arduino UNO board is pressed. I’m new to Lora and the embedded field. First, I send message 1 from my Arduino UNO card, but the lora module does not receive this message. The messages sent by the Lora module can be received by Arduino UNO. In this case, since Serial is used, I wrote simple codes in case the Lora module is a receiver. I’m adding it below. Please tell me where I’m doing wrong? Thank you.

Arduino UNO code:

#include <SoftwareSerial.h>

const int buttonPin = 2;    
const int loraRxPin = 10;   // LoRa  RX pini
const int loraTxPin = 11;   // LoRa  TX pini
const int ledPin = 13;     

SoftwareSerial loraSerial(loraRxPin, loraTxPin); 

void setup() {
  pinMode(buttonPin, INPUT);      
  pinMode(ledPin, OUTPUT);       
  Serial.begin(9600);             // Ana seri portu başlat
  loraSerial.begin(9600);         // LoRa modülü seri portunu başlat
}

void loop() {
  if (digitalRead(buttonPin) == HIGH) {
    loraSerial.println("1");
    Serial.println("1 değeri gönderildi");
    
    // LoRa wait response
    long timeout = millis() + 5000; // 5 saniye zaman aşımı süresi
    bool ackReceived = false;
    
    while (millis() < timeout) {
      if (loraSerial.available() > 0) {
        String response = loraSerial.readString();
        if (response.indexOf("ACK") != -1) {
          ackReceived = true;
          break;
        }
      }
    }
    
    if (ackReceived) {
      Serial.println("ACK are taken, message are sent successfully");
      digitalWrite(ledPin, HIGH);  
      delay(1000);             
      digitalWrite(ledPin, LOW);  
    } else {
      Serial.println("ACK are not taken, message are not send");
    }   
    delay(1000); 
  }
}
RAK3172 code:
#include <stdint.h>
#include <string.h>

void setup()
{
    Serial.begin(9600);
    delay(1000);
}

void loop()
{
  // Read messages from Arduino Uno
  if (Serial.available() > 0) {
    char received = Serial.read();
    delay(100); 

    Serial.print("Incoming message: ");
    Serial.println(received);

    // If the incoming message is '1', send 'ACK' message
    if (received == '1') {
      Serial.println("ACK");
      Serial.println("ACK are sent");
    }
  }
  delay(500);
}

Does your Arduino UNO have 3.3V levels on its RX and TX lines?
If not, you MUST put a voltage converter from 5V to 3.3V between your Arduino Uno and the RAK3172.

Using 5V levels on the RX/TX lines can damage the RAK3172.

For further help, check out the examples in the RUI3-Arduino-Library library I made for communication between a host MCU and WisDuo modules with RUI3.

Does your Arduino UNO have 3.3V levels on its RX and TX lines? -Yes

Thank you for your feedback, I will examine the examples.

I obtained 3.3V with a voltage divider by using 10k and 20k resistors while going from the Arduino UNO TX pin to the RAK3172 RX pin. Could this be a problem? There is no problem when the RAK3172 module sends messages to the Arduino UNO board, but they cannot do this mutually.

Resistors are not the best solution. A logic level converter like this one will do a better job

If you have a oscilloscope, you could check the signal quality of the Uno TX to RAK3172 RX lines.

Thanks for the quick response. Is it necessary to use RUI3 API functions for the RAK3172 module to communicate with the Arduino UNO board? Is there something wrong with the basic codes I mentioned in my question? I just don’t think I will encounter such a result since I do not use a voltage reducer. Apart from a LORA module like RAK3172, do the codes required to communicate with a device such as Arduino UNO have the same functions as Arduino UNO?

If you do not want AT commands, you have to initialize the Serial on the RAK3172 different.
There are different modes

RAK_AT_MODE 	AT command mode.
RAK_CUSTOM_MODE 	Custom mode

By default the Serial is in AT command mode. Which means whatever is received on the RAK3172 RX line is automatically handled by the AT command handler.

If you do not want to use AT commands, you have to use RAK_CUSTOM__MODE in the initialization

Serial.begin(9600, RAK_CUSTOM_MODE);

But then you loose all AT command functionality.

2 Likes