Realize LoRa point-to-point communication based on HaaS100

1 Introduction

LoRa is an ultra-long-distance wireless transmission technology based on spread spectrum technology adopted and promoted by Semtech. Compared with traditional communication technology, LoRa has the advantages of low threshold, long distance, and long battery life, and it has high practical value in the fields of digital agriculture and smart communities. For more LoRa introduction, please refer to: www.semtech.com/lora . The author has realized LoRa point-to-point communication based on HaaS100. This article will introduce in detail how to quickly get started with this LoRa communication solution.

 

2. Introduction

image.png

In this solution, SX1268 is selected as the LoRa communication IC. HaaS100 is connected to the SX1268 module to send and receive data. HaaS100 and SX1268 modules communicate through SPI. The software mainly refers to the official Semtech driver, ported it to AliOS Things, and made corresponding adaptations to the HaaS100 platform.

 

3. Environment construction

image.png

Physical display

  • Prepare two HaaS100 development boards. One is the communication sender and the other is the communication receiver.
  • Prepare two SX1268 modules and connect them to two HaaS100 respectively. The connection sequence is shown in the figure below:

Wiring diagram.jpg

 

4. Software introduction

  • The relevant code of this solution is located in the application/example/lora_demo path of the HaaS branch of the AliOS Things project:

       https://github.com/alibaba/AliOS-Things/tree/dev_3.1.0_haas/application/example/lora_demo

 

  • The code summary is as follows:

application/example/lora_demo/

├── Config.in

├── aos.mk

├── demo.c

├── radio.c

├── radio.h

├── sx126x-board.h

├── sx126x-haas.c

├── sx126x.c

└── sx126x.h

    • Among them, demo.c is the program entry, which is responsible for the initialization of lora and the call of the data transceiver interface
    • radio.c/sx126x.c is the radio layer driver of the SX1268 chip, responsible for converting business functions into access to chip registers
    • sx126x-haas.c based on AliOS Things implements the hardware interfaces required by the radio layer, such as GPIO, SPI and timers, etc.

5. Get started quickly

  • If the current development board is the sender of data, the macro switch TRANSMIT_MODE is defined as TRANS_MODE_TX;

image.png

  • If the current development board is the data receiver, define the macro switch TRANSMIT_MODE as TRANS_MODE_RX;

image.png

 

  • Compile software: aos make lora_demo@haas100 -c config && aos make;
  • Compile the image of the sender and the receiver in the above manner, and burn them into two HaaS100 blocks respectively. After connecting to the serial port, you can see that the two HaaS100s are performing LoRa communication:

image.png

6. Appendix

If you need more technical support, you can join the Dingding Developer Group

For more technology and solution introduction, please visit the Aliyun AIoT homepage https://iot.aliyun.com/

Guess you like

Origin blog.csdn.net/HaaSTech/article/details/112425914