I want to use multiple PiicoDev sensors, two PiicoDev_VEML6040 and three PiicoDev_VL53L1X, but they all need to be connected to pins 3 and 5 on the Raspberry Pi. Perhaps a rookie question but how do I change the address of each of them so I can use them individually?
According to the datasheet for the VEML6040, the address of the sensor is fixed at 0x10, so you wouldn’t be able to use multiple without a multiplexer (that part would be ideal, but it’s out of stock, likely the chip shortage something like this should do fine instead.
The Core Electronics repo for the VL53L1X PiicoDev library has some info on using multiple VL53L1X sensors:
Using Multiple Sensors
Since the VL53L1X defaults to a single address, multiple sensors on the same bus will conflict. You can use the change_addr function to use something other than the default, but it will be lost on power down. You can use any spare GPIO on your microcontroller to drive the SHT (shutdown) pin low to disable all the sensors you are using, then bring them up one at a time to give them a unique address each time your code starts. Be sure to pick addresses that are at least 2 away from each other, as reading from the sensor uses your set address + 1.
Hi @George194980, welcome to the forums!
The Colour Sensor (VEML6040) has only one address available, so only one may be used on a PiicoDev bus.
The Distance Sensor (VL53L1X) also has one address as set by the manufacturer - however there is a (somewhat advanced) procedure to set a new address on powerup using the
change_addr(x) method which will set the address to whatever integer is input as
x. After this command is issued, the device needs to be restarted by pulling the
SHT pin low, then high (or returning to not-connected). The address returns to default (0x10) every time the device powers up - so this procedure needs to be repeated each time.
PiicoDev doesn’t currently support using more than one I2C bus on Raspberry Pi, so it will only be possible to work with one Colour Sensor at the moment.
There are I2C Muxes available that will in principle mean you can address multiple devices of the same address - though these aren’t (yet) compatible with PiicoDev and would require a little detective work to get working.
Thanks for your help.
Thank you for the help.
I don’t think it was covered in the other comments, but all I2C devices connect on those pins, they are for the I2C bus, theoretically you can connect up to 128 devices to those 2 pins, as long as the arresses don’t conflict… and that’s covered by the other comments