LoRa AT Commands Configuration

This document describes how to configure HARDWARIO TOWER LoRa devices with AT commands over a USB virtual serial port.

This document does not explain project-specific firmware commands and functions. They are explained in the project itself.

Note

This guide applies to all firmware in the HARDWARIO Playground with the prefix twr-lora

LoRa Configuration

The LoRa module can be configured with AT commands sent to the Core module over a USB virtual serial port. You will need a terminal emulator application such as Hterm, putty, minicom, picocom, or screen. Configure the emulator with the following serial port parameters:

  • Baudrate 115200

  • 8 data bits, 1 stop bit, no parity

  • CR+LF as the “end of line” sequence for both transmit and receive

HTerm

You can download Hterm for Windows and Linux. It also supports macros and sequences in the left panel for most used commands. Type the command and press ENTER. Not the ASend button.

Picocom

If you use picocom, start the program with the following parameters

picocom -b 115200 --omap crcrlf --echo /dev/ttyUSB0

To exit the program press CTRL+A followed by CTRL+Q.

Putty

The configuration option “Implicit LF every CR” in Putty is only effective on received data. To send CR+LF to the device, press CTRL+J followed by the Enter key.

AT Commands

To list all possible commands use AT$HELP. The set of supported commands will depend on your firmware version. You will get something like this:

 1AT$HELP
 2AT$DEVEUI
 3AT$DEVADDR
 4AT$NWKSKEY
 5AT$APPSKEY
 6AT$APPKEY
 7AT$APPEUI
 8AT$BAND 0:AS923, 1:AU915, 5:EU868, 6:KR920, 7:IN865, 8:US915
 9AT$MODE 0:ABP, 1:OTAA
10AT$NWK Network type 0:private, 1:public
11AT$ADR Automatic data rate 0:disabled, 1:enabled
12AT$DR Data rate 0-15
13AT$REPU Repeat of unconfirmed transmissions 1-15
14AT$REPC Repeat of confirmed transmissions 1-8
15AT$JOIN Send OTAA Join packet
16AT$FRMCNT Get frame counters
17AT$LNCHECK MAC Link Check
18AT$RFQ Get RSSI/SNR of last RX packet
19AT$DEBUG Show debug UART communication
20AT$REBOOT Firmware reboot
21AT$FRESET LoRa Module factory reset
22AT$SEND Immediately send packet
23AT$STATUS Show status
24AT$BLINK LED blink 3 times
25AT$LED LED on/off
26AT+CLAC List all available AT commands
27AT$HELP This help

To read a value, append the question mark character at the end of the corresponding AT command:

AT$APPSKEY?

The current value will be shown in the terminal as follows:

$APPSKEY: BF22C15EB89237A65DAABB05B2C91EB4

Use the following syntax to update the value:

AT$APPSKEY=BF22C15EB89237A65DAABB05B2C91EB4

Tip

You can use online key generators for testing purposes

OTAA - Over-the-Air Activation

OTAA means that the session keys (the ones with S in the name) are generated in the LoRa network during JOIN. The keys are then automatically transferred to your LoRa module. If your LoRa network does not support the OTAA activation method, read the ABP section below. If you are not sure which activation type to use, start with OTAA.

For the OTAA activation method, the LoRa network needs to know the DevEUI of your LoRa module. You can read the value with the command AT$DEVEUI?:

$DEVEUI: 009335FF931FEADC
OK

The LoRa network also needs to know the APPKEY and APPEUI values. You can either read the values from your LoRa module and transfer them into your LoRa network, or you can let the LoRa network generate new values for you to set in your module, for example:

1AT$APPEUI=324502A5676BADD7
2OK
3AT$APPKEY=44D4A5DA7A9507F036C5A2750211F052
4OK

Each time you get an OK, the value has been saved in the LoRa module’s internal flash memory.

Tip

Some LoRa networks also support generating DEVEUI but we do not recommend changing this value.

Finally, switch the modem into OTAA mode and send a JOIN command to exchange the session keys. Make sure your modem has good signal because it needs bidirectional communication with the gateway to complete the join.

Enter:

1AT$MODE=1  // Set OTAA(1)
2OK
3AT$NWK=1   // Public(1) or private(0) network config (TTN is public)
4OK
5AT$JOIN
6OK
7$JOIN_OK

Note that the OK response to JOIN command does not mean that the join was sucessful. Wait for a few seconds to get either $JOIN_OK (join was successful) or $JOIN_ERROR (join failed). If the join was successful, the LoRa module is ready to communicate.

ABP - Activation by Personalization

ABP means that you set up session keys manually. AT$MODE has to be set to 0 (ABP), which is the default setting after a LoRa module power reset.

If you use the ABP mode, you need to set the APPSKEY and NWKSKEY values manually via the corresponding AT commands. For example:

1AT$APPSKEY=5505CA3E4620843B324502A5676BADD7
2OK
3AT$NWKSKEY=44D4A5DA7A9507F036C5A2750211F050
4OK

Each time you get an OK, the value has been saved in the LoRa module’s internal flash memory.

Also, the LoRa network will need to know the DEVEUI and DEVADDR values from your LoRa module. Use the commands AT$DEVEUI? and AT$DEVADDR? to read the values, for example:

1$DEVEUI: 009335FF931FEADC
2OK
3$DEVADDR: 26012C39
4OK

Read Sensor Values

You can use the command AT$STATUS to obtain the curent values from all available sensors. This command only prints the values to the terminal. It does not send anything through the LoRa network.

1AT$STATUS
2$STATUS: "Voltage",3.2
3$STATUS: "Temperature",23.0
4$STATUS: "Orientation",1
5OK

Send Data

To send sensor values to the LoRa network immediately, send the AT$SEND command to your module:

1AT$SEND
2OK