Servers by jDrones

How to make the TFMINI rangefinder talk I2C

@ppoirier I received the TFMini, wired it up to the Arduino with your sketch, and connected it to my pixhawk via I2C. I enabled the rangefinder as Maxbotics I2C and changed primary alt measurement to rangefinder from barometer. I disabled the GPS and the GPS prearm checks. My alt measurement is much more accurate and precise than it was before. My issue now is im getting a “PreArm: check range finder” error. Any thoughts?

Cool :slight_smile:
Yes you can disable this error by checking out parameters (Bit 5) in prearm checks:

1 Like

@ppoirier Worked, THANK YOU!!! Weather is windy and snowy so no outdoor testing today. As for indoor with GPS disabled, were you flying in Loiter or Stabilize in your video above?

@DHank01 Good === hit the “like” button :wink:

I fly loiter using optical flow

1 Like

@ppoirier: Hello Patrick, i’m trying to test the TF mini poc but i’m running into a small issue. Where do you got the mavlink.h library for the teensy? I got one but the distance message is not there. So i ‘stole’ it from the cleanflight code.


Hello Nicolas,
I generated it using the python export script, as showed in this excellent blog: MAVLink Step by Step

1 Like

@ppoirier In testing our copter with a Pixhawk, PX4FLOW, TFMINI Lidar for altitude, with all GPS parameters turned off(Optical Flow Only), we can take off in Loiter mode and hover relatively well but after a few seconds it kicks out of LOITER mode and we get an EKF variance error and looking at the EKF gages, the horizontal position EKF is high and in the orange.
When taking off in Stabilize and trying to switch modes to POSHOLD or LOITER the flight mode change fails. Altitude seems to be fine? These issues go away when we turn the GPS back on.
Do you have any suggestions or guidance? Any log plots you would like to see?

Hello , I answered on your topic

thanks patrick…
That is what i was looking for!

After trying a while i still cant compile the project. Getting all sort of errors:

TFMINI_I2C_MAVLINK:74: error: ‘MAV_TYPE_GCS’ was not declared in this scope

‘MAV_COMP_ID_PATHPLANNER’ was not declared in this scope

Any hint?
(i followed the step by step guide)

Seems you are missing somethink in your mavlink library
try substituingthe define by the associated numbers from this

The error line is longer than just the PATHPLANNER (too long to put it here without spamming).

I build the mavlink using the step by step guide in a virtualbox linux. (it was impossible run it on windows).

I will upload my mavlink library on gitter tonight :wink:

cool thanks patrick…i don’t know why mine does not work at all.

@nicodh It is too big for github, I did a share drive

I will leave it open until you copy == let me know

1 Like

Thanks downloading right now

Nicolas Grunbaum

Thanks Patrick, it’s done, i downloaded it, and tested it, it works. :slight_smile:

Thanks for the help!

Nicolas Grunbaum

Putting this out to the community. I seem to be in need of assistance. I flashed my pro mini with no issues, its wired up and double checked. I configured the Arducopter per the instructions. But no joy.
At rest the copters altitude reports as .15 meters and if I roll the machine on its side so it measures a longer distance if measures .23 meters. If I run my hand in front of the sensor it changes numbers quickly but only in the range of .15 to .23. I am stumped.
One small change. If I give it more room to measure it gives me higher numbers, I saw it go to 40 at one point. ITs a small room so its hard to get an unobstructed range.

I did sit the machine on the bench with the lidar over the edge. Its 1 meter to the floor and it read .21. No settings for the lidar in mission planner have any effect on the numbers other then to stop it from working.
I thought this may be a symptom of it outputting in say mm over CM…but I am not sure what the results would be like its its wrong.
Any thoughts would be appreciated.

What should it be MM or CM

Yes it look like the TFMINI is sending in cm,
here are the commands to:
Modify output unit to mm output: 42 57 02 00 00 00 00 1A
Modify output unit to cm output: 42 57 02 00 00 00 01 1A

Uou migh try to reduce gain as well on line 32


Merci beaucoup Patrick
That was it spot on. It’s working great now.

1 Like
Servers by jDrones