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(&quot;num = &quot;);
 Serial.println(num,DEC);

}

lucidgold
  • 233
  • 1
  • 3
  • 9

1 Answers1

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.

fuenfundachtzig
  • 1,515
  • 1
  • 14
  • 26
  • Which version of Arduino IDE are you using? What board did you select? – lucidgold Mar 14 '15 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. – fuenfundachtzig Mar 14 '15 at 17:32