SX1276/77/78/79 低功耗长距离收发器驱动程序 (esp-idf)
SX1276/77/78/79 Low Power Long Range Transceiver driver for esp-idf.
I based on this.
ESP-IDF V5.0 or later.
ESP-IDF V4.4 release branch reached EOL in July 2024.
git clone https://github.com/nopnop2002/esp-idf-sx127x
cd esp-idf-sx127x/basic/
idf.py menuconfig
idf.py flashNote for ESP32C3
For some reason, there are development boards that cannot use GPIO06, GPIO08, GPIO09, GPIO19 for SPI clock pins.
According to the ESP32C3 specifications, these pins can also be used as SPI clocks.
I used a raw ESP-C3-13 to verify that these pins could be used as SPI clocks.
LoRa mode has the following three communication parameters.
1.Error Coding Rate (= CR)
2.Signal Bandwidth (= BW)
3.Spreading Factor (= SF)
The communication speed is faster when BW is large, CR is small, and SF is small.
However, as the communication speed increases, the reception sensitivity deteriorates, so select the one that best suits your needs.
Error coding rate
1:4/5(Default)
2:4/6
3:4/7
4:4/8
Signal Bandwidth
0:7.8 kHz
1:10.4 kHz
2:15.6 kHz
3:20.8kHz
4:31.25 kHz
5:41.7 kHz
6:62.5 kHz
7:125 kHz(Default)
8:250 kHz
9:500 kHz
In the lower band (169MHz), signal bandwidths 8&9 are not supported.
Spreading Factor (expressed as a base-2 logarithm)
6:64 chips / symbol
7:128 chips / symbol(Default)
8:256 chips / symbol
9:512 chips / symbol
10:1024 chips / symbol
11:2048 chips / symbol
12:4096 chips / symbol
The ESP32 series has three SPI BUSs.
SPI1_HOST is used for communication with Flash memory.
You can use SPI2_HOST and SPI3_HOST freely.
When you use SDSPI(SD Card via SPI), SDSPI uses SPI2_HOST BUS.
When using this module at the same time as SDSPI or other SPI device using SPI2_HOST, it needs to be changed to SPI3_HOST.
When you don't use SDSPI, both SPI2_HOST and SPI3_HOST will work.
Previously it was called HSPI_HOST / VSPI_HOST, but now it is called SPI2_HOST / SPI3_HOST.
| SX127X | ESP32 | ESP32-S2/S3 | ESP32-Cx/Hx | |
|---|---|---|---|---|
| RST | -- | GPIO16 | GPIO38 | GPIO3 |
| MISO | -- | GPIO19 | GPIO37 | GPIO4 |
| SCK | -- | GPIO18 | GPIO36 | GPIO5 |
| MOSI | -- | GPIO23 | GPIO35 | GPIO6 |
| NSS | -- | GPIO15 | GPIO34 | GPIO7 |
| GND | -- | GND | GND | GND |
| VCC | -- | 3.3V | 3.3V | 3.3V |
You can change it to any pin using menuconfig.
LoRa's packet format is strictly specified.
Therefore, if the following three parameters are the same, they can communicate with each other.
In LoRa modulation mode, the communication speed (bps) and maximum reception sensitivity (RSSI) are determined by a combination of spreading factor (SF), bandwidth (BW), and coding rate (CDR).
With varying Signal Bandwidth(BW) (Unit=Bytes/Sec)
ESP32@160/433MHz/CR=1/SF=7
| BW=0(7.8KHz) | BW=2(15.6KHz) | BW=4(31.25KHz) | BW=6(62.5KHz) | BW=7(125KHz) | BW=8(250KHz) | BW=9(500KHz) |
|---|---|---|---|---|---|---|
| 37.50 | 83.18 | 165.75 | 296.32 | 618.93 | 1153.85 | 2031.87 |
With varying Error coding rate(CR) (Unit=Bytes/Sec)
ESP32@160/433MHz/BW=7/SF=7
| CR=1(4/5) | CR=2(4/6) | CR=3(4/7) | CR=4(4/8) |
|---|---|---|---|
| 618.93 | 543.13 | 468.32 | 410.63 |
Create idf_component.yml in the same directory as main.c.
YourProject --+-- CMakeLists.txt
+-- main --+-- main.c
+-- CMakeLists.txt
+-- idf_component.ymlContents of idf_component.yml.
dependencies:
nopnop2002/sx127x:
path: components/lora/
git: https://github.com/nopnop2002/esp-idf-sx127x.gitWhen you build a projects esp-idf will automaticly fetch repository to managed_components dir and link with your code.
YourProject --+-- CMakeLists.txt
+-- main --+-- main.c
| +-- CMakeLists.txt
| +-- idf_component.yml
+-- managed_components ----- nopnop2002__sx127xDatasheet is here.
暂无开放 Issues,或尚未同步最近议题。