Issues with Arduino master reading ATTiny45 slave over I2C

I’m trying to use an Arduino Duemilanove as an I2C master to request values from an ATTiny45 20Mhz, which is using the ATTiny I2C library from I’m programming the ATTiny using the Arduino, which is working like a charm. The part that isn’t working is the I2C communication.

What happens is the Arduino will send Wire.requestFrom() and then just hang. It won’t even finish its first loop(). I see “Hello. started…requested…” on the serial monitor, and that’s it (see my code). Sometimes, I don’t even see “requested…”. Occasionally when I power cycle the ATTiny, the Arduino will run through loop() about ten times, then hang again. Never at any point does it actually receive any data from the ATTiny.

I am quite sure I have the ATTiny hooked up to the Arduino properly. The only other connections to the ATTiny are an LED and a momentary contact switch on pins 3 and 4 for feedback that the ATTiny is powered on and looping.

I have adjusted TWI_BUFFER_LENGTH to 6 as described in the

Here’s the Arduino code:

#include <Wire.h>

#define ATTiny1   1

void setup()
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output

  // enable internal pull-up resistors on SDA and SCL pins
  digitalWrite(A4, HIGH); // SDA (data)
  digitalWrite(A5, HIGH); // SCL (clock)


void loop()
  Wire.requestFrom(1, 1);    // request 6 bytes from slave device #2
  while(Wire.available())    // slave may send less than requested
    Serial.print("wire available: ");
    char c =; // receive a byte as character
    Serial.print(c);         // print the character


and here’s the ATTiny code:

#include <TinyWireS.h>
#include <usiTwiSlave.h>

#define ATTiny1   1

#define LED_PIN   3
#define BUTTON    4

void setup() {                
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON, INPUT);
  TinyWireS.begin(ATTiny1); // init I2C Slave mode

void loop() {
  if(digitalRead(BUTTON)==HIGH) digitalWrite(LED_PIN,HIGH);
  else digitalWrite(LED_PIN,LOW);
  // respond to master device
  // if requested, respond to master device with a 1
  if(TinyWireS.available()) {
    uint8_t data = 10;

Any help would be really appreciated; I’ve been working at this for two nights now and it’s still confounding me. Thanks!!

  Wire.requestFrom(1, 1);    // request 6 bytes from slave device #2

How many bytes?

just one byte. I tried to clean up the comments but evidently forgot that line. there's a couple other discrepancies like that in the comments, but they're only comments.

It’s just that you mentioned 6 before:

I have adjusted TWI_BUFFER_LENGTH to 6 …

Try pulling out the serial prints, or at least move them. The thing may be timing-dependent.

Have you got pull-up resistors on the signal lines? The Arduino's pull-ups usually aren't strong enough.

thanks guys. I don't have physical pull-up resistors on the signal lines, just the Arduino's. I'll try it again without serial prints and with actual pull-ups.

Any luck getting the I2C communication to work? I'm attempting the same thing, independently arrived at the same code, and unsurprisingly, have the same issue with it hanging up awaiting a response.