Issue with HC-SR04 Rangefinder

I am using a Speedybee F405 Wing FC.

i think i have scripting already enabled on my custom firmware, because i thought it might be useful at some point, so i will load the script to the SD card and see if it finds the sensors.

what are you using to run the arduino code.

i am sure it is a clone of Arduino nano v3.0 with an old bootloader, at least that what it said when i was buying it

setup 4x type 16 sensors with address 41 42 43 44 and see if any get data when you have just 2 sensors that are the same either the vl53l1x or the vl53l0x

try setting BRD_BOOT_DELAY to 1000 to give the arduino time to run incase its starting up too fast, it was a pixahawk that i tested it on not a f405.

tried the LUA script, but it is not possible on my side because my fc is only 1mb of memory, and it does not work, it says: ā€œScripting: out of memoryā€.

after swapping the SCL and SDA, the FC still does not turn on, and still turns on after unplugging one (any) senosr from the splitter, but i donā€™t think my FC is receiving any data from the rest of the senosrsā€¦

Todayā€™s example of the F4 lacking. Even if you have an F4 with 2mb, like a Pixracer, the maximum heap size available isnā€™t good for much. Been there, done that, replaced the Flight Controller.

After setting up 3 sensors (cant do 4 because boot loop) and plugging them into the FC, one of them was giving data for a while, but then stoppedā€¦

Im going to go bankrupt after my hobbyā€¦

ok, got 2 sensors working (showing weird data), but still one isnā€™t working, and i am still unable to connect the 4th oneā€¦

I donā€™t know what else to do now, i concluded that the arduino is, for some reason, not changing the addresses at all, im running out of ideasā€¦

what code are you using ? what sensors are you getting data from? what address does it have? if your getting data from more than one then its changing.

yeah you might be right, i am getting 2 different data.

Iā€™m using your original code, Getting data from: VL53L1X rangefinder 3 which is connected to arduino via xshut pin to pin A2 (address 43), and getting data from 2 VL53L0X (one is connected to A0 (address 41), and second one is A1 (address 42), but only if both of them are lifted and pointed the same direction (that could mean that they are addressed the same), and they are sending the shorter value from the sensor which is closer to obstacle.

today i tried different arduino analog pins, but the results were the sameā€¦

Have you figured anything out yet?

you could try sending the data via mavlink using the original POC code the hardware is basically the same apart from your connecting the arduino to the flight controller via serial.

You say that the connections are the same? Should i leave arduino connected to scl and sda pins on FC? Will try tommorow. Thanks

sorry your correct, disconnect it from the flight controllers SCL and SDA pins but leave the lidars connected to the arduino via i2c.

then connect the arduinos serial TX RX to one of the serial ports on the flight controller and set it to mavlink.

I belive the code is made for the vl53l0x only so it might need tweaked to make it work with both.

From the looks of the code, i think i am also supposed to plug the sensorā€™s xshut pins to digital pins, is that correct? Also, only thing i have now connected to the arduino are the xshut pins and the RX and TX pins, is that correct too? Just donā€™t want to fry anything by mistake or somethingā€¦

your right its different using the digital pins rather than analogue pins, you can change that in code to use the pins your using now or move the wires

arduino connects to all the xshut pins and to the scl sda pins on the lidars

the arduino then connects to the flight controller using TX and RX pins.

what we are doing is reading the sensors over i2c with the arduino then sending it via serial mavlink telemetry so the sensors no longer connect to the flight controller i2c bus, they are fully controlled by the Arduino.

i think i have issues finding working libraries for this code, every one of them just shows an error while compilingā€¦