Uses the libgpiod library to get sensor data from the TF-Luna using C++ on the Raspberry Pi and I2C Communication, with graphics using wxwidgets.
The TF-Luna is a LiDAR (Light Radar) that measures accurate, single-point distance measurement in a small package that is ideal for robotics, and obstacle detection. Attached is code from C++ to retreive and set information on the TF-Luna, the header MDLTFLuna27.h containing library code is specific to the TF-Luna.
- install Raspberry Pi OS (64-bit)
- Open a terminal and type the following commands:
- sudo apt install libwxgtk3.2-dev build-essential
- sudo apt install -y libi2c-dev
- sudo apt install libgpiod-dev
- make sure TF-Luna is detected at &h10: i2cdetect -y 1
- Create the TF-Luna example program in a terminal with:
g++ TFLunaCPP27.cpp -o TFLunaCPP27 `wx-config --cxxflags --libs` - Run the program with: ./TFLunaCPP76.cpp
wx.h is located in usr/include/wx-3.2/wx/wx.h
Below are the breadboard connections with the Raspberry Pi and TF-Luna.


