Issue with HC-SR04 Rangefinder

you will have to set

PRX1_TYPE = 2 for MAVLINK

that will get it to use the mavlink rangefinder for proximity

then select the proximity button in the setup>advanced menu to view the proximity data.

i have only one of them posting data, second one isnā€™t visible anywhereā€¦

what sensors do you have connected?
whats it showing under DISTANCE_SENSOR in mavlink inspector?

i have 2 VL53L1X sensors connected.
image

are you getting anything on the proximity display?

Yes, only one sensor, the one wchich is connected to D5 pin (Via XSHUT) on arduino

ok that is good news, the flight controller and software are working . its probably sensor issues now .

is the one that is working the same VL53l0x that you had working before?

Canā€™t really tell (i forgot), but i see in my phones camera that both of them are pulsing the light.

try swapping the sensors xshut wires see if the working sensor moves position. if it moves then its a sensor issue.

swapped the connections, thats what i got:
image


I donā€™t know what happened on the proximity sensorā€¦ (happened after swapping) Still only one works, and showing correctly.

Ok, so the sensor that was working before works now too, so that maybe the broken sensor, but why? It was working beforeā€¦ I will check the connections.

so the sensor that is working is sensor 4 set to orientation 0 connected to pin D6.

try connecting d6 to the other sensor to see if it starts working

I updated github again so the sensors are set 0-90-180-270 for sensors 1-2-3-4

Ok i rebooted the FC, and now both of them work, but the one that wasnā€™t working before, now posts correct, but some glitched data when changing distanceā€¦ i mean it should work but i donā€™t knowā€¦ will try the code

Do you want me to change the Xshut wires back?

it shouldnt matter as they are just setting what sensor is at what position essentially.

D2-D4-D5-D6 = S1-S2-S3-S4 = 0-90-180-270

I have updated it again so that the min max ranges are set correctly, you shouldnā€™t have had the proximity showing something of nothing was connected. It should have only shown the working sensors.

that is what i got after the latest code:


both of them work, but are limited to 20cm, and the lines didnā€™t dissappear as you planned to.

updated again, there are extra constraints in the code for the sensor readings causing issues I think, there are limits in the mavlink messages so I have removed them.

ok, will update the code

Yes! Finally everything works! (i meanā€¦ most of the things) Now is it possibble to change the orientation or other settings of sensors thru Mission planner? or do i need to change that in code? im tired of unsoldering and soldering the TX and RX wires all the timeā€¦

there are 2 sets of TX and RX pins on the board. solder the flight controller wire to the pins marked RX1 TX0 if your using a board without usb.

the sensor positions are set in the code relative to each other, so if all the sensors are mounted together you can change the group orientation in the flight controller prx1 parameters

I keep a lot of these around when im working on thigns like this so i can quickly plug things in until i get it finalized then I will hard-wire it.

1 Like