ESP32 UART over Lora

saeedisa
Posts: 1
Joined: Thu Jul 18, 2024 4:16 am

ESP32 UART over Lora

Postby saeedisa » Thu Jul 18, 2024 4:28 am

I have 2 ESP32S - WROOM - 32 and 2 Lora E220-400T22S, Lora is installed on Ebyte E15-ULT1. I'm tryin to create transmitter and receivers of this 2 setups. Each setup is a ESP32S and Lora connected together, where:

From Lora's side, I have pins:
* RXD: which is used for Receiving data
* TXD: which is used for Transmitting data
* AUX
* NC1, NC2, NC3
* GRD
* VCC
* M0, M1

in ESP32S I have a lot of pins:
* GRD, VCC
* a lot of GPIO

I have connected ESP32 to Lora by those;
* Lora GND -> ESP GND
* Lora VCC -> ESP VCC 5V
* M0, M1 -> GND
* Lora RXD and TXD to ESP GPIO 16, 17 in ESP (Tried the opposite as well, do RXD and TXD to ESP GPIO 17, 16 but that did not solve.)

I have written 2 similar codes where the only diff is read/write respectively to transmit/receive operation.

Where receiver app is:
  1. #define ECHO_TEST_TXD (17)
  2. #define ECHO_TEST_RXD (16)
  3. #define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
  4. #define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
  5.  
  6. #define ECHO_UART_PORT_NUM      (UART_NUM_0)
  7. #define ECHO_UART_BAUD_RATE     (115200)
  8.  
  9. #define BUF_SIZE (1024)
  10.  
  11. void lora_uart() {
  12.  
  13. /* Configure parameters of an UART driver,
  14.  * communication pins and install the driver */
  15. uart_config_t uart_config = {
  16.     .baud_rate = ECHO_UART_BAUD_RATE,
  17.     .data_bits = UART_DATA_8_BITS,
  18.     .parity    = UART_PARITY_DISABLE,
  19.     .stop_bits = UART_STOP_BITS_1,
  20.     .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
  21.     .source_clk = UART_SCLK_DEFAULT,
  22. };
  23. int intr_alloc_flags = 0;
  24.  
  25.  
  26. #if CONFIG_UART_ISR_IN_IRAM
  27.     intr_alloc_flags = ESP_INTR_FLAG_IRAM;
  28. #endif
  29.  
  30. ESP_ERROR_CHECK(uart_driver_install(ECHO_UART_PORT_NUM, BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
  31. ESP_ERROR_CHECK(uart_param_config(ECHO_UART_PORT_NUM, &uart_config));
  32. ESP_ERROR_CHECK(uart_set_pin(ECHO_UART_PORT_NUM, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS));
  33.  
  34. // Configure a temporary buffer for the incoming data
  35. uint8_t *data = (uint8_t *) malloc(BUF_SIZE);
  36.  
  37. while (1) {
  38.     // Read data from the UART
  39.     ESP_LOGI(TAG, "Receiving.....");
  40.     int len = uart_read_bytes(ECHO_UART_PORT_NUM, data, (BUF_SIZE - 1), 20 / portTICK_PERIOD_MS);
  41.     if (len) {
  42.         data[len] = '\0';
  43.         ESP_LOGI(TAG, "Recv str: %s", (char *) data);
  44.     }
  45.     vTaskDelay(1000);
  46. }
  47. }
and transmitter app is:
  1. #define ECHO_TEST_TXD (17)
  2. #define ECHO_TEST_RXD (16)
  3. #define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
  4. #define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
  5.  
  6. #define ECHO_UART_PORT_NUM      (UART_NUM_0)
  7. #define ECHO_UART_BAUD_RATE     (115200)
  8.  
  9. #define BUF_SIZE (1024)
  10.  
  11.  
  12. void lora_uart() {
  13.  
  14. /* Configure parameters of an UART driver,
  15.  * communication pins and install the driver */
  16. uart_config_t uart_config = {
  17.     .baud_rate = ECHO_UART_BAUD_RATE,
  18.     .data_bits = UART_DATA_8_BITS,
  19.     .parity    = UART_PARITY_DISABLE,
  20.     .stop_bits = UART_STOP_BITS_1,
  21.     .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
  22.     .source_clk = UART_SCLK_DEFAULT,
  23. };
  24. int intr_alloc_flags = 0;
  25.  
  26. #if CONFIG_UART_ISR_IN_IRAM
  27.     intr_alloc_flags = ESP_INTR_FLAG_IRAM;
  28. #endif
  29.  
  30. ESP_ERROR_CHECK(uart_driver_install(ECHO_UART_PORT_NUM, BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
  31. ESP_ERROR_CHECK(uart_param_config(ECHO_UART_PORT_NUM, &uart_config));
  32. ESP_ERROR_CHECK(uart_set_pin(ECHO_UART_PORT_NUM, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS));
  33.  
  34. // Configure a temporary buffer for the incoming data
  35. // uint8_t *data = (uint8_t *) malloc(BUF_SIZE);
  36.  
  37. while (1) {
  38.     // Write data back to the UART
  39.     ESP_LOGI(TAG, "Sending....." );
  40.     uart_write_bytes(ECHO_UART_PORT_NUM, (const char *) "Hello", 5);
  41.     ESP_LOGI(TAG, "Wrote data str: %s", (char *) "Hello");
  42.     vTaskDelay(1000);
  43. }
  44. }
But no success of receiving any data...

What did I miss in connectivity ? is there anything special I need to do in addition ?
I have been struggling with this for many days now

Thanks in advance

jayhack
Posts: 1
Joined: Sun Jul 21, 2024 7:22 pm

Re: ESP32 UART over Lora

Postby jayhack » Sun Jul 21, 2024 7:25 pm

I can't find info on any E15-ULT1, but Ebyte modules I have used had default baud rate of 9600.

aliarifat794
Posts: 200
Joined: Sun Jun 23, 2024 6:18 pm

Re: ESP32 UART over Lora

Postby aliarifat794 » Wed Jul 24, 2024 7:52 am

Sorry I could not find any tutorial on ESP32 and Lora E220-400T22S. However, I found one project on ESP32 microcontroller with an RA-01 LoRa module. You can check this out and see if it helps in any way: https://www.pcbway.com/project/sharepro ... 56be3.html
You can also check this library: https://github.com/xreef/EByte_LoRa_E22_Series_Library

Who is online

Users browsing this forum: No registered users and 95 guests