UART reading float numbers
Posted: Tue Apr 11, 2023 8:15 am
Hey everyone,
I would like to ask for your help. I am writing code in Arduino, yet i utilize the <driver/uart.h> library and i have set up the uart as following:
Then, i try to read data and echo them as following:
My plan was to take all 4 bytes that a float is consisted of and using memcpy try and structure the float that i would finally print.
To be honest i am having trouble even with reading plain data (not floats) in general, so if you can help me with even some echo, i would appreciate it.
Thanks in advance
I would like to ask for your help. I am writing code in Arduino, yet i utilize the <driver/uart.h> library and i have set up the uart as following:
Code: Select all
uart_config_t uart_config_0 = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(UART_NUM_0, &uart_config_0);
uart_set_pin(UART_NUM_0, TX_UART0, RX_UART0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_0, BUF_SIZE*2, 0, 0, NULL, 0);
Code: Select all
int len = uart_read_bytes(UART_NUM_0, dataR, 1024, 1000);
if (len > 0)
{
uart_write_bytes(UART_NUM_0, dataR, strlen(dataR));
}
To be honest i am having trouble even with reading plain data (not floats) in general, so if you can help me with even some echo, i would appreciate it.
Thanks in advance