SOLVED I2C only works without wire.begin?

So this one is new (to me):

I have a PCA9555DB port extender, and it works just like I want it, but only if I add the Wire.begin() in my setup (logical).

I have a PCF85134HL LCD display controller, and it DOES work but only if I remove the Wire.begin() from my code! It runs normally with all the wire functions (Weird stuff!).

Unfortunately, I have both in my project so I need to fix this somehow, but it's above my skills ATM. I could post my code, but not sure if the fault is in there, both IC's work, just not together.

I tried disabling the internal pull-ups, didn't work. Anyone have an idea where to look?

External libraries?

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>        
#include <EEPROM.h>
#include <Wire.h> 
#include <TimerOne.h> 
#include <avr/interrupt.h>

Did removed TimerOne to see if that’s the problem, had the same problems.

Are there libraries for controlling the PCA9555DB & PCF85134HL? I would guess a library has already done a wire.begin() as it's initialized and that's why one device works without it in your main code but the other device should still work without another wire.begin() if it's initialized/called after the first one. Time to post your code (using code tags or attach to your post)

Tried the TWIinit() as a test, no luck there. I'm communicating with both IC's directly, without the use of a external library.

Code is messy now, i'm debugging the life out of it! The loop contents I removed, it's really an initialization thing...

#include <Wire.h>

int Var1;

void setup() {

    Serial.begin(19200);
  //Wire.begin();
  Wire.beginTransmission(0x70);
  Wire.write(0x80);
  Wire.write(0xC8);
  Wire.write(0x00);
  Wire.write(0xF0);
  Var1 = Wire.endTransmission();
  Serial.write(Var1);
  
  Wire.beginTransmission(0x20);
  Wire.write(6);
  Wire.write(0xFF);  // low byte
  Wire.write(0xFF);    // high byte
  Var1 = Wire.endTransmission();  
  Serial.write(Var1);
  
}




void loop() {
  
}

Even doing just this, the problem occurs…
Can’t make it any better…

When I include the Wire.begin, the port expander returns a “0” (All OK) and the LCD controller a “2” (wrong address).
When I remove it, it’s the other way around…

Which Arduino board, or Arduino compatible microcontroller are you using ? Do you use the newest Arduino IDE 1.0.6 or 1.5.8 BETA ?

You must use Wire.begin() of course, it means the LCD controller is not at 0x20.

Run the sketch of the i2c_scanner : http://playground.arduino.cc/Main/I2cScanner It will find the addresses of both chips. The address of the expander can be 0x20 to 0x27, the LCD controller can be at 0x38 or 0x39.

Peter_n: Which Arduino board, or Arduino compatible microcontroller are you using ? Do you use the newest Arduino IDE 1.0.6 or 1.5.8 BETA ?

You must use Wire.begin() of course, it means the LCD controller is not at 0x20.

Run the sketch of the i2c_scanner : http://playground.arduino.cc/Main/I2cScanner It will find the addresses of both chips. The address of the expander can be 0x20 to 0x27, the LCD controller can be at 0x38 or 0x39.

Arduino Ethernet based board, And the arduino IDE 1.0.5-r2. The I2C scanner got me more addresses than I2C devices in the circuit, but one of them was 0x38. When i tried it, IT WORKED! awesomecakes! +1 But now i'm wondering, how did you know? And why does the documentation of the LCD device say "listens to the address 0x70 or 0x71"? :S

I opened both datasheet, scrolled down for a picture of the slave address.

The Arduino Wire library uses 0 to 127. That is bit 7 to bit 1 and shifted to the right (bit 0 is the read/write bit). Some manufacturers use the bits of the address without the shifting.

Where did you find that about 0x70 and 0x71, I can not even find the word "listen" in the datasheet : http://www.nxp.com/products/interface_and_connectivity/lcd_drivers/lcd_segment_drivers/PCF85134HL.html

Page 27, chapter 8.6 I2C-bus protocol

And your 100% right, I used the flat out address and didn’t take the bit shift into account from the wire library.

Blink a few times with your eyes and look at it again: "Two I2C-bus slave addresses (0111 000 and 0111 001) are used..."

That are 7 bits, with a space in the fysical location of the bits over the I2C bus, but bit 0 is omitted.

0111 000 = 011 - 1 000 = 0x38