Skip to content

3.5inch_Lesson07_LoRaWAN_AT_Command

1. Course Introduction

This lesson uses the CrowPanel Advance 3.5inch ESP32-S3 development board, the SX1262/LoRaWAN wireless module, and the ThinkNode-G1 gateway to complete LoRaWAN network join and data transmission. Learners first configure the G1 gateway to connect to the network and access TTN, then configure parameters such as DevEUI, JoinEUI/AppEUI, AppKey, and frequency band via serial AT commands, and finally perform the network join and uplink transmission.

The focus of this lesson is not simply flashing code, but completing the entire chain of "gateway, TTN platform, end-device parameters, AT commands, wireless transmission, and platform data."

2. Learning Objectives

  • Be able to register the G1 gateway on the TTN platform, create an Application, and register an OTAA end device.
  • Be able to use SSCOM or similar serial tools to send AT commands and configure DevEUI, JoinEUI/AppEUI, AppKey, frequency band, and join method.
  • Be able to explain the relationship among AT command parsing, the command table, and callback functions.
  • Be able to determine whether the network join and transmission succeeded based on RadioLib return codes, serial logs, and TTN Live data.

3. Preparation

  • Hardware: CrowPanel Advance 3.5inch ESP32-S3 development board, SX1262/LoRaWAN wireless module, antenna.
  • Gateway: ThinkNode-G1 LoRaWAN gateway.
  • Cables: Type-C USB data cable that supports data transfer.
  • Software: Arduino IDE and the ESP32 Arduino development environment, SSCOM serial debugging tool.
  • Platform account: The Things Network account.
  • Project: sendATcommands_3.5.ino.
  • Tool: lesson-07/tool/SSCOM.zip.

Note: The LoRaWAN frequency band must match the gateway, the TTN Frequency plan, and the end-device AT commands at the same time. When the frequency bands are inconsistent, the serial port may show a transmission action, but the platform will not receive any data.

Code and Resource Download

Code download: - lesson-07

4. Software Operation Steps

4.1 Overall Experiment Flow

The software operations in this lesson proceed in the order of "open the project and flash the program -> configure the G1 gateway and TTN platform -> send AT commands using SSCOM -> view data on TTN."

  1. Open the 3.5inch LoRaWAN AT project using Arduino IDE.
  2. Configure the board, port, Flash Size, PSRAM, and Partition Scheme as described in Lesson01.
  3. Compile and flash sendATcommands_3.5.ino.
  4. Configure the ThinkNode-G1 gateway networking method and Packet Forwarder.
  5. Register the G1 gateway on the TTN platform, and create an Application and an End device.
  6. Use SSCOM to send AT commands, configure the node parameters, perform the network join, and send data.
  7. View the data uploaded by the node on the TTN Live data page.

4.2 Open and Flash the 3.5inch Project

  1. Open this lesson's project using Arduino IDE: image-20260730164401958 image-20260730164436897
lesson-07/code/sendATcommands_3.5/sendATcommands_3.5.ino
  1. Insert the wireless module into the CrowPanel Advance 3.5inch development board and install the antenna. Connect the development board to the computer using a Type-C USB cable that supports data transfer.

IMG_8135

  1. In the Tools menu of Arduino IDE, confirm the following parameters:
Board: ESP32S3 Dev Module
Port: select the serial port corresponding to the current board
Flash Size: 16MB (128Mb)
PSRAM: OPI PSRAM
Partition Scheme: Huge APP (3MB No OTA/1MB SPIFFS)
Serial Monitor baud: 115200

image-20260729155105951

  1. Click Upload to compile and wait for the upload to complete. If it hangs at Connecting..., check for port occupation and use BOOT/RESET download mode as required by the board. image-20260730165323687

image-20260730165446018

Note: If you find that the board behaves abnormally during the flashing stage, remove the wireless module first and then upload the program. After confirming that the program is written successfully, plug the module back in.

After the program is flashed, this lesson does not use the Arduino IDE Serial Monitor as the primary input tool. Instead, SSCOM is used to send AT commands. The SSCOM baud rate should also be set to 115200.

4.3 G1 Gateway Configuration, TTN Registration, End Device Creation, and SSCOM AT Commands

4.3.1 G1 Gateway Network Configuration

The G1 gateway supports three networking methods: Ethernet, Wi-Fi, and 4G cellular network, of which 4G is only available for the 4G version. This lesson uses Wi-Fi as the networking method.

  1. Press and hold the gateway button for about 5 seconds until the top indicator light slowly blinks blue, and the device enters configuration mode.

wireless_module1

3.5_Arduino-07_08

  1. Connect to the AP hotspot. The hotspot name is ThinkNode-G1_XXXXXX, where XXXXXX is the 6-digit MAC address. This hotspot is open by default and can be connected directly without a password.

wireless_module2

  1. Enter 192.168.1.1 in the browser to access the local console. Enter root for both the username and password.

wireless_module3

  1. After logging into Luci, click Network > Wireless.

wireless_module4

  1. Click Scan to scan for nearby Wi-Fi networks.

wireless_module5

  1. Select the Wi-Fi network to connect to and click Join Network.

wireless_module6

  1. Enter the Wi-Fi password, click Submit, and then save the settings.

wireless_module7

wireless_module8

  1. On the Luci page, click LoRaWAN, go to the LoRa Gateway page, and set the network configuration mode to WiFi.

wireless_module9

wireless_module10

  1. Set the gateway working mode to Packet Forwarder.

wireless_module17

  1. Configure the Packet Forwarder. Gateway EUI automatically obtains the EUI of the currently connected gateway; enter the The Things Stack deployment address in Server address; Server Ports (Up/Down) is generally set to 1700.

    wireless_module18

  2. Configure Region and Frequency plans, and click Save & Apply. The frequency band here must be consistent with the TTN platform and the end-device AT commands.

    wireless_module19

    wireless_module11

  3. Double-click the gateway reset button and wait for the device to restart. If the gateway successfully connects to Wi-Fi, the WLAN green indicator light stays solid, and the top indicator light also remains green.

    3.5_Arduino-07_22

4.3.2 Register the Gateway on the TTN Platform

  1. Open The Things Network and log in to the TTN account.

wireless_module12

  1. Register the gateway, fill in the EUI, and click Confirm.

wireless_module62

wireless_module13

Gateway ID is usually written as eui-gatewayEUI and may only use lowercase letters, numbers, and hyphens.

  1. Fill in the Gateway Name and select the Frequency Plan that matches the gateway version.

wireless_module14

  1. After successful registration, you can view the gateway status on the Overview page.

wireless_module15

  1. Double-click the gateway settings button and wait for the restart. The gateway connects to TTN in Packet Forwarder mode.

wireless_module60

4.3.3 Create the TTN Node Application

  1. Click Applications in the TTN console.

wireless_module21

  1. Click Add application, fill in the Application ID and Application name, then click Create application.

wireless_module22

  1. On the application Overview page, click Register end device.

wireless_module23

  1. Select Enter end device specifics manually.

wireless_module24

  1. Set the Frequency plan, LoRaWAN version, Regional Parameters version, and JoinEUI.

wireless_module25

wireless_module26

wireless_module27

wireless_module28

wireless_module29

  1. Expand the advanced settings, configure it to OTAA mode, and click Confirm.

wireless_module30

wireless_module31

wireless_module32

  1. Click Generate to generate the DevEUI and AppKey, fill in the End device ID, then click Register end device.

wireless_module33

wireless_module34

wireless_module35

wireless_module36

After registration, save the DevEUI, JoinEUI/AppEUI, and AppKey from the Activation information.

wireless_module37

4.3.4 Set Up Join Nonces Reset

To make it easy to repeatedly test the network join during experiments, you can enable Resets join nonces in the TTN device settings.

  1. Go to Application > Application Name.

wireless_module63

  1. Click the node name to enter Settings.

wireless_module64

  1. Scroll to the bottom of the page and open Join Settings.

wireless_module47

  1. Enable Resets join nonces.

wireless_module48

4.3.5 Send AT Commands Using SSCOM

  1. Open the SSCOM serial tool, select the USB COM port recognized by the computer, then click EXT.

wireless_module54

  1. Set the serial parameters to 115200, check the carriage-return-line-feed option, and when opening the serial port, only check DTR.

  2. Send the following AT commands to configure the node parameters in order:

AT+BAND=0
AT+DEUI=70:B3:D5:7E:D0:06:****
AT+APPEUI=AA:AA:AA:AA:AA:AA:****
AT+APPKEY=49:0F:B4:80:37:F0:5E:6C:5C:B3:24:F5:B5:78:****

Replace DevEUI, AppEUI, and AppKey with the actual values from the TTN page.

wireless_module55

wireless_module56

  1. Send the network join command AT+JOIN and wait for the node to successfully join the network.

wireless_module57

  1. Send the data AT+SEND=10:0:1234, then check the data reported by the node on TTN's Applications > Live data page.

wireless_module58

wireless_module59

5. Hardware Operation Steps

  1. Insert the Wireless module-Meshtastic block into the W-M wireless module slot on the development board, and connect the CrowPanel Advance development board using a USB data cable.

wireless_module61

IMG_8135

6. Key Code Explanation

SX1262 radio = new Module(0, 1, 2, 46, SPI);
LoRaWANNode node(&radio, &Region_868, subBand);

radio defines how the SX1262 module is connected, and node defines the LoRaWAN node object. The frequency band and subBand must be consistent with the gateway, the TTN platform, and the AT commands.

const struct ATCommand_s ATCommand[AT_CMD_MAX] = { ... };

The command table binds command strings to callback functions. When adding a new command, you need to define the string and the callback function, and then register it in the table.

if (at_config.receiveSerialCmd(cmd_data_buf, &cmd_data_size)) {
  at_config.parseCmd((char *)cmd_data_buf, cmd_data_size);
}

The main loop first receives the serial command and then passes it to the parser. If the serial port does not respond, first check the baud rate, the carriage return/line feed format, and the SSCOM sending method.

if (OTAA_Join_Flag == 1) {
  node.beginOTAA(...);
  state = node.activateOTAA(joinDR);
}

AT commands do not perform the network join directly within the parser; instead, they set a flag, and the main loop then executes the actual wireless operation. This prevents the serial parsing logic from being entangled with the time-consuming network join operation.

7. Experimental Observations

After the end device is configured successfully, sending AT+JOIN in SSCOM will display network join related logs; after sending AT+SEND=10:0:1234, the data reported by the node can be viewed on TTN's Applications > Live data page.

wireless_module59

If the network join fails, first check the following items:

  • Whether the frequency band is consistent across the G1 gateway, the TTN gateway, the TTN end device, and the AT commands.
  • Whether the Gateway EUI is correctly entered on TTN.
  • Whether DevEUI, JoinEUI/AppEUI, and AppKey exactly match those on the TTN end device page.
  • Whether the G1 gateway is connected to the network and properly linked to TTN.
  • Whether SSCOM is using the 115200 baud rate and appending a carriage return/line feed when sending.
  • Whether the wireless module is correctly seated in the development board, and whether the development board port and hardware connections were completed as described in Lesson 1.

8. Code Download

Code download path: lesson-07