Skip to content

4.3_5.0_7.0inch_Lesson07_LoRaWAN_AT_Commands

1. Course Introduction

This lesson completes the LoRaWAN communication configuration between the ThinkNode-G1 gateway, the TTN platform, and the wireless module of the CrowPanel Advance 4.3inch / 5.0inch / 7.0inch large-size boards.

The lesson first connects the G1 gateway to Wi-Fi and configures the Packet Forwarder, then registers the gateway on the TTN platform, creates an application and an end device, and finally uses the SSCOM serial tool to send AT commands to the development board, allowing the wireless module to join the LoRaWAN network via OTAA and upload data.

2. Learning Objectives

  • Be able to switch the ThinkNode-G1 gateway into configuration mode and connect it to Wi-Fi.
  • Be able to configure the LoRaWAN Packet Forwarder in the G1 local console.
  • Be able to register the G1 gateway, create an Application, and create an End device on the TTN platform.
  • Be able to use AT commands to configure the DevEUI, AppEUI, AppKey, and frequency band, and to complete network join and data transmission.
  • Be able to determine whether communication is working properly based on the RadioLib return values, the SSCOM responses, and the TTN Live data.

3. What You Need to Prepare

  • 1 × CrowPanel Advance 4.3inch / 5.0inch / 7.0inch large-size development board.
  • 1 × Wireless module-Meshtastic wireless module.
  • 1 × ThinkNode-G1 LoRaWAN gateway.
  • A Type-C USB data cable that supports data transfer.
  • Arduino IDE and the ESP32 Arduino development environment.
  • SSCOM serial debugging tool: 4.3_5.0_7.0_Arduino/lesson-07/tool/SSCOM.zip.
  • A The Things Network account.
  • The project for this lesson: 4.3_5.0_7.0_Arduino/lesson-07/code/sendATcommands_7.0/sendATcommands_7.0.ino.

Note: The LoRaWAN module belongs to the wireless module link. For large-size boards, the Function Keys / function DIP switch must be switched to 01, which corresponds to WM (wireless module). If a port anomaly occurs during flashing, you may first power off and unplug the wireless module; after the program is successfully flashed, plug the module back in and power the board on again.

Code and Resource Download

Code download: - Lesson07_LoRaWAN_AT_Command

4. Software Operation Steps

4.1 Overall Experiment Flow

The software operations for this lesson follow the sequence: "Open the project and flash the program → Configure the G1 gateway and TTN platform → Send AT commands using SSCOM → View data on TTN."

  1. Use Arduino IDE to open the project for this lesson, and confirm that the course library files have been placed into Arduino's libraries directory as described in Lesson01.
  2. Configure the board, port, Flash Size, PSRAM, and Partition Scheme as described in Lesson01.
  3. Compile and flash the LoRaWAN AT program.
  4. Configure the ThinkNode-G1 gateway's network connection 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 to configure the node parameters, perform network join, and send data.
  7. View the data uploaded by the node on TTN's Live data page.

4.2 Open and Flash the Project

  1. Use Arduino IDE to open the large-size project file:
4.3_5.0_7.0_Arduino\lesson-07\code\sendATcommands_7.0\sendATcommands_7.0.ino

image-20260731180456829

  1. Insert the wireless module into the W-M wireless module slot on the CrowPanel Advance development board, and connect the board to the computer using a Type-C USB cable that supports data transfer. For large-size boards, the Function Keys / function DIP switch must be switched to 01.

image-20260731180741021

  1. In the Arduino IDE Tools menu, confirm the parameters. This configuration is consistent with the large-size Arduino Lesson01:
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-20260731180658420

  1. Click Upload to compile and wait for the upload to complete. If it gets stuck at Connecting..., check for port conflicts and use BOOT/RESET download mode as required by the board.

image-20260731180943123

Note: 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. SSCOM's baud rate should also be set to 115200, and a carriage return and line feed must be sent.

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 network connection methods: Ethernet, Wi-Fi, and 4G cellular network, of which 4G is only applicable to the 4G version. This lesson uses Wi-Fi as an example.

  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

4.3_5.0_7.0_Arduino-07_06

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

wireless_module2

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

wireless_module3

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

wireless_module4

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

wireless_module5

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

wireless_module6

  1. Enter the Wi-Fi password, click Submit, 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's operating mode to Packet Forwarder.

wireless_module17

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

    wireless_module18

  2. Configure the Region and Frequency plans, then click Save & Apply. The frequency band configured 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 will stay solid, and the top indicator light will also remain green.

    4.3_5.0_7.0_Arduino-07_20

4.3.2 Register the Gateway on the TTN Platform

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

wireless_module12

  1. Register the gateway, enter the EUI, and click Confirm.

wireless_module62

wireless_module13

Gateway ID is typically written as eui-gatewayEUI, and may only contain 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 will connect to TTN as a Packet Forwarder.

wireless_module60

4.3.3 Create the TTN Node Application

  1. In the TTN console, click Applications.

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 Enable Join Nonces Reset

To facilitate repeated network join testing during the experiment, 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

wireless_module47

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

wireless_module47

  1. Enable Resets join nonces.

wireless_module48

4.3.5 Using SSCOM to Send AT Commands

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

wireless_module54

  1. Set the serial port parameters to 115200, check "Carriage return and line feed", 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:****

Here, DevEUI, AppEUI, and AppKey should be replaced 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 data AT+SEND=10:0:1234, then view the data reported by the node on the TTN Applications > Live data page.

wireless_module58

wireless_module59

5. Hardware Operation Steps

  1. After powering off, confirm that the Wireless module-Meshtastic is correctly inserted into the W-M wireless module slot on the development board.

wireless_module61

  1. Confirm that the antenna is properly connected, to avoid the wireless module transmitting without an antenna attached.

  2. Switch the function DIP switch to 01, then connect the CrowPanel Advance development board using a USB data cable.

  3. After the gateway, development board, and computer are all powered on, first confirm that the gateway is online, then execute the AT commands via SSCOM.

4.3_5.0_7.0_Arduino-07_02

Note: 01 is the wireless module channel for large-size boards. If the DIP switch is not set to 01, the serial port may function normally but the wireless module will not respond, which manifests as the AT commands having no actual network-join or transmission effect.

6. Key Code Explanation

#define HSPI_MISO  4
#define HSPI_MOSI  6
#define HSPI_SCLK  5
#define HSPI_SS    8
SX1262 radio = new Module(8, 20, 19, 2, SPI);

config.h defines the SPI pins and SX1262 control pins used by the wireless module on large-size boards. GPIO20 is DIO1, GPIO19 is NRESET, GPIO2 is BUSY, and GPIO8 is NSS. If initialization fails, first check whether the module is properly inserted, whether the DIP switch is set to 01, and whether the SPI pins match the current board version.

const LoRaWANBand_t Region_915 = US915;
const LoRaWANBand_t Region_868 = EU868;
const uint8_t subBand = 1;
LoRaWANNode node(&radio, &Region_868, subBand);

The frequency band must be consistent with the gateway, the TTN Frequency Plan, and the Band setting in the AT commands. Different regions use different frequency bands, so you should select the appropriate one based on local regulations and the TTN page before the experiment.

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

The program only proceeds to parsing after receiving a complete serial command. If SSCOM does not send a carriage return and line feed, the baud rate does not match, or the wrong serial port is selected, the command will appear to be sent but the program will not respond.

state = node.sendReceive(MsgTemp, MsgTemp_size, Port_Number,
                         downlinkPayload, &downlinkSize,
                         true, &uplinkDetails, &downlinkDetails);

After receiving AT+SEND, the program uploads the pending data over LoRaWAN and waits to see whether any downlink data is returned. The return value can be converted into a readable string via stateDecode() to help pinpoint issues with network join, frequency band, port, or data length.

7. Experimental Observations

After the end device is successfully configured, 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 seen on the TTN Applications > Live data page.

wireless_module59

If the network join fails, please first check:

  • Whether the frequency bands in the G1 gateway, TTN gateway, TTN end device, and AT commands are consistent.
  • Whether Gateway EUI is correctly filled in 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 uses the 115200 baud rate and adds a carriage return and line feed when sending.
  • Whether the wireless module is correctly inserted into the development board and the function DIP switch is switched to 01.

8. Code Download

Code download link: Lesson07_LoRaWAN_AT_Command