TinyF and STM32 serial port communication

TinyF and STM32 serial port communication0. Introduction to TinyF1.Experimental Preparation2.Experimental wiring3. Main code explanation4.Experimental phenomenon5.Some important parameters of TinyF

0. Introduction to TinyF

1.Experimental Preparation

2.Experimental wiring

STM32TinyF
PA2RX
PA3TX
GNDGND
5V5V

Wiring diagram

Note: If you want to use a USB to TTL module, refer to the following table for wiring between STM32 and USB to TTL

STM32USB转TTL
PA9RXD
PA10TXD
GNDGND
5V5V

 

3. Main code explanation

The above program is used to parse data from the TinyF laser ranging module. Only when the protocol is met can the data be correctly parsed.

4.Experimental phenomenon

1.Download the program provided by the routine to STM32

2.Connect the wires according to the wiring diagram.

3.The serial port assistant is set to the interface as shown in the figure

4.After power on, the serial assistant will print the distance information

image-20250805195434186

5.Some important parameters of TinyF

Related parameter description

namevalue
Baud rate115200
Effective minimum distance (theoretical value)20,unit:mm
Effective maximum distance (theoretical value)4000,unit:mm
Confidence0~62,The larger the value, the higher the distance reliability.

Data format

Data frame structure: image-20250806182406790

Example: image-20250806182514571

FieldNumber of bytesExample(Hex)ASCII characters
Frame header (fixed value)120space
Distance value(distance)1~533 32 37327
Delimiter (fixed value)22C 20,space
Confidence(confidence)1~236 3161
Frame tail (fixed value)10A\n