I tried to set up an I2C conversation between ab ATTiny85 (8MHz) and an Arduino Uno. However I always get a 255 response from my I2C slave. I am using Arduino 1.8.5.

What am I doing wrong?

ATTiny85-Slave Code:

#include "TinyWireS.h"  // wrapper class for I2C slave 
#define I2C_SLAVE_ADDR  0x26 // i2c slave address (38)

byte t=10;

void setup() {
  TinyWireS.begin(I2C_SLAVE_ADDR);  // init I2C Slave mode

void loop() {

void requestEvent() {

Arduino Uno-Master Code:

 #include <Wire.h>
 #define I2C_SLAVE_ADDR  0x26 // i2c slave address (38)

void setup() {

void loop() {
  byte num;
  // read 1 byte, from address 0x26
  Wire.requestFrom(I2C_SLAVE_ADDR, 1);
  while(Wire.available()) {
    num = Wire.read();
  Serial.print("num = ");
  • Where is the TinyWireS_stop_check ? The value of 255 is when the Wire.read() returns -1 which means that you did not receive valid data from the slave. You could run a i2c scanner and keep it running on the Uno, while trying to fix the wiring or the slave sketch. If that is working, then try to receive or send data.
    – Jot
    Jan 10, 2018 at 23:21
  • @Jot - can you explain why Wire.read() would yield -1 when wire.available() is nonzero? Jan 11, 2018 at 2:35
  • @ChrisStratton you are right, when wire.available shows that there is data, then -1 is not returned. I didn't think that through. I was trying to tell it in a common way, because there is an other possibility: when the slave behaves badly, perhaps the slave aknowledges with a ack to its address, but fails to send data so the sda stays high resulting in 255. Maybe there are even more possibilities when the slave does weird things.
    – Jot
    Jan 11, 2018 at 2:51
  • 1
    Seems that am not the only one. forum.pjrc.com/threads/… ...strange :-(
    – Wolfgang
    Jan 11, 2018 at 12:08

1 Answer 1


It may seem that the current commit of January 2018 from the TinyWire library is corrupt. Try using an older version from 2017, for example this one: https://github.com/rambo/TinyWire/tr...72a13504bbfc4e

This solves the problem for me as well.

Source: Teensy 3.5 - I2C - ATTiny85-20PU (TinyWireS.OnRequest not triggering!) - Post #11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.