Introduction: TFMini Lidar Display - Like Radar Only With Light! :-)
There are a number of things that came together to make this work, but the biggest (and what inspired me to do it) is the "Arduino Radar Project" found on howtomechatronics.com by Dejan Nedelkovski (date unknown). https://howtomechatronics.com/projects/arduino-rad...
I did this project a few months ago (10-18-2018), with the thought of publishing my results, and just never got around - today seemed like a good day to catch up on some projects I wanted to document.
A number of changes were made on the Arduino side of things to get this working,
The ultrasonic was replaced with a TF Mini Lidar unit https://www.sparkfun.com/products/14588 (This unit is a serial device, which makes it easy enough to use)
a PCA9685 PWM/Servo board was used because the servo library caused problems when using the softwareserial library.
The other small change was the mount I used, which really is a minor thing - I used a cheap PAN/Tilt mount, and a couple of servos - The original thought was to expand this even more, and have a height option (giving more of a 3D look) I hit a couple of road blocks with the idea, and never went back to it. So the reality is you only really need one servo (I have two).
Sections of the Arduino code were based on Juan Jose Luna Espinosa TFMini and the ESP32 code https://github.com/yomboprime/TFMiniArduinoTest
The only library that is needed is the Adafruit PWM Servo Driver Library https://github.com/adafruit/Adafruit-PWM-Servo-Dri...
Step 1: What Do We Need to Build This....
I already hinted to most of it.....
We need the TFMini Lidar, 2 servos, a pan/tilt mount, a PCA9685 board and are Arduino UNO/ or clone.
We also need a extra 5v power source for the servo board. (Good tutorial for the PCA9685 board can be found here https://learn.adafruit.com/16-channel-pwm-servo-dr...
The wiring is pretty simple for this, From the Arduino you'll want to connect 5v to both the VCC on the PCA9685 board, and the TFMINI lidar unit, as well as the ground to both. The PCA9685 is a I2C device, so SCL connects to A5, and SDA to pin A4.
From the TFMini you'll connect the TX pin to PIN 8 on the Arduino.
On the PCA9685 you'll connect one servo to header 0, and one servo to header 1 (Besure to hook them up correctly, the ground (brown) wire should be at the bottom or outer edge) Header 0 is going to be used for the PAN servo (or the one we will be using) - the tilt servo is connected to header 1 (The code does move this slightly just to get it to a straight position).
That is it for the hardware, on the software side of things, we will need to install the Arduino IDE (at the time of this writing I'm using 1.8.5, but the latest should work as well) and I've not tested or used the online editor (so I have no idea if it will work with this).
You'll want to follow the install instructions for your OS, found here: https://www.arduino.cc/en/Guide/HomePage
You'll also want to update the boards, and libraries as needed (use the stable libraries, don't use any of the betas, they are buggy)
We also need to install Processing - for those that don't know what processing is - it is a flexible software sketchbook and language for learning how to code within the context of the visual arts.
In other words, it makes it really easy to make displays and display information.
Finally you'll want to grab the code from my github repository.
Step 2: The Software....
From the repository you'll find some test code for the Arduino, load this on the UNO, and open the serial console, and if all is working correctly, you should start to see some distances from your TF MINI - This code is based on the work of Juan Jose Luna Espinosa (2018) The TFMini and the ESP32
Once you verify that the lidar is working, you are ready to load the lidar_radar_with_processing2 code on the UNO.
Now we need to load the processing code, We need to change the serial port - this is at line 42.
The sketch has the serial port that my UNO is using, this in Linux and if you are using linux it should be something similar ( it could also be something like /dev/ttyUSB0) for a Windows machine it will be a COM#
either way, this should be the same serial port your Arduino IDE is using. - You'll want to close the Arduino Serial console, and run the processing sketch.
IF all goes will you should start to see the "Radar" display.
You might notice that my display doesn't look quite the same as the project that inspired it -
I made a few changes to the processing sketch - because the TFMini Lidar can display between 12 inches and 36 feet - I changed the range - I also didn't like how the original sketch made a RED line, so I changed that to just a point of RED (BTW that change is in the processing sketch at line 115 and line 116 if you want to change it back). The range is actually mapped to a value of 1 to 39 in the Arduino sketch.
* Note: line 39 lets you change the resolution, You may or may not need to adjust this - if you don't see something that looks like the picture above you probably will have to adjust line 39.
** Note 2: - You might get an error about the serial port, I've forgotten the order of devices - I think you start the Arduino first, then start the processing sketch - But I might have that backward - so you might start the processing sketch, then plug in the Arduino.... One way gives an error in process, and the other works.
Step 3: More Pictures and Thanks for Reading.....
I hope I've done the original project justice, and I hope you have enjoyed what I've done with it.
* I kind of feel like I didn't really explain this very well..... Maybe I should should document my projects a lot sooner then 3 months out *
Participated in the