Posts

Showing posts with the label VL53L0X

The micro:bit is talking to the VL53L0X ToF sensors!

Image
This chip is no more :( This morning I got my Arduino sensor driver talking to a micro:bit using SPI. The Arduino Uno runs at 5 volts, and the micro:bit works at 3v3, so I used a level shifter to connect the two. My first attempt failed disastrously. The level shifter I used was based on the TI TXB0108. I managed to connect the 5v power and inputs to the 3v3 side, and I fear the magic smoke has left the chip. It's a shame, as the board was my first attempt at soldering SMD devices. It's been sitting unused in my bits box for a few years, though, so it's not the end of the world. Fortunately I had an Adafruit level shifter breakout based on the same IC. It's well laid out with very clear pin markings and I managed to connect it correctly. The replacement worked perfectly and the micro:bit MicroPython code was very straightforward. I've listed it below, and it's with the other code on GitHub . from microbit import * import struct from time imp...

SPI access to multiple ToF sensors is working

Image
I've been ploughing through the steps towards my goal of connecting multiple distance sensors to Anastasia's micro:bit. I now have a pair of Arduinos connected via SPI, with the slave reporting distances from two VL53L0X sensors. The wiring is a mess and the code needs cleaning up. But it's working, and replacing the Arduino master by a micro:bit should be pretty straightforward. I'll report on progress. The code is on GitHub .

Muliplexing I2C with the Adafruit TCA9548A multiplexer

Image
I want to attach multiple VL53L0X Time-of-flight sensors to a single I2C bus. It looks as if that should be easy, but it's not. One solution involves disabling the sensors and then enabling them one at  a time to change their address. It's workable, but fiddly. If you only have two sensors you could use different I2C buses, but I eventually want to run 8 sensors, so that won't work. The TCA9548A I2C multiplexer There is another approach that is easy to implement and works out of the box. The TCA9548A is an I2C device that acts a little like a telephone exchange. You can use it to route I2C transactions to one of eight separate I2C busses. That allows you to have eight devices with the same I2C address, one on each bus. I did a first experiment using an Adafruit CircuitPython m4 feather. That worked well, and I've just confirmed that it works just as well with a Raspberry Pi. Since I'm using Adafruit's CircuitPython libraries, the same code run...