I have tried to look in various foruns but couldn't find the solution for my problem. I'm trying to build a project where I have to use three VEML6070 sensors... These sensors obviously use the same address.
Hardware:
Raspeberry PI2 (I have one RPI3 and RPIZero that I could use)
Linux 4.19.85-1-ARCH #1 SMP PREEMPT armv7l GNU/Linux
Any help will be very much appreciated.
Config.txt:
dtoverlay=i2c-gpio,bus=5,i2c_gpio_delay_us=1,i2c_gpio_sda=20,i2c_gpio_scl=21
dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24
The result from i2cdetect -l is this:
i2c-3 unknown 3.i2c
i2c-1 unknown bcm2835 I2C adapter
i2c-4 unknown 4.i2c
i2c-5 unknown 5.i2c
I have this Python example:
I replace i2cX with 3, 4 and 5 and the result is the same
import time
import busio
import board
import adafruit_veml6070
i2c5 = busio.I2C(board.SCL, board.SDA)
uv = adafruit_veml6070.VEML6070(i2c5)
(...)
How can I do this with multiplexing in python?
At this point I just don't know if i2c5 = busio.I2C(board.SCL, board.SDA) or i2c3 = busio.I2C(board.SCL, board.SDA) or whatever makes sense.
EDIT - 31/12
Ok, thank you for you help and kind replies. I tried to find the answers for this issue without a mux but some of them were too complicated for me to understand.
So, I took a spare 4052 that I have here and connect all sensors. However to read all sensors with the same address I had to create three extra files - modules - and import them:
#uvsensor.py
import busio
import board
import RPi.GPIO as GPIO
import adafruit_veml6070
GPIO.setmode (GPIO.BCM)
GPIO.setup (5, GPIO.OUT)
GPIO.setup (6, GPIO.OUT)
GPIO.output(5, GPIO.LOW)
#GPIO.output(6, GPIO.HIGH)
def sensor_uv_1():
GPIO.output(6, GPIO.HIGH)
i2c = busio.I2C(board.SCL, board.SDA)
uv = adafruit_veml6070.VEML6070(i2c)
uv_raw = uv.uv_raw
return(uv_raw)
and in the main file:
import uvsensor
uv_1=uvsensor.sensor_uv_1()
print (uv_1)
The code needs a little tweaking to be proper organized (There is one last shot with a friend of mine that will try to modify the busio so it can read all three sensors.)
for now, all three sensors are working fine