Using AnalogWrite for I2C sensors

Hi!

I have 6 RGB color sensors with the same address. That means that I can't chain them in the same port and then call different addresses using the Wire library.

But, the sensors use 3,3v. Is it possible to send 3,3v via an analogWrite (assigning each sensor an analog port) and read the values from each sensor turning them on and off individually?

If not, what can I do to read data from the 6 sensors that have the same I2C address?

Thanks!

Do the those ? sensors have a CS (chip select) pin.

If not, use an 8-channel I2C muxer (Adafruit). Leo..

No, they don't have a CS pin. The address is fixed.

I don't have access to a 8-channel muxer either so I'm out of luck on that side.

Is it possible to power on each sensor individually generating 3,3V using analogWrite so I can read from each sensor via I2C?

"Is it possible to power on each sensor individually generating 3,3V using analogWrite so I can read from each sensor via I2C?" No, the analogWrite outputs a PWM signal, not a level. You could filter it with a low pass filter, but the current will be limited by the filter resistor. And SCL & SDA will be impacted by the non-powered devices.

What is the RGB sensor you are using?

Where are you located that you can't order an I2C mux? Can you order a pair of 8:1 analog switches and use those a mux by selecting the same channel on each, one for SCL and one for SDA? The lines need to be bidirectional for I2C. https://www.digikey.com/products/en/integrated-circuits-ics/interface-analog-switches-multiplexers-demultiplexers/747?k=analog+switch&k=&pkeyword=analog+switch&pv1961=9&FV=ffe002eb&mnonly=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25

What about using the digital ports that don't generate a PWM signal?

I'm located in Chile. I can order it, but It'll be too late.

I'm using this RGB sensor https://www.sparkfun.com/products/12829

How are we supposed to help you without knowing what hardware you have.

CrossRoads asked: What is the RGB sensor you are using?

And, are you using a 3.3volt Arduino, or I2C level shifter?
Leo…

If they have an input pin to select one of two addresses, then you wire them up like SPI CS pins. Select all the devices to address B then only give one the signal to use address A. Then do the I2C calls to address A.

https://www.intersil.com/content/dam/Intersil/documents/isl2/isl29125.pdf

You're going to need some additional hardware to talk to multiple chips I'm afraid.