Atom DTU LoRaWAN-Series(RAK3172) Base
SKU: A152-CN470, A152-US915, A152-EU868
The Atom DTU LoRaWAN-Series is a LoRaWAN programmable data transfer unit (DTU) based on the STM32WLE5 chip. The module supports long-range communication, low-power operation, and high sensitivity characteristics, making it suitable for IoT communication needs in a variety of complex environments.
Frequency band support: CN470 (470MHz), EU868 (868MHz), US915 (915MHz)
Communication protocol:
Supports LoRaWAN Class A, Class B, Class C modes
Supports LoRa Point-to-Point (P2P) communication mode.
Communication Interface:
UART interface: Used to send AT commands to control LoRaWAN network access, data sending/receiving, P2P mode communication, etc.
RS485 interface: supports wired communication of industrial equipment with high reliability.
Internet access method:
OTAA (Over-The-Air Activation)
ABP (Activation By Personalization)
Support the following products:
Micropython LoRaWAN-EU868 LoRaWAN OTAA Mode Example:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import RGB 9from base import AtomDTULoRaWANRUI3Base 10 11 12rgb = None 13base_lorawaneu868 = None 14 15 16def setup(): 17 global rgb, base_lorawaneu868 18 19 M5.begin() 20 rgb = RGB() 21 base_lorawaneu868 = AtomDTULoRaWANRUI3Base(2, port=(19, 22)) 22 base_lorawaneu868.set_network_mode(1) 23 base_lorawaneu868.set_otaa_config( 24 "70B3D57ED007006A", "A843ECB026197C981D67AEFACC72D01E", "70B3D57ED0063472" 25 ) 26 base_lorawaneu868.set_rx_delay_on_window1(1) 27 base_lorawaneu868.set_rx_delay_on_window2(2) 28 base_lorawaneu868.set_rx_data_rate_on_windows2(0) 29 base_lorawaneu868.set_lorawan_node_class("C") 30 if base_lorawaneu868.join_network(10000): 31 print("Success join the network") 32 rgb.fill_color(0x33FF33) 33 base_lorawaneu868.send_data(1, "AABBCC", 0) 34 else: 35 print("Failed Join to the network") 36 rgb.fill_color(0xFF0000) 37 38 39def loop(): 40 global rgb, base_lorawaneu868 41 M5.update() 42 if BtnA.wasPressed(): 43 if (base_lorawaneu868.get_received_data_count()) != 0: 44 print(base_lorawaneu868.get_received_data_string()) 45 else: 46 print("Message queue is empty") 47 48 49if __name__ == "__main__": 50 try: 51 setup() 52 while True: 53 loop() 54 except (Exception, KeyboardInterrupt) as e: 55 try: 56 from utility import print_error_msg 57 58 print_error_msg(e) 59 except ImportError: 60 print("please update to latest firmware")
Micropython LoRaWAN-EU868 P2P Mode TX Example:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import RGB 9from base import AtomDTULoRaWANRUI3Base 10 11 12rgb = None 13base_lorawaneu868 = None 14 15 16def setup(): 17 global rgb, base_lorawaneu868 18 19 M5.begin() 20 rgb = RGB() 21 base_lorawaneu868 = AtomDTULoRaWANRUI3Base(2, port=(19, 22)) 22 base_lorawaneu868.set_network_mode(0) 23 base_lorawaneu868.set_p2p_frequency(600000000) 24 base_lorawaneu868.set_p2p_spreading_factor(7) 25 base_lorawaneu868.set_p2p_bandwidth(0) 26 base_lorawaneu868.set_p2p_tx_power(14) 27 base_lorawaneu868.set_p2p_code_rate(0) 28 base_lorawaneu868.set_p2p_preamble_length(8) 29 print("Press the button to send P2P message") 30 31 32def loop(): 33 global rgb, base_lorawaneu868 34 M5.update() 35 if BtnA.wasPressed(): 36 base_lorawaneu868.send_p2p_data("AABBCC", timeout=0, to_hex=False) 37 38 39if __name__ == "__main__": 40 try: 41 setup() 42 while True: 43 loop() 44 except (Exception, KeyboardInterrupt) as e: 45 try: 46 from utility import print_error_msg 47 48 print_error_msg(e) 49 except ImportError: 50 print("please update to latest firmware")
Micropython LoRaWAN-EU868 P2P Mode RX Example:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import RGB 9from base import AtomDTULoRaWANRUI3Base 10 11 12rgb = None 13base_lorawaneu868 = None 14 15 16def setup(): 17 global rgb, base_lorawaneu868 18 19 M5.begin() 20 rgb = RGB() 21 base_lorawaneu868 = AtomDTULoRaWANRUI3Base(2, port=(19, 22)) 22 base_lorawaneu868.set_network_mode(0) 23 base_lorawaneu868.set_p2p_frequency(600000000) 24 base_lorawaneu868.set_p2p_spreading_factor(7) 25 base_lorawaneu868.set_p2p_bandwidth(0) 26 base_lorawaneu868.set_p2p_tx_power(14) 27 base_lorawaneu868.set_p2p_code_rate(0) 28 base_lorawaneu868.set_p2p_preamble_length(8) 29 print("Press the button to send P2P message") 30 31 32def loop(): 33 global rgb, base_lorawaneu868 34 M5.update() 35 if BtnA.wasPressed(): 36 base_lorawaneu868.send_p2p_data("AABBCC", timeout=0, to_hex=False) 37 38 39if __name__ == "__main__": 40 try: 41 setup() 42 while True: 43 loop() 44 except (Exception, KeyboardInterrupt) as e: 45 try: 46 from utility import print_error_msg 47 48 print_error_msg(e) 49 except ImportError: 50 print("please update to latest firmware")
UIFLOW2 LoRaWAN-EU868 LoRaWAN OTAA Mode Example:
UIFLOW2 LoRaWAN-EU868 P2P Mode TX Example:
UIFLOW2 LoRaWAN-EU868 P2P Mode RX Example:
API
AtomDTULoRaWANRUI3Base
- class base.dtu_lorawan_rui3.AtomDTULoRaWANRUI3Base(id=2, port=None, debug=False)
基类:
RUI3Create an AtomDTULoRaWANRUI3Base object.
- 参数:
MicroPython Code Block:
from base import AtomDTULoRaWANRUI3Base lorawan_rui3 = AtomDTULoRaWANRUI3Base(2, port=(19, 22))
- set_abp_config(dev_addr, apps_key, nwks_key)
Configure the device for ABP (Activation By Personalization) mode.
- 参数:
- 返回类型:
None
MicroPython Code Block:
lorawan_rui3.set_abp_config( dev_addr="26011D89", apps_key="2B7E151628AED2A6ABF7158809CF4F3C", nwks_key="2B7E151628AED2A6ABF7158809CF4F3C" )
- get_abp_config()
Retrieve the current ABP configuration.
MicroPython Code Block:
print(lorawan_rui3.get_abp_config())
- set_otaa_config(device_eui, app_key, app_eui)
Configure the device for OTAA (Over-The-Air Activation) mode.
- 参数:
- 返回类型:
None
MicroPython Code Block:
lorawan_rui3.set_otaa_config( device_eui="2CF7F1C0420000AA", app_key="2B7E151628AED2A6ABF7158809CF4F3C" app_eui="80000000000000AA", )
- class driver.rui3.RUI3(id, tx, rx, debug=False)
基类:
object- get_received_data()
Retrieve the data from the last received message.
- 返回:
A tuple containing the port number (int) and the received data (bytes), or False if no data was received.
- 返回类型:
MicroPython Code Block:
data = lorawan_rui3.get_received_data() if data: print(f"Received data: {data}") else: print("No data received.")
- get_received_data_string()
Retrieve the received data as a string.
- 返回:
The received data as a string, or an empty string if no data was received.
- 返回类型:
MicroPython Code Block:
data = lorawan_rui3.get_received_data_string() if data: print(f"Received data: {data}") else: print("No data received.")
- get_received_data_count()
Retrieve the number of received data.
- 返回:
The number of received data.
- 返回类型:
MicroPython Code Block:
count = lorawan_rui3.get_received_data_count() print(f"Received data count: {count}")
- reset_module_to_default()
Reset the module to its factory default settings.
MicroPython Code Block:
rui3.reset_module_to_default()
- get_device_eui()
Get the device EUI.
- 返回:
The device EUI.
- 返回类型:
MicroPython Code Block:
lorawan_rui3.get_device_eui()
- set_join_config(state, auto_join, reattempt_interval=8, max_attempts=0, timeout=8000)
Configure the join parameters for LoRaWAN.
The configuration does not confirm network join success.
- 参数:
state (int) – The join state to configure, as an integer.
auto_join (int) – The auto-join flag, as an integer.
reattempt_interval (int) – The interval between join retries, in seconds. Default is 8.
max_attempts (int) – The maximum number of retries. Default is 0 (no limit).
timeout (int) – The timeout duration in milliseconds for the command. Default is 8000ms.
- 返回:
True if the command is successfully set, else False.
- 返回类型:
MicroPython Code Block:
lorawan_rui3.set_join_config( state=1, auto_join=1, reattempt_interval=10, max_attempts=5, timeout=10000 )
- join_network(timeout=8000)
Join the LoRa network using predefined join parameters.
- 参数:
timeout (int) – The timeout duration in milliseconds for the join command. Default is 8000ms.
- 返回:
True if the command is successfully set, else False.
- 返回类型:
bool

MicroPython Code Block:
if lorawan_rui3.join_network(timeout=10000): print("Network joined successfully!") else: print("Failed to join network.")
- set_join_mode(mode)
Set the join mode for the LoRa module.
- 参数:
mode (int) – The join mode to set, 0 for ABP or 1 for OTAA.
- 返回:
True if the command is successfully set, else False.
- 返回类型:
MicroPython Code Block:
lorawan_rui3.set_join_mode(1) # Set to OTAA mode
- get_join_state()
Check whether the module has successfully joined the network.
- 返回:
True if joined, otherwise False.
- 返回类型:
MicroPython Code Block:
if lorawan_rui3.get_join_state(): print("Module is joined to the network.") else: print("Module is not joined to the network.")
- get_last_receive()
Retrieve the data from the last received message.
- 返回:
A tuple containing the port number (int) and the received data (bytes), or False if no data was received.
- 返回类型:
MicroPython Code Block:
last_data = lorawan_rui3.get_last_receive() if last_data: port, data = last_data print(f"Received data on port {port}: {data}") else: print("No data received.")
- send_data(port, data, timeout=600)
Send data through a specific port.
- 参数:
- 返回:
True if the data was sent successfully, otherwise False.
- 返回类型:
bool

MicroPython Code Block:
success = lorawan_rui3.send_data(port=1, data=b"HelloLoRa", timeout=800) if success: print("Data sent successfully!") else: print("Failed to send data.")
- set_network_mode(mode)
Set the network mode for the device.
- 返回:
The result of the AT command execution.
- 返回类型:
- 参数:
mode (int) –
The mode to set for the network:
0 = P2P_LORA
1 = LoRaWAN
2 = P2P_FSK
MicroPython Code Block:
lorawan_rui3.set_network_mode(0) # Set to P2P_LORA mode
- get_p2p_frequency()
Retrieve the current P2P frequency.
- 返回:
The current P2P frequency as an integer.
- 返回类型:
MicroPython Code Block:
frequency = lorawan_rui3.get_p2p_frequency() print(f"Current P2P frequency: {frequency} Hz")
- set_p2p_frequency(frequency)
Set the P2P frequency for the device.
- 返回:
The result of the AT command execution.
- 返回类型:
- 参数:
frequency (int) –
The frequency to set for P2P communication.
Low-frequency range: 150000000-600000000
High-frequency range: 600000000-960000000
MicroPython Code Block:
success = lorawan_rui3.set_p2p_frequency(433000000) if success: print("P2P frequency set successfully!") else: print("Failed to set P2P frequency.")
- get_p2p_spreading_factor()
Retrieve the current P2P spreading factor.
- 返回:
The current P2P spreading factor as an integer.
- 返回类型:
MicroPython Code Block:
sf = lorawan_rui3.get_p2p_spreading_factor() print(f"Current P2P spreading factor: {sf}")
- set_p2p_spreading_factor(spreading_factor)
Set the P2P spreading factor.
- 参数:
spreading_factor (int) –
The spreading factor to set for P2P communication.
Range is 5 to 12.
- 返回:
The result of the AT command execution.
- 返回类型:
MicroPython Code Block:
success = lorawan_rui3.set_p2p_spreading_factor(10) if success: print("P2P spreading factor set successfully!") else: print("Failed to set P2P spreading factor.")
- get_p2p_bandwidth()
Retrieve the current P2P bandwidth.
- 返回:
The current P2P bandwidth as an integer.
- 返回类型:
MicroPython Code Block:
bw = lorawan_rui3.get_p2p_bandwidth() print(f"Current P2P bandwidth: {bw}")
- set_p2p_bandwidth(bandwidth)
Set the P2P bandwidth.
- 参数:
bandwidth (int) –
The bandwidth to set for P2P communication.
- For LoRa:
0 = 125 kHz
1 = 250 kHz
2 = 500 kHz
3 = 7.8 kHz
4 = 10.4 kHz
5 = 15.63 kHz
6 = 20.83 kHz
7 = 31.25 kHz
8 = 41.67 kHz
9 = 62.5 kHz
- For FSK:
Range: 4800-467000 Hz
- 返回:
The result of the AT command execution.
- 返回类型:
bool


MicroPython Code Block:
success = lorawan_rui3.set_p2p_bandwidth(1) # Set to 250 kHz if success: print("P2P bandwidth set successfully!") else: print("Failed to set P2P bandwidth.")
- get_p2p_code_rate()
Retrieve the current P2P code rate.
- 返回:
The current P2P code rate as an integer.
- 返回类型:
MicroPython Code Block:
code_rate = lorawan_rui3.get_p2p_code_rate() print(f"Current P2P code rate: {code_rate}")
- set_p2p_code_rate(code_rate)
Set the P2P code rate.
- 参数:
code_rate (int) –
The code rate to set for P2P communication.
0 = 4/5
1 = 4/6
2 = 4/7
3 = 4/8
- 返回:
The result of the AT command execution.
- 返回类型:
MicroPython Code Block:
success = lorawan_rui3.set_p2p_code_rate(1) # Set to 4/6 if success: print("P2P code rate set successfully!") else: print("Failed to set P2P code rate.")
- get_p2p_preamble_length()
Retrieve the current P2P preamble length.
- 返回:
The current P2P preamble length as an integer.
- 返回类型:
MicroPython Code Block:
preamble_length = lorawan_rui3.get_p2p_preamble_length() print(f"Current P2P preamble length: {preamble_length}")
- set_p2p_preamble_length(length)
Set the P2P preamble length.
- 返回:
The result of the AT command execution.
- 返回类型:
- 参数:
length (int) –
The preamble length to set for P2P communication.
Range is 5 to 65535.
MicroPython Code Block:
success = lorawan_rui3.set_p2p_preamble_length(16) if success: print("P2P preamble length set successfully!") else: print("Failed to set P2P preamble length.")
- get_p2p_tx_power()
Retrieve the current P2P transmission power.
- 返回:
The current P2P transmission power as an integer.
- 返回类型:
MicroPython Code Block:
tx_power = lorawan_rui3.get_p2p_tx_power() print(f"Current P2P transmission power: {tx_power} dBm")
- set_p2p_tx_power(power)
Set the P2P transmission power.
- 参数:
power (int) –
The transmission power to set for P2P communication.
Range is 5 to 22 dBm.
- 返回:
The result of the AT command execution.
- 返回类型:
MicroPython Code Block:
success = lorawan_rui3.set_p2p_tx_power(20) # Set to 20 dBm if success: print("P2P transmission power set successfully!") else: print("Failed to set P2P transmission power.")
- get_p2p_fsk_bitrate()
Retrieve the current P2P FSK bitrate.
- 返回:
The result of the AT command execution.
- 返回类型:
MicroPython Code Block:
fsk_bitrate = lorawan_rui3.get_p2p_fsk_bitrate() print(f"Current P2P FSK bitrate: {fsk_bitrate} b/s")
- set_p2p_fsk_bitrate(bitrate)
Set the P2P FSK bitrate.
- 参数:
bitrate (int) –
The bitrate to set for P2P FSK communication.
Range is 600 to 300000 b/s.
- 返回:
The result of the AT command execution.
- 返回类型:
MicroPython Code Block:
success = lorawan_rui3.set_p2p_fsk_bitrate(9600) # Set to 9600 b/s if success: print("P2P FSK bitrate set successfully!") else: print("Failed to set P2P FSK bitrate.")
- send_p2p_data(payload, timeout=1000, to_hex=False)
Send P2P data with a given payload.
- 参数:
payload (str) –
The payload to send.
Length must be between 2 and 500 characters.
Must consist of an even number of characters composed of 0-9, a-f, A-F, representing 1 to 256 hexadecimal values.
timeout (int) – The timeout for the data transmission, in milliseconds. Default is 1000 ms.
to_hex (bool) – Indicates whether to convert the payload to hexadecimal format. Default is False.
- 返回:
True if the data was sent successfully (“TXFSK DONE” or “TXP2P DONE”), False otherwise.
- 返回类型:
bool

MicroPython Code Block:
success = lorawan_rui3.send_p2p_data("abcdef", timeout=2000, to_hex=True) if success: print("P2P data sent successfully!") else: print("Failed to send P2P data.")
- get_p2p_receive_data(timeout=500, to_str=False)
Receive data in P2P mode, including RSSI, SNR, and payload.
- 参数:
- 返回:
A tuple (RSSI, SNR, Payload) if data is received; False if no data is received.
- 返回类型:
MicroPython Code Block:
result = lorawan_rui3.get_p2p_receive_data(timeout=1000, to_str=True) if result: rssi, snr, payload = result print(f"Received data - RSSI: {rssi}, SNR: {snr}, Payload: {payload}") else: print("No data received.")
- get_p2p_sync_word()
Get the current sync word in P2P mode.
- 返回:
The sync word as a string.
- 返回类型:
MicroPython Code Block:
sync_word = lorawan_rui3.get_p2p_sync_word() print(f"Current P2P sync word: {sync_word}")
- set_p2p_sync_word(sync_word)
Set the sync word in P2P mode.
- 参数:
sync_word (int) –
The sync word value.
Must be in the range of 0x0000 to 0xFFFF.
- 返回:
The response from the command execution.
- 返回类型:
MicroPython Code Block:
success = lorawan_rui3.set_p2p_sync_word(0x1234) if success: print("P2P sync word set successfully!") else: print("Failed to set P2P sync word.")





