How to make the TFMINI rangefinder talk I2C

I solved the problem. I substituted my Arducam PRO Mini Atmega328 Development Board with an Arduino Uno and the program emulated correctly. It looks like it was a hardware compatibility problem. Thanks for your patience

1 Like

thanks @ppoirier, now migrated from serial to I2C, a summary of the procedure find on this blog:

Load the sketch BeneWake_TFMINI_I2C_Maxbotic_Outdoor_Limit (for me)
Upload it to the Arduino Pro board (FTDI connected)
A4 is SDA A5 is SCL
Open TF GUI connect TFMINI via FTDI
The command of standard output is 42 57 02 00 00 00 01 06 Arduino Compatible
Modify output unit to mm output: 42 57 02 00 00 00 00 1A
Connect to MP and apply the following settings:
RNGFND_TYPE 7 (LightWare)
RNGFND_ADDR 112 (70 Hex is 112 Dec)
Reboot the FC and it works perfectly

3 Likes

did you try your code with a Pico?

No, does the Pico expose bothe the Serial and the I2C ?

Do not know, just seen this and was impressed by the very small size: https://create.arduino.cc/projecthub/mellbell-electronics/arduino-pico-the-world-s-smallest-arduino-board-24ee0e

Did you know that I made the Multi-Sector TFMINI detector using ATtiny ?

https://discuss.ardupilot.org/t/avoidance-experiments-with-the-poc-and-benewake-tfmini/25277

1 Like

:clap: yes, WITH and Arduino Pro Mini as controller as I can read in your blog…

The Arduino acts a a multiplexer for the I2C bus and sends the rangefinder distance and corresponding angle signals to the FC over serial MavLink.

Hi to all.

I have a question about the arduino code for translate the serial output to i2c.
At the state of the art i can only read the distance measured from the lidar.
If it’s setted as “proximity sensor”, the drone can reach at minimum the distance written in the code.

Is it possible to upgrade the arduino code in order to send the readed distance to a pixhawk and let the drone to maintain that distance?

Thanx to all.

This is basicslly what avoidance is doing. Take a look on ardupilot avoidance wiki to see how to setup rangefinder and parameters

i can set the rangefinder as:

  1. terrain following;
  2. object avoidance

Setted on 1, it means that the drone maintain the heigh (for ex. during translation).
Setted on 2, it means that the drone doesn’t go nearest than the distance setted.

In other words, with option 1) the drone follow the terrain trend (maintain a distance); with option 2) the drone doesn’t follow the wall trend (avoid a distance < than the one setted).

Am i wrong?
If it doesn’t, the question is: Is there a way to implement a code that let the drone to maintain the setted distance, when it is on “proximity sensor” ?

Thanx to all.

Yes , I have one of my quad with 2 TFMINI installed and I set I2C address 70 to altitude and address 71 to avoidance.

Have you look at avoidance library ?
http://ardupilot.org/dev/docs/code-overview-object-avoidance.html

I try to redo my question in a better way.

If i install a lidar as altitude holder (pointing on the ground), and i move in a transaltion motion, the drone follows the ground and maintain the altitude.

If i install a lidar as proximity sensor pointing on the wall), and i move in a traslational motion, the drone doesn’t follow the wall. It only avoid to reach at least a distance from the wall, but it can get away form the wall (direction not parallel with the wall, wind gusts, etc…).

The question is: Is it possible to maintain constant the distance from the wall, during a translation?

Thanx to all.

Altitude is ‘‘easy’’ to detect because the IMU has a fixed vector called Gravity.
In the case of a wall following, it is different matter, because this surface is not in a fixed plane so in this case, you could use a scanning Lidar that would allow this type pf avoidance.

I suggest you open a new discussion in the forum, because the question is not directly related to the subject and you would benefit from more input with a new discussion

I only write here to thank everyone and especially to ppoirier the work done. Of course to thank also the whole community that makes Rover easier. I have only been with Pixhawk + Rover for a few months and it has been relatively easy for me to connect my TFMini to Pixhawk 1 through the I2C port and verify that it distanced from the wall in front of it.
PD1 .: To correctly configure the TFMini and from its WINCC TF V1.1.2 application, I had to enter the start cmd, wait for sampling to pass to 0, standard output cmd, output cmd to mm, and finally abandon cmd.
PD2 .: In Arduino sketch BeneWake_TFMINI_I2C_ProMini_Maxbotic_Fast_Blink I had to modify “uint8_t Scaling = 13;” because it means more than what the tape measure showed.
The next step is to put another TFMini in the back of the Rover.

1 Like

Hi everybody.
Just one question.
¿ This I2C aproach will work with standard arducopter 3.5.7 directly out of the box on my pixhawk 2.1 or a driver mod is needed ?

Thanks in advance.
Miguel.

Yes it is because it emulates a standard I2C device

Thanks again. i will give it a try maybe tomorrow.

Hi again.
Work in progress. I’ll upload some photos showing final product :smile::smile:.
Do you think that a UBEC rated for 5v 1Amp will be enough in order to power TFMINI + Arduino Pro Mini + Red Led ?

Thanks in advance.

Miguel.

Cool

Yes no problem, the TFMINI Average current is 120 mA