Design A LoRaWAN Gateway

Photo of RT-Thread

Made by RT-Thread

About the project

Design a multi-functional single-channel LoRaWAN Gateway #LiteCoG(Lite Connect Gateway).

Project info

Difficulty: Easy

Estimated time: 1 hour



1 Introduction

LiteCoG (Lite Connect Gateway) is a small, multi-connection-enabled IoT gateway, the current main function is a single/ dual channel LoRaWAN gateway, on its north connection via Ethernet, WiFi, 4G Cat1, south communication via LoRa, but it also supports BLERS485, with the features of long-distance communication, low cost, easy deployment, easy to expand and many others, easy for large-scale promotion. LiteCoG is designed for smart homes, smart cities, smart parking and other local area networks, smaller device capacity of the Internet of Things communication scenarios, but also because of its low-cost advantages, it can also be used as a LoRaWAN supplement device.

LiteCoG Gateway developed with the open-source RT-Thread operating system, uses LoRa SX126X-SX127X to provide standard LoRaWAN access capabilities so as to reduce BOM costs, and with LoRa features of long-range communication and low power consumption, it is convenient to deploy battery-powered smart devices with great flexibility in applications such as home parking, community-based parking / small area parking. At the same time, relying on the RT-Thread powerful hardware and software ecosystem resources, the whole product development process is accelerated to shorten the time of delivering the products to market.

    • LoRaWAN Single-channel Gateway(lgwsc)
      • Dock to Standard LoRaWAN server
        • UDP
          • Unicore
          • Tencent Cloud
      • Class A
      • Support lgwsc shell command
      • Support gateway parameter configuration
      • Support storage works well while power-off
      • Connection on the north
        • Ethernet
        • WiFi
        • 4G Cat1
    • Human-computer interaction
      • OLED Display
2. Development Environment
  • Software
    • RT-Thread: V4.0.3
    • IDE: RT Thread Studio 2、MDK5
    • PessimonUIBuilder 3.0
  • Hardware
    • ART-Pi
      • STM32H750
      • AP6212
    • ART-Pi industry expanding board
      • Ethernet、485
    • ART-Pi multi-media expanding board
      • 320*480 TFT screen
    • LoRa multi-function expanding board(LRS007)
      • SX1268 LoRa module
      • 1.3 inch OLED display
3 RT-Thread on this project
  • RT-Thread Kernel:
    • Scheduler: Multithread (task) implementation
    • Interthread synchronization: semaphore, mutex
    • Interthread communication: mailboxes, message queues
    • Memory management: mem pool, memheap management algorithm
    • Software timer
  • Components
    • FinSH Console
    • Device Drivers
      • I/O
      • WIFI framework
      • SPI framework
        • Use the SPI framework to drive the devices that have SPI interface (e.g. the LoRa SPI module that we mentioned in this article)
    • Network
      • netdev
      • AT command
      • SAL(Socket Abstraction Layer)
      • TCP/IP protocol stack
        • lwip lightweight IP
      • Utilities
        • ulog
  • Software Packages

    RT-Thread has over 340 up-for-grabs software packages for developers, making embedded development faster and easier.

    • AT: at_device-latest;
    • adbd-v1.1.1
    • btstack-v0.0.1
    • CmBacktrace-v1.4.0
    • EasyFlash-v4.1.0
    • fal-v0.5.0
    • littlefs-v2.0.5
    • JSON: cJSON-latest
    • netutils-latest
    • webclient: webclient-latest
    • webnet-v2.0.2
      • web server
    • loragw-packet-forward-latest
      • single-channel lorawan package
    • lora-radio-driver-latest
      • lora radio
    • multi-rtimer
      • Low-power hard real-time timing module
    • ft6236-v1.0.0
      • Touch-chip ft6236 driver
    • Persimmon GUI library
  • Others
    • ART-Pi SDK
      • sdk-bsp-stm32h750-realthread-artpi
4 System Design

4.1 A Typical IoT System Application Framework

4.2 Hardware Framework

Different interaction to meet different scenarios.

  • LoRaWAN Indoor Gateway (WiFi Edition)
      • ART-Pi + LoRa Multi-Function Expansion Board (LRS007) for indoor scenes such as smart homes and smart agriculture
  • LoRaWAN Indoor Gateway (WiF Edition) with control screen
      • ART-Pi + ART-Pi Multimedia Expansion Board + LoRa Multi-Function Expansion Board (LRS007) for smart home, smart community scenarios
  • LoRaWAN Outdoor Gateway (4G Edition)
      • ART-Pi + 4G Cat1 Module Expansion Board (L610) + LoRa Multi-Function Expansion Board (LRS007) for outdoor scenes such as smart parking
    • LoRaWAN Indoor/External Gateway (Ethernet Edition)
      • ART-Pi + ART-Pi Industrial Expansion Board + LoRa Multi-Function Expansion Board (LRS007) for smart factories and other scenarios

Multi-functional single-channel LoRaWAN Gateway (LiteCoG), on the north it supports WiFi, Ethernet, 4G Cat1, depending on the actual scenario, and use loRa debugging method to implement LoRaWAN single-channel access.

For applications such as smart homes, if there is a need for a control screen, you can further use the touch screen or OLED for human-computer interaction.

4.3 Software Framework

One of the main functions of multi-functional single-channel LoRaWAN Gateway (LiteCoG) 1.0 is to implement a single-channel LoRaWAN gateway, its north communication protocol is based on UDP communication, the south communication protocol is LoRaWAN, and the LiteCoG can be further extended to achieve edge computing function, that is, it can directly control LoRaWAN terminal equipment. There are also some other features, such as, gateway parameter configuration, storage works well while power-off, obtaining weather information, OLED display, persimmon UI display, and so on.

5 Software Module
  • loragw-pkt-fwd single-channel lorawan gateway to implement lorawan packet forwarding function
    • static void thread_up(void)
        • Receive lola uplink message from the Lorawan terminal device
      • Periodically obtain status information
      • Framed into PUSH_DATA (json format) and sent to the lorawan server
    • static void thread_down(void);
      • Maintain the link to the lorawan server
      • Receive and parse the downstream packet (json) of the Lorawan server and join the JiT queue
    • static void thread_jit(void);
      • Periodically take messages from the JiT queue and send them to the lorawan terminal device via lora
    • static int lgwsc(int argc, char *argv[])
      • shell command for setting gateway parameters (eui, freq, datarate, etc.)
      • Parameter of power-down storage
    • static void thread_up(void)
  • lora-radio software package
    • Implement lora chip sx126x sx127x Radio frequency(RF) drive
        • lora-radio-sx126x.c
          • Provide an upper-level access interface
        • lora-spi-sx126x.c
            • Implement spi read and write interface of the sx126x chip
            • rt_device
        • sx126x.c
        • Lora chip sx126x underlying drive
    • Multi-rtimer package
    • Implement a hard real-time timing module for lora-radio timeout service and for providing a more accurate timer for lora-pkt-fwd
    • Lorawan-ed-stack package
      • Parse lorawan protocol frames to help LiteCoG implement directly control to the lorawan terminal devices


Photo of RT-Thread


An Open-Source Community-Powered Real-Time Operating System (RTOS) Project!


Leave your feedback...