I am using a LOLIN32 lite (ESP32) to read data sent from a STM32F103 (black pill). The ESP32 is using micropython and the STM32 is programmed using CubeMX + Truestudio.

When calling the uart.read() or uart.readline() in micropython I get the data sent by the STM32 but it has appended a \x00 value at the beginning.

From Tera terminal I get: b’\x00test message\n’


UART configuration CubeMX

Code used in the STM32 (I am using the HAL library, the rest of the code is too long to post).

uint8_t buff_uart[] = "test\t a long message\n";

while (1){

Code in micropython:

uart = UART(2, 115200)
uart.init(115200, bits=8, parity=None, stop=1, timeout=2000)

while True:

If I connect the serial line from the STM32 to a serial USB I can see the right data in Tera terminal (without \x00). Can it be that micropython add a delimiter?

or is this an error? What I am missing here?

  • 2
    Have you checked it's not the other end sending it that way? – hardillb Oct 7 at 14:29
  • Add your code of the STM32 to the question please. – Bence Kaulics Oct 7 at 14:54
  • I added the code and clarified the post a bit better :) – Gabriel Oct 7 at 16:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.