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:
- #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);
- }
- }
- #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);
- }
- }
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