-
Notifications
You must be signed in to change notification settings - Fork 19
Description
// for SX126x series or LLCC68
#include <SX126x.h>
SX126x LoRa;
#include <SPI.h>
//#include <LoRa.h>
//Lolin S2 Mini SPI默认pin脚
#define MISO 40
#define MOSI 1
#define SCLK 4
#define nss 38 // LoRa模块片选引脚,可以根据您的连接进行修改
#define RST_PIN 2 // LoRa模块复位引脚,可以根据您的连接进行修改
#define DI01_PIN 6 // LoRa模块中断引脚,可以根据您的连接进行修改
#define BUSY_PIN 8 // LoRa模块中断引脚,可以根据您的连接进行修改
#define TXEN_PIN 10 // LoRa模块中断引脚,可以根据您的连接进行修改
#define RXEN_PIN 11 // LoRa模块中断引脚,可以根据您的连接进行修改
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("Configure SPI");
// 开始新的 SPI 通信
SPI.begin(SCLK, MISO, MOSI);
// 设置SPI时钟频率
SPI.beginTransaction(SPISettings(16E6, MSBFIRST, SPI_MODE0)); // 将时钟频率设置为16MHz
delay(1000);
Serial.println("Configure SPI Done");
Serial.println("LoRa Power On");
// 初始化LoRa模块
LoRa.setPins(nss, RST_PIN,BUSY_PIN,DI01_PIN,TXEN_PIN,RXEN_PIN);
LoRa.setActive();
// 初始化LoRa模块
Serial.println("LoRa.begin()");
LoRa.begin(); //Stuck on this step.
Serial.println("LoRa receiver started");
}