Raspberry Pi · guide
TFmini Plus with Raspberry Pi CAN / UART: integration and configuration guide
Setup, connection, configuration and code guidance for TFmini Plus with Raspberry Pi. The original files are available in Materials and downloads. Documented interface: CAN, UART.
Applicable setup
TFmini Plus · Raspberry Pi · CAN, UART
Technical instructions and steps
Interfacing TFmini Plus with Raspberry Pi 4B
Written by: Ibrahim (FAE)
This article explains how to interface TFmini Plus with Raspberry Pi 4B but it should work with all other versions of Raspberry Pi as long as the right pins are used. The following assumptions are made while writing this article:
1. The end-user has Raspberry Pi and TFmini Plus in hands
2. The operating system (tested on Raspbian version 10 buster) is installed on Raspberry Pi 3. The serial port is already enabled 4. Python2 or 3 is installed 5. Python editor is required for writing the script. I have Thonny installed on my RasPi.
NOTE: If you have installed full Raspbian, all the required packages are included in full version.
2|Page
Pin configuration of Raspberry Pi:
The following image shows the pinout of Raspberry Pi board:
Figure 1: Pinouts
We are using the serial pins for connecting TFmini Plus with Raspberry Pi. Pin-8 (TXD) and Pin-10 (RXD) as enclosed in red rectangle. Pin 2 and 6 or 4 and 6 can be used as power source because the operating voltage of TFmini Plus is 5V.
3|Page
Wire sequence of TFmini Plus:
Figure 2 and table-I show all the details about pin description and the wiring sequence of TFmini Plus.
Figure 2: Color code of TFmini Plus
Table-I: Pin descriptionCustomized cable needed for proper connection:
If we look at the connector of TFmini Plus, it is GH1.25-4P connector. On the other hand Raspberry Pi has pin headers. So we need a cable which has 7P 1.55MM bar connector (also called horizontal patch socket) on one side and female dupont connector on other side for inserting it into Raspberry Pi. The following figure shows customized cable for this purpose.
4|Page
Figure 3: GH1.25 4P to dupont cable
Schematic diagram:
The next image show connection diagram of TFmini Plus with Raspberry Pi.
Figure 4: Schematic
It should be noted that if you are connecting more devices to your raspberry Pi, then it is highly recommended to use a high current power supply because the default adapter has only 2A current capacity. So choose your power supply depending upon the current requirement of the whole system. The actual connection settings can be seen in figure 5.
5|Page
Figure 5: Actual connection
6|Page
Python code:
In this section we will discuss the main parts of python code that are used for reading the data from TFmini Plus. The following tables show the serial protocol used by TFmini Plus, and data format:
Table II: Communication protocol
Table III: Data format
7|Page
Following the above sequence of data, we will get the bytes from TFmini Plus using Python. First of all we need to install the serial port library which can be done using pip installer (works with both Python2 and 3):
After successfully installing the library, it’s time to write the script and import the serial port library.
Create the object of class Serial and pass the necessary parameters (serial port and baud rate):
The main function starts from here and it searches if there the port is open and call the function read_data():
8|Page
The function read_data() checks the bytes, make some necessary shifting of bytes and then prints the data in terminal:
This code has two parts; first part is compatible with Python3 (upper part) and second is compatible with Python2 (lower section). For different byte positions, please refer to Table-III. The distance measured by LIDAR can be observed in the following figure.
9|Page
Figure 6: Data measured by LiDAR
10 | P a g e
Use and verification
The technical content follows the readable source material. Confirm the product hardware revision, flight-stack or software version, and field safety boundary against the original material and current platform documentation.
Materials and downloads
- Interfacing TFmini Plus with Raspberry · English source (PDF)Complete inquiry to download
