Distance sensing

Last year we ran with ultrasonic ping sensors, but a lot of the teams were using the VL53L0X time of flight sensors with good results.  So this year we thought we’d have a go with some of those too.  We got the ones on a pololu carrier board for about 10 quid each.

And they’re *lovely*.  I think that under the covers they’re doing something very complicated/interesting and hiding all that from us, but the readings we get from them are very accurate and very consistent.  No need for any averaging or filtering code on the Pi side.

Its not all roses though.  The minor downside of that complexity is that you need to initialise them with a C-library.  If you’re using the python library, that’s all taken care of for you, but we are writing our code in Golang, so we had to mess about linking in that C-library.

Another quirk to be aware of – they are an I2C device, so they all need an I2C address.  They come with a fixed one from the factory. If you only have one this is fine, but if you have more than one, they will all have the same address…  Other I2C sensors usually allow you to tune the address with jumpers, but this doesn’t seem to be an option with these boards – at startup you need to hold all but one in reset (using GPIO pins) and then send it I2C commands to change the address, and repeat with a different one in reset.  We decided we didn’t have enough GPIO pins for this.

Alternatively, you can use an I2C multiplexer like the TCA9548A (adafruit do a nice carrier board for it too).  With this, you attach the ToF sensors to the different buses coming out of the multiplexer, then you send commands to the multiplexer to change which bus you want to talk to.

Here’s Tigerbot wearing a few sensors on its front.

Leave a Reply

Your email address will not be published. Required fields are marked *