esp32esp-idflora

Lora E220-400T22S to ESP32S wiring, transmitting/receiving issue


I'm trying to connect the Lora E220-400T22S version installed on the Ebyte E15 card with an antenna to ESP32S and transmit or receive RF data.

my code is based on this library ESPIDF Lora github

however, the problem seems to be in wiring where I can't figure out what I'm missing.

from Lora's side, I have pins:

  1. RXD: which is used for Receiving data
  2. TXD: which is used for Transmitting data
  3. AUX
  4. NC1, NC2, NC3
  5. GRD
  6. VCC
  7. M0, M1

in ESP32S I have a lot of pins:

  1. GRD, VCC
  2. a lot of GPIO

checking idf.py menuconfig Lora configuration lora configuration

I can see that RXD/TXD should be connected to P19 in ESP32. Hence, the wiring I did is:

  1. Lora GND -> ESP GND
  2. Lora VCC -> ESP VCC 5V
  3. Lora TXD -> ESP P19
  4. M0, M1 -> GND

Lora and ESP

But no success in sending data, in terms of code, init_lora always fails

it says that the version always is 0xff which tried to read from register 0x42 but I have no clue what this means, nor has anybody answered in GitHub question.

what am I missing in connectivity?

update due to comments:

I have used UART to connect to Lora and try to send receive data but without success.

I have connected Lora RXD and TXD to GPIO 16, 17 in ESP and wrote the following app for receiver ESP:

#define ECHO_TEST_TXD (17)
#define ECHO_TEST_RXD (16)
#define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)

#define ECHO_UART_PORT_NUM      (UART_NUM_0)
#define ECHO_UART_BAUD_RATE     (115200)

#define BUF_SIZE (1024)

void lora_uart() {

/* Configure parameters of an UART driver,
 * communication pins and install the driver */
uart_config_t uart_config = {
    .baud_rate = ECHO_UART_BAUD_RATE,
    .data_bits = UART_DATA_8_BITS,
    .parity    = UART_PARITY_DISABLE,
    .stop_bits = UART_STOP_BITS_1,
    .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
    .source_clk = UART_SCLK_DEFAULT,
};
int intr_alloc_flags = 0;


#if CONFIG_UART_ISR_IN_IRAM
    intr_alloc_flags = ESP_INTR_FLAG_IRAM;
#endif

ESP_ERROR_CHECK(uart_driver_install(ECHO_UART_PORT_NUM, BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
ESP_ERROR_CHECK(uart_param_config(ECHO_UART_PORT_NUM, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(ECHO_UART_PORT_NUM, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS));

// Configure a temporary buffer for the incoming data
uint8_t *data = (uint8_t *) malloc(BUF_SIZE);

while (1) {
    // Read data from the UART
    ESP_LOGI(TAG, "Receiving.....");
    int len = uart_read_bytes(ECHO_UART_PORT_NUM, data, (BUF_SIZE - 1), 20 / portTICK_PERIOD_MS);
    if (len) {
        data[len] = '\0';
        ESP_LOGI(TAG, "Recv str: %s", (char *) data);
    }
    vTaskDelay(1000);
}
}

and the following to to the transmit ESP with same connections:

#define ECHO_TEST_TXD (17)
#define ECHO_TEST_RXD (16)
#define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)

#define ECHO_UART_PORT_NUM      (UART_NUM_0)
#define ECHO_UART_BAUD_RATE     (115200)

#define BUF_SIZE (1024)


void lora_uart() {

/* Configure parameters of an UART driver,
 * communication pins and install the driver */
uart_config_t uart_config = {
    .baud_rate = ECHO_UART_BAUD_RATE,
    .data_bits = UART_DATA_8_BITS,
    .parity    = UART_PARITY_DISABLE,
    .stop_bits = UART_STOP_BITS_1,
    .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
    .source_clk = UART_SCLK_DEFAULT,
};
int intr_alloc_flags = 0;

#if CONFIG_UART_ISR_IN_IRAM
    intr_alloc_flags = ESP_INTR_FLAG_IRAM;
#endif

ESP_ERROR_CHECK(uart_driver_install(ECHO_UART_PORT_NUM, BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
ESP_ERROR_CHECK(uart_param_config(ECHO_UART_PORT_NUM, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(ECHO_UART_PORT_NUM, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS));

// Configure a temporary buffer for the incoming data
// uint8_t *data = (uint8_t *) malloc(BUF_SIZE);

while (1) {
    // Write data back to the UART
    ESP_LOGI(TAG, "Sending....." );
    uart_write_bytes(ECHO_UART_PORT_NUM, (const char *) "Hello", 5);
    ESP_LOGI(TAG, "Wrote data str: %s", (char *) "Hello");
    vTaskDelay(1000);
}
}

But no success of receiving any data...


Solution

  • The LoRa module uses the LLCC68 chip with a UART interface (two pins, one for RX the other for TX). The library you're trying to use is for a different chip (SX127x) with an SPI interface. Won't work.

    And to your updated question: You probably have to configure the module first before transmitting any payload data, see e.g. https://github.com/xreef/EByte_LoRa_E22_Series_Library