I am working with a project using ESP32 to communicate with 3 modules using UART, I use UART1 and UART2 for LoRa and Sigfox modules which work perfectly find. Then, I decided to use ft2232h mini module as an external debugger for ESP32 in order to use UART0 for a GPS module. However, there is no communication at all in the UART0, in the console, I can see that it tries to print something, but all I can see is blank spaces. But when I connect the GPS with other UART, it works fine. Please help me do the configuration to use all three UARTs. Below is my code, which is taken from ESP IDF UART example. Thank you.
https://github.com/espressif/esp-idf/tr ... 183_parser.
Code: Select all
/* NMEA Parser example, that decode data stream from GPS receiver
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "nmea_parser.h"
static const char *TAG = "gps_demo";
#define TIME_ZONE (+1) //Paris Time
#define YEAR_BASE (2000) //date in GPS starts from 2000
/**
* @brief GPS Event Handler
*
* @param event_handler_arg handler specific arguments
* @param event_base event base, here is fixed to ESP_NMEA_EVENT
* @param event_id event id
* @param event_data event specific arguments
*/
static void gps_event_handler(void *event_handler_arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
{
gps_t *gps = NULL;
switch (event_id) {
case GPS_UPDATE:
gps = (gps_t *)event_data;
/* print information parsed from GPS statements */
ESP_LOGI(TAG, "%d/%d/%d %d:%d:%d => \r\n"
"\t\t\t\t\t\tlatitude = %.05f°N\r\n"
"\t\t\t\t\t\tlongtitude = %.05f°E\r\n"
"\t\t\t\t\t\taltitude = %.02fm\r\n"
"\t\t\t\t\t\tspeed = %fm/s",
gps->date.year + YEAR_BASE, gps->date.month, gps->date.day,
gps->tim.hour + TIME_ZONE, gps->tim.minute, gps->tim.second,
gps->latitude, gps->longitude, gps->altitude, gps->speed);
break;
case GPS_UNKNOWN:
/* print unknown statements */
ESP_LOGW(TAG, "Unknown statement:%s", (char *)event_data);
break;
default:
break;
}
}
void app_main()
{
/* NMEA parser configuration */
// nmea_parser_config_t config = NMEA_PARSER_CONFIG_DEFAULT();
nmea_parser_config_t config = { \
.uart = { \
.uart_port = UART_NUM_0, \
.rx_pin = 3, \
.baud_rate = 9600, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.event_queue_size = 16 \
} \
};
/* init NMEA parser library */
nmea_parser_handle_t nmea_hdl = nmea_parser_init(&config);
/* register event handler for NMEA parser library */
nmea_parser_add_handler(nmea_hdl, gps_event_handler, NULL);
vTaskDelay(10000 / portTICK_PERIOD_MS);
/* unregister event handler */
nmea_parser_remove_handler(nmea_hdl, gps_event_handler);
/* deinit NMEA parser library */
nmea_parser_deinit(nmea_hdl);
}