Having trouble using two I2C joystick

I using two I2C hall effect joystick in my circuit which is 67A-DF-3C-030C. We are using joysticks as a mouse I don’t know if it is related to the topic. Also, I use 14 push buttons as an interrupt for some UART messages. I am having trouble using both joysticks together. I can access both of them with different I2C addresses so there is no conflict. When just one of them is connected to the circuit it works perfectly but when I connect both of them at the same time somehow they both stop working. I couldn’t figure the problem out. I have no clue it is related to hardware or software. I am posting schematic of both joystick circuit PB9 and PB8 are SDA and SCL pins.

I using two I2C hall effect joystick in my circuit which is 67A-DF-3C-030C.

What on Earth does that mean?

It mean using two https://www.digikey.com/product-detail/en/grayhill-inc/67A-DF-3C-030C/GH7699-ND/4360139

Grumpy_Mike:
What on Earth does that mean?

Ok but can’t see it without consenting to having cookies.
All your schematic shows is two sockets with pull up resistors.

I have no idea what you are doing nor what involvement an Arduino has. It is easy for you, you have the thing in front of you. We can only go off your description which at the moment is just about worth the paper it is written on.

After 115 posts, can you not do better than this?

I am sorry if I couldn't make the situation clear. I am using STM32 as a microcontroller, not an atmega. But my question is about I2C communication protocol.

Grumpy_Mike:
OK but can’t see it without consenting to having cookies.

Oh, the dread GDPR!

No wonder Brexit is popular!

caneradiyaman6:
It mean using two https://www.digikey.com/product-detail/en/grayhill-inc/67A-DF-3C-030C/GH7699-ND/4360139

Well you should have stated that.

$61.15 each? This better be for the SPACEX project or such!

But my question is about I2C communication protocol.

No it is not. You said:-

I can access both of them with different I2C addresses so there is no conflict.

So you have no problem with the I2C communication protocol.

When just one of them is connected to the circuit it works perfectly but when I connect both of them at the same time somehow they both stop working.

Is nothing to do with the I2C communication protocol but how you have wired it to your system and what code you are running.

I am using STM32 as a microcontroller

Then would it not be better asking in a STM32 forum?

Joystick.jpg

You have not shown the I2C pull-ups.

Ah, OK, the datasheet. So they have a single address select line with the intention that you use two together on the same bus and the third line is an interrupt so you only need three pins to interface two of them at most.

And you are most unlikely to need an interrupt anyway, so really, just a single two pin I2C bus.

And I see they are for medical or military use, so the cost matches.

I have sent the pull-ups for I2C pins. I was trying to observe the waveform of SDA pin. The weird thing is that when a probe of oscilloscope connected to SDA pin at the beginning, Both joysticks are working well. Otherwise; they stay busy. I really have no clue about this problem. I will try to decrease the value of pull-up resistors.

You only need one set of pullups. For a 3V3 device they should be 3K3 to 1K8 in value.

Grumpy_Mike:
You only need one set of pullups. For a 3V3 device they should be 3K3 to 1K8 in value.

Thanks a lot. I made the pull-ups 3.3K and it started working.

caneradiyaman6, I am trying to interface with the same joystick and having difficulty using the Wire library. I think Wire may be incompatible due to the joystick's rather odd default of returning X and Y when queried without a specified register address, which I believe to be in conflict with Wire's buffering. Did you roll your own I2C comms, or am I misunderstanding the Wire library? If the latter, could you post your XY read sequence?
I sure wish Greyhill had just implemented specific registers for the X and Y values!

Did you get the Greyhill Joystick to work with Arduino Wire?

The following code worked for me, I used Nick Gammon's I2C address scanner to determine the address which is left shifted because of the LSB used for read/write. The counter is decremented every 1ms in an interrupt in order to get the sample rate to 50 samples per second.

void handle_joystick()
{
  if(joystick_counter == 0)
  {
    // 50 samples per second
    joystick_counter = 20;

    if(Wire.requestFrom(64, 2) == 0)
    {
      // error
    }
    else
    {
      joy_x = Wire.read();
      joy_y = Wire.read();
      // Handle X
      if((joy_x & 0x80) != 0)
      {
        // Negative X
        joy_x = joy_x - 255;
      }
      // Handle Y
      if((joy_y & 0x80) != 0)
      {
        // Negative Y
        joy_y = joy_y - 255;
      }
      // Serial.print("Joystick X = ");
      // Serial.print(joy_x);
      // Serial.print(" / ");      
      // Serial.print("Joystick Y = ");
      // Serial.println(joy_y);      
    }
  }
}