4

I keep receiving the following error in myATTiny85-Slave code below:

sketch_mar12a.ino: In function 'void setup()':

sketch_mar12a:19: error: 'class USI_TWI_S' has no member named 'onRequest'

I have downloaded TinyWireS and TinyWireS.h clearly has a public function onRequest. I opened the .ZIP file (downloaded from https://github.com/rambo/TinyWire) and drag-dropped TinyWireS folder into the Arduino libraries folder. This is how I install ALL libraries.

I am using Arduino 1.0.6

What am I doing wrong?

ATTiny85-Slave Code:

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

byte t=10;

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

void loop()
{
}

void requestEvent()
{  
   TinyWireS.send(t);
}

Arduino Uno-Master Code:

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

 void setup() 
 {
     Wire.begin();
     Serial.begin(9600);
 }

 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 = ");
     Serial.println(num,DEC);
 }
3
  • How did you install the library?
    – Gerben
    Mar 13, 2015 at 15:35
  • I opened the .ZIP file (downloaded from github.com/rambo/TinyWire) and drag-dropped TinyWireS folder into the Arduino libraries folder. This is how I install ALL libraries.
    – lucidgold
    Mar 13, 2015 at 18:52
  • you may need to include: TinyWireS_stop_check(); in your loop
    – diy_bloke
    Feb 18, 2016 at 11:56

1 Answer 1

0

I was able to compile your code "ATTiny85-Slave Code" without problems.

You can try to extract the contents of the ZIP archive (i.e. the library) directly to the directory where your sketch is stored. #include "TinyWireS.h" should then pick up that version.

You should also switch on verbose output for the compilation to have a look at the directory in which the code is compiled. Here you would find (at least in my older Arduino IDE version) copies of the included files. (/tmp/build... on Linux systems.) You can then make sure the proper version of the files is used.

You can also search your drives for other copies of TinyWireS.h.

2
  • Which version of Arduino IDE are you using? What board did you select?
    – lucidgold
    Mar 14, 2015 at 16:45
  • I am using Arduino IDE 1.0. It compiles with any board selection... Note that I did not install the Tiny hardware specs, but did a small hack in usiTwiSlace.c, declaring all missing symbols as ints. Mar 14, 2015 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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