SX1276/77/78/79 Low Power Long Range Transceiver driver for esp-idf.
I based on this.
- Changed make to cmake.
- Added support for ESP32S2, ESP32S3, ESP32C2, ESP32C3 and ESP32C6.
- I left the control of CS to the driver.
- Added a sample of ping-pong/http/mqtt.
- Added some API functions.
ESP-IDF V4.4/V5.x.
ESP-IDF V5.0 is required when using ESP32-C2.
ESP-IDF V5.1 is required when using ESP32-C6.
git clone https://github.com/nopnop2002/esp-idf-sx127x
cd esp-idf-sx127x/basic/
idf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3/esp32c6}
idf.py menuconfig
idf.py flash
Note 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.
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-C2/C3/C6 | |
---|---|---|---|---|
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.
- Signal Bandwidth (= BW)
- Error Cording Rate (= CR)
- Spreading Factor (= SF)
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).
- SF
Increasing SF increases the spreading factor and improves noise resistance.
This improves reception sensitivity and extends communication distance, but communication speed decreases. - BW
Bandwidth sets the width of the communication band. Setting a larger bandwidth will improve communication speed.
However, the radio reception sensitivity (RSSI) will decrease. - CDR
CDR (CodingRate) sets the level of error correction rate.
The larger the number, the better the correction rate, but the amount of information per packet increases.
(No effect on maximum reception sensitivity)
You can set whether to use Optimaise for each CDR, and enabling it will improve the correction rate, but will reduce communication speed.
Datasheet is here.