Problem with I2C when two sensors are connected.

Thread Starter

wiyarun

Joined Jun 26, 2022
4
My project requires two sensors to operate on the same i2c bus, one of which is a display and the other of which is a touch sensor.
And I have a problem where, if I test both devices without connecting them simultaneously, both will function normally. But when I combine them, the touch sensor does not immediately function.
Using an oscilloscope to detect the signal, I discovered that when I send Address 0x38, which is the number of the touchscreen sensor in Bit 9, there appears to be an incomplete Logic High signal.
And I'm uncertain how this signal originated. Does anyone have any idea what could be causing this issue?

Note: R Pullup is 4.7K, Bus speed 100KHz, wring distance 20 cm.

S__20168707.jpg
 

Ian Rogers

Joined Dec 12, 2012
1,136
9th bit??? Usually it goes:- Start... 8 bits... Slave sends ack.. So on and on.. The bus should be in read mode after the 8th bit has left..
 

Ian0

Joined Aug 7, 2020
9,671
That's the "acknowledge" bit - your data is not being acknowledged. If the device being addressed has received your data it will respond with a logic zero in that bit.
 

JohnInTX

Joined Jun 26, 2012
4,787
It looks like the slave at 0x38 is trying to pull down SDA to ACKnowledge but can't. If the signals are OK when each device is run separately, I would look for a grounding problem between the slaves and master. It might be that your wiring can't handle the current when both are connected or there is a connection problem.

You don't say what microprocessor you are using and if you are using a hardware peripheral or bit banging. If bit banging, ensure that your SDA drive is active 0 and floating (not driven high) for a 1. The signals shown could also be from bus contention i.e. one device actively outputting a '1' and the slave pulling to 0 for the ACK. Most microcontrollers can source more current than an I2C slave can sink so the active 1 will win and you will get a signal like you show.

The signals from the master show that it can manipulate the bus OK, Start, ADDRESS, WRITE, and it looks like the slave is receiving its address and trying to ACK but it can't pull SDA down. Check the code, connect the scope at the slave end and see if the signals are different there.

Good luck!
 
Last edited:

Ian0

Joined Aug 7, 2020
9,671
I suspect @JohnInTX is correct, but . . . .
Could something be driving SDA high? The only thing that should drive SDA high is the pullup resistor - all the devices connected to it should be open-drain so that they can only pull it low.
Is the pin correctly configured on your processor, as an open-drain output?
 

Thread Starter

wiyarun

Joined Jun 26, 2022
4
It looks like the slave at 0x38 is trying to pull down SDA to ACKnowledge but can't. If the signals are OK when each device is run separately, I would look for a grounding problem between the slaves and master. It might be that your wiring can't handle the current when both are connected or there is a connection problem.

You don't say what microprocessor you are using and if you are using a hardware peripheral or bit banging. If bit banging, ensure that your SDA drive is active 0 and floating (not driven high) for a 1. The signals shown could also be from bus contention i.e. one device actively outputting a '1' and the slave pulling to 0 for the ACK. Most microcontrollers can source more current than an I2C slave can sink so the active 1 will win and you will get a signal like you show.

The signals from the master show that it can manipulate the bus OK, Start, ADDRESS, WRITE, and it looks like the slave is receiving its address and trying to ACK but it can't pull SDA down. Check the code, connect the scope at the slave end and see if the signals are different there.

Good luck!
Thank you for your advice. I'll look into it. And about the MCU I using nRF91.
 

Thread Starter

wiyarun

Joined Jun 26, 2022
4
I suspect @JohnInTX is correct, but . . . .
Could something be driving SDA high? The only thing that should drive SDA high is the pullup resistor - all the devices connected to it should be open-drain so that they can only pull it low.
Is the pin correctly configured on your processor, as an open-drain output?
I set up my MCU to use open-drain already. At first, I wasn't sure if the sensor was open-drain or not, so I asked the display and touch screen suppliers, and they said that it was open-drain.
 
Top