In my project I have connected multiple sensor breakout boards to a Arduino-proMIni running at 3.3V and 8Mhz as follows on a fabricated pcb but preserving the original board layouts (so that I can connect them via traces instead of loose wires)
To save power I am using the digital GPIO Pins to power all the breakout boards that are running on I2C with Vin = 3.3V.
The breakout boards for different sensors have pullup resistances for SDA/SCL lines (pulled up with Vin) and configured as follows:
When I power on the board, as long as the external eeprom is ON (but no reads or writes are happening), there is no serial output for the i2c line.
When I turn off the eeprom, the i2c line only works if all others sensors are on. Turning any one or more of the sensors off, gives no serial output for the i2c line.
After researching online I realized that we need to give a dedicated Vdd line to the pullup resistances of the SDA/SCL lines instead of the Vin lines, as turning Vin off will also pull-down the i2c lines.
So I removed the pull-up resistances on all the breakout boards and added 5k pullups to the SDA/SCL pins on the MCU with the Vdd.
Even after doing this the i2c lines only work after the external eeprom is turned off.
As For the other sensors -
- The RTC now works only when all other sensors are off. Switching the RTC on is most likely adding a lot of noise in the i2c output because the values changes on the serial monitor change asa it is turned on and come back to normal when turned off.
- The capacitive sensor works only when the accelerometer is on.
- The current odometer and the accelerometer work without any problems.
Can someone please help me figure out why all of this is happening? Can this problem be solved by merely choosing the right pull-up resistances or is it a higher order problem? Is it possible that because I am using a 30cm wire for the Accelerometer, the entire bus capacitance is increasing, adding too much noise in the system when multiple slaves run simultaneously. And hence will it help if I shift the accelerometer on the SPI protocol and decouple it from I2C?
All sensors are running at <100Khz except the eeprom which is running at 400Khz.
Update:
So I took everyones suggestion below and made 2 pcbs. In one I powered all the sensors to the Vcc line and even pulled up the i2c line on Vcc. In the other I powered all the sensors with the GPIO pins (but keeping them always on HIGH) just like before and pulled up the i2c lines with another GPIO (so that I can pull them down when all the sensors are simultaneously LOW to avoid case [4] as pointed out by @maple below). And guess what? The GPIO powered sensors are working flawlessly while in the Vcc powered ones the i2c line i.e SDA, freezes after few seconds. This happens in the case when I am trying to communicate with the FDC1004, the adxl and ina219. RTC doesn't seems to be affected. Any clue why this could happen?