Good day @flybrianfly😀
I use a cyclone m1025c that produces M10 ubx format.
Using u-center, I successfully connected to the device via uart, configured it to output only ubx and a frequency of 10 Hz.
This library is intended for Arduino compatible boards and for stm32, but it seems that it does not work on esp32 boards.
This code calls the hardware Serial, in esp32 this is done differently and after flashing the device disappears via usb, only forced entry into the boot mode helps.
If you comment out the line
gnss.Begin(GNSS_BAUD)
Then usb is detected on the device as a com port and behaves as usual.
The pseudocode is:
#include <Arduino.h>
// #include "freertos/FreeRTOS.h"
// #include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"
#include "driver/uart.h"
#include "string.h"
#include "driver/gpio.h"
// UBX parsing library
#include <ubx.h>
#define SERIAL_BAUD 115200
#define GNSS_BAUD 115200
#define UART_GNSS UART_NUM_2 // UART2 — GNSS
#define UART_GNSS_TX_PIN (GPIO_NUM_38)
#define UART_GNSS_RX_PIN (GPIO_NUM_39)
#define BUF_SIZE (1024)
// binary output OK
bfs::Ubx gnss(&Serial2);
static const char *TAG = "uart_example";
void uart_init()
{
// --- UART GNSS (UART2) ---
uart_config_t uart_gnss_config = {
.baud_rate = GNSS_BAUD, // GNSS speed
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
ESP_ERROR_CHECK(uart_param_config(UART_GNSS, &uart_gnss_config));
ESP_ERROR_CHECK(uart_set_pin(UART_GNSS, UART_GNSS_TX_PIN, UART_GNSS_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(UART_GNSS, BUF_SIZE * 2, 0, 0, NULL, 0));
}
void setup() {
Serial.begin(SERIAL_BAUD);
// Serial2.begin(GNSS_BAUD);
uart_init();
Serial.println("communication with GNSS");
if (!gnss.Begin(GNSS_BAUD)) {
Serial.println("Failed to establish communication with GNSS RX");
while (1) {}
}
// Serial.print("Serial port speed: ");
// Serial.println(SERIAL_BAUD);
}
void loop() {
// forwarding serial2 to serial
// if (Serial2.available())
// Serial.write(Serial2.read());
// Serial2.write(Serial.read());
// delay(20);
if(gnss.Read()) {
Serial.print(gnss.fix());
Serial.print("\t");
Serial.print(gnss.num_sv());
Serial.print("\t");
Serial.print(gnss.lat_deg(), 6);
Serial.print("\t");
Serial.print(gnss.lon_deg(), 6);
Serial.print("\t");
Serial.print(gnss.north_vel_mps(), 2);
Serial.print("\t");
Serial.print(gnss.alt_msl_m());
Serial.print("\t");
Serial.print(gnss.alt_wgs84_m(), 2);
Serial.print("\n");
}
}
Is it possible to adapt the library code for esp32?
Thanks!
Good day @flybrianfly😀
I use a
cyclone m1025cthat produces M10ubxformat.Using
u-center, I successfully connected to the device viauart, configured it to output onlyubxand a frequency of10 Hz.This library is intended for
Arduinocompatible boards and forstm32, but it seems that it does not work onesp32boards.This code calls the hardware
Serial, inesp32this is done differently and after flashing the device disappears viausb, only forced entry into thebootmode helps.ublox/src/ubx.h
Line 144 in b472d38
If you comment out the line
Then
usbis detected on the device as acomport and behaves as usual.The pseudocode is:
Is it possible to adapt the library code for
esp32?Thanks!