/espidf-lora

ESP-IDF Website https://docs.espressif.com/projects/esp-idf/

Primary LanguageCMIT LicenseMIT

ESP-IDF LoRa™ module component

  • Tested on RA-02 (SX1278)
  • Compatible CAD (Channel activity detection)

Import to /components

git clone https://github.com/LastuvkaLukas/espidf-lora.git lora

Default configuration

Everything can be configured using menuconfig --> LoRa Configuration

  • Settings
    • Frequency (433MHz)
    • Sync word (0xFD)
    • Preamble length (255)
    • TX power (17)
    • Init timeout (100)
  • SPI Config
  • DIO 0-5 Config

Default conect GPIO

Power

LoRa™ module ESP
GND GND
3V3 3V3
RST GPIO27

SPI

Compatible HSPI and VSPI

Default select HSPI

LoRa™ module ESP
MISO GPIO12
MOSI GPIO13
SCK GPIO14
NSS GPIO15 (optional)

DIO pins

Default dio pins disconnect

LoRa™ module ESP
DIO0 --- (optional)
DIO1 --- (optional)
DIO2 --- (optional)
DIO3 --- (optional)
DIO4 --- (optional)
DIO5 --- (optional)

Examples

First init LoRa™ module

esp_err_t err = lora_init();
if(err != ESP_OK)
    ESP_CHECK(err);
...

Send

...
lora_begin_tx();
uint8_t buf[] = "data";
uint8_t size = sizeof(buf);
lora_write_tx(buf, uint8_t size);
lora_end_tx();
...

Recieve without CAD

...
uint8_t buf[255];
uint8_t len;
esp_err_t err = lora_begin_rx(&len);
if(err == ESP_OK)
    lora_read_rx(buf, len);
lora_end_rx(); // Switch to Standby mode (optional)
...

Recieve with CAD

...
uint8_t buf[255];
uint8_t len;
esp_err_t err = lora_waiting_cad_rx(&len);
if(err == ESP_OK)
    lora_read_rx(buf, len);
lora_end_rx(); // Switch to Standby mode (optional)
...

Copyright (c) 2023 Laštůvka Lukáš