RAK3172 EVB and Arduino Uno

Hello!

I am creating an Air Quality Monitoring System. I am using Arduino Uno to control my relay, fan, and PM Sensor. The RAK3172 will be my LoRa module to connect it to TTN. My problem is that my Arduino and RAL3172 are not communicating. Can you help me with the code for this please? I am not familiar with RAK.

Thank you very much

Welcome to the forum @eleeeyn

The RAK3172 is using AT commands over UART.

(1) As far as I know, the Arduino UNO has 5V signal level on its UARTS. The RAK3172 is a 3.3V device, so you need logic level shifters between the two.

(2) For communication using AT commands, you can have a look at the RUI3-Arduino-Library, which provides some Arduino code examples.

Thank you @beegee . Can I ask for an example syntax to connect arduino with RAK? Sorry I am not really good at programming :frowning:

The library has some examples. I tested with an ESP32 MCU, but it should work on a Arduino UNO, but I don’t have that board, so I can’t test.

image

The red marked examples are for Arduino IDE, the other examples are for PlatformIO.

Thank you! And one more thing. I just noticed that if I change the baud rate of RAK3172, it does not save. so everytime I remove the device it goes back to the default. i think this is the reason why my Arduino uno and RAK3172 are not communicating. BTW, I am using 3.4.11 ver

RUI3 V3.4.11 is an very old firmware of the RAK3172. I am not sure if the baudrate was saved in that version.

Latest version for RAK3172 is V4.2.1 and it does save the baudrate.

Firmware update of RAK3172 ==> RAK3172 WisDuo Evaluation Board Quick Start Guide

I already updated the firmware to v4.2.1. the rak is able to join the TTN and I successfully changed the baud rate to 9600. however the arduino is still not communicating with the RAK. This is my sample code.

#include <SoftwareSerial.h>

// D11 = RX (Arduino reads from RAK TX)
// D10 = TX (Arduino writes to RAK RX)
SoftwareSerial rakSerial(11, 10);

void setup() {
Serial.begin(9600); // Serial Monitor
rakSerial.begin(9600); // Communication with RAK

delay(2000); // Give RAK time to power up

Serial.println(“Sending AT…”);
rakSerial.print(“AT\r\n”); // Send AT command with proper line endings
}

void loop() {
// Read replies from RAK
if (rakSerial.available()) {
char c = rakSerial.read();
Serial.write(c); // Show it in Serial Monitor
}
}

How do you connect?

I realize now that you have the Evaluation Board, is that correct?

The Evaluation Board is using the USB port for AT command communication. The RX0/TX0 UART cannot be used for AT command communication.

For your application it would be better to use the RAK3272 Breakout Board. This has the UART2 on the pin headers to communicate with a host MCU like your Arduino UNO.

Yes I have the RAK3172 EVB. I connect the RX and TX of RAK3172 using logic level shifter going to Arduino. This will not work?

If that so, can the RAK3172 control relay, fan, and the sensor?

RX and TX of the pin headers will not work.

The RAK3172 can do all the stuff you want to do with a custom application written with ArduinoIDE.

We have the RUI3 API, which is a Arduino BSP and allows you to write custom firmware for the RAK3172. The RUI3 API includes the complete LoRa P2P and LoRaWAN communication functionality. RUI3 API includes as well the full AT command interface.

We have a lot of example code for sensors, relays and other actuators in our RUI3 Best Practices.

RUI3 API ==> RUI3 | Unified IoT Development API for LoRaWAN

RUI3 Best Practices examples ==> GitHub - RAKWireless/RUI3-Best-Practice: This repo provides additional examples for RUI3. It focuses on low power consumption and practical examples for range tests, location tracking and sensing applications using the WisBlock Modular System.

For sensors, relays and other interfaces you can use the Evaluation Board and add WisBlock Sensors and IO modules ==> Modular IoT System of Modules for Building Custom LPWAN IoT Projects

Ohhh, that’s the reason why my Arduino can’t communicate with the RAK. :frowning:

If I’ll try to connect sensors, fan and relay, which pins can I use in the RAK?

You can’t connect them directly, you need

If you have all external components already, you can try to use the IO Module RAk13001. But keep in mind, the GPIO’s of the RAK3172 have a limited output current and are 3.3V level only. You cannot control a relay directly with them.

you mean i can’t use my existing sensors such as PMS5003 and relays? :frowning:

It depends.
If your relays can be controlled with 3.3V they could work.
I don’t know the PMS5003, what kind of sensor is it and what interface does it have?

it’s a Particulate Matter sensor. and has the pins: VCC GND TX and RX.

We have the same, but as a I2C version.
It could work if you have a 5V supply. WisBlock BaseBoard doesn’t provide 5V.