Overview: Build a LoRaWAN470 gateway and node based on M5Stack devices

This tutorial will show how to pass M5 BASIC host and Module LoRa (433MHz) implements the LoRaWAN470 gateway and node, and communicates with TTN , we put the firmware in Burner , users can set parameters through Burner

Assemble the hardware

1.1 Hardware Preparation

Hardware List:
BASIC Host: 3 (1 gateway 2 nodes)
Module LoRa (433MHz): 3 (1 gateway 2 nodes)
ENV-II Unit: 2

Assemble the 433 module, ENV-II Unit and core host, two of which are used as LoRaWan terminals and one is used as LoRaWan gateway.

  • Rendering after assembly:

Note: Module LoRa (433MHz) module needs to connect DIO1 to GPIO34

Firmware burning and configuration

2.1 Gateway

2.1.1 Gateway firmware burning and configuration

  1. Open the M5burner application and burn the gateway firmware

Note: The first burn will prompt you to enter M5BurnerNVS to set

At this time, we click button B to enter the BurnerNVS setup program

  1. Open M5Burner and enter the BurnerNVS setting interface to set

Required parameters:
1. WIFI_SSID: WIFI SSID
2. WIFI_PASS: WIFI password
3. Other parameters can be kept as default
4. Other parameters can be kept as default: default The frequency is 471.9MHz/SF7, the default server is nam1.cloud.thethings.network, the default time zone is +8)
5. After completing the settings, we click the B button of the host to restart the host, so far Gateway firmware configuration complete

2.1.2 Register gateway on TTN

  1. First open the official website of TTN and register an account
  2. Note: For pictures and texts, you can view our tutorial TTN(The Things Network)
  3. The default server for the gateway is nam1.cloud.thethings.network
  4. Parameters that must be set
  1. Gateway ID: human readable string
  2. Gateway EUI: The "GW EUI" item on the host screen is generated based on the MAC address to ensure global uniqueness
  1. Schedule downlink late: Check it for the downlink function
  2. Frequency plan: Select China 470-510MHz, FSB11
  3. Other parameters can be kept as default, so far the gateway has successfully registered on TTN.

2.2 Terminal

2.2.1 Create a node on TTN

  1. Create an app
  1. Create two nodes with network access type OTAA under the application, and get DEVEUI, APPEUI and APPKEY of each device

  2. Note: For pictures and texts, you can view our tutorial TTN(The Things Network)

  1. Parameters that must be set

    1. Frequency plan: Select China 470-510MHz, FSB11

    2. LoRaWAN version: LoRaWAN Specification 1.0.2

    3. Regional Parameters version: we choose revision B

  2. Other parameters can be kept as default, so far the node has been successfully created on TTN

2.2.2 Node firmware burning and configuration

  • Open the M5burner application and burn the node firmware
  • Click "info"->"burner setup" to enter BurnerNVS setup program
  • Open M5Burner and enter the BurnerNVS setting interface to set

Parameters that must be set:
1. APPEUI: generated by TTN, can be queried on TTN
1. DEVEUI: generated by TTN, can be queried on TTN
2. APPKEY: generated by TTN, You can query on TTN
3. Other parameters can be kept as default
4. Note: The default eight channels are 471.9MHz, the frequency extension factor SF7, the network access mode OTAA, the sending interval is 20s), so far the node firmware configuration Finish

Nodes communicate with TTN

  1. We use the CayeneLPP library to encapsulate the information. We need to change the decoding type to CayeneLPP in TTN to see the data uploaded by the node
  1. After the configuration is completed through the above steps, the node will collect environmental information through the ENV-II Unit and upload it to TTN at intervals of 20s, which is consistent with the temperature and humidity data displayed on the node.

We can add the delivery information to the downlink queue on the TTN website, so that the node will receive a Downlink message after the next Uplink upload, and the data displayed on the node is consistent with the set data

Interface and BurnerNVS parameter detailed explanation

4.1 Gateway

4.1.1 Gateway interface

Start page:

From top to bottom are:
1. Title bar: LoRaWan470 GW
2. Status light: green flashing state when working normally, yellow is initializing state
3. GW EUI: each gateway Unique ID, generated by MAC address
4. Freq: Listening frequency and extension factor
5. Uplink: The number of LoRa data packets uploaded by the gateway
6. Downlink: The number of LoRa data packets sent by the gateway Quantity
7. Recently Node: The recently communicated node address and RSSI
8. Key:
1. info: You can enter the information page.
Information Pages:

From top to bottom are:

  1. Title bar: LoRaWan470 GW

  2. Status light: green flashing state when working normally, yellow is initializing state

  3. WiFi SSID: WiFi ID

  4. LoRaWAN Server: LoRaWAN server address

  5. Port: LoRaWAN server port

  6. NTP Server: NTP server address

  7. Timezone: time zone

  8. Keys:

    1. back: Return to the start page.

    2. burner setup: enter the BurnerNVS setup program

4.1.2 Gateway BurnerNVS parameters

  1. WIFI_SSID: WIFI SSID

  2. WIFI_PASS: WIFI password

  3. Frequency: The listening frequency of the gateway needs to comply with the LoRaWAN protocol. The spectrum range of the LoRaWAN 470 is 470MHz to 510MHz. The specific setting needs to check the LoRaWAN protocol. The frequency of the gateway and the node must be the same

  4. SF: frequency extension factor, the range is 5-0, corresponding to SF7 to SF12 respectively, the frequency extension factor of gateway and node must be the same

  5. TTN_SERVER: The address of the LoRaWAN server

  6. TTN_PORT: the port number of the LoRaWAN server

  7. NTP_SERVER: The address of the NTP server

  8. TIMEZONE: time zone

4.2 Nodes

4.2.1 Node interface

From top to bottom are:

  1. Title bar: LoRaWan470 Node

  2. Status light: green flashing state when working normally, yellow is initializing state

  3. CH Nums: channel and its corresponding frequency

  4. TX Interval: Uplink sending interval

  5. ENV-II Unit: The status of ENV-II Unit, green is the normal working state, otherwise it is red, the right side will also display the temperature and humidity

  6. Keys:

    1. beep disable indicates that the speaker is in the off state. Press this button to switch to beep enable. At this time, if a Downlink message is received, the speaker will beep once to remind you.

    2. info: You can enter the information page.

    3. uplink enable Description Uplink is enabled, the node will upload messages to the TTN at intervals of 20s, and pressing this button will switch to uplink disable.

From top to bottom are:

  1. Title bar: LoRaWan470 Node

  2. Status light: green flashing state when working normally, yellow is initializing state

  3. Spec Version: This is the version of the LoRaWAN protocol

  4. Mode: Network mode, now OTAA

  5. DEVADDR: Device address

  6. Keys:

    1. back: Return to the start page.

    2. burner setup: enter the BurnerNVS setup program

4.2.2 Node BurnerNVS parameters

  1. APPEUI & DEVEUI & APPKEY: OTAA network access parameters, generated by TTN

  2. TX_INTERVAL: time interval of uplink

  3. CHANNEL0 ~ CHANNEL8: The frequency of each channel needs to comply with the LoRaWAN protocol. The spectrum range of LoRaWAN 470 is 470MHz to 510MHz. The specific setting needs to check the LoRaWAN protocol. The frequencies of the gateway and the node must be the same

  4. SF: frequency extension factor, the range is 5-0, corresponding to SF7 to SF12 respectively, the frequency extension factor of gateway and node must be the same

  5. POWER: transmit power, the range is 0-20, the larger the value, the greater the power, the default is 20

  6. ABP_ENABLE: ABP access mode enable. 1 is on, 0 is off. If it is 0, it is the OTAA network access mode, and the settings related to ABP are invalid. If it is 1, it is the ABP network access mode, and the settings related to OTAA are invalid.

  7. NWKSKEY & APPSKEY & DEVADDR: ABP network access parameters, which can be generated by TTN.

  8. ADR_ENABLE: ADR enable. 1 is on, 0 is off.

  9. APP_PORT: Set the application port, the range is 1-255

  10. CONFIRM_MSG: Confirm message enable. 1 is on, 0 is off. If on, you will receive an ACK after each uplink.

other apps

5.1 Enter the BurnerNVS program on the fly

Click "info" -> "burner setup"

After that, you will enter the following page, indicating that you have entered the Burner NVS setup program

At this point we can open the Burner application and set up BurnerNVS

5.2 Nodes connect to other gateways

When we need to connect to other gateways, we only need to modify the frequency of CHANNEL0 - CHANNEL8

5.3 Nodes use ABP mode to access the network

If we need to use ABP mode to access the network, we only need to turn on ABP_ENABLE to enable

Note: You need to go to General settings -> Network layer -> Advanced MAC settings under the TTN ABP node management page, change Rx1 delay to 5s, and change Resets frame The counters` option is checked

On This Page