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);
}
-
How did you install the library?Gerben– Gerben2015年03月13日 15:35:34 +00:00Commented 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– lucidgold2015年03月13日 18:52:59 +00:00Commented Mar 13, 2015 at 18:52
-
you may need to include: TinyWireS_stop_check(); in your loopdiy_bloke– diy_bloke2016年02月18日 11:56:27 +00:00Commented Feb 18, 2016 at 11:56
1 Answer 1
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
.
-
Which version of Arduino IDE are you using? What board did you select?lucidgold– lucidgold2015年03月14日 16:45:47 +00:00Commented 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 inusiTwiSlace.c
, declaring all missing symbols asint
s.fuenfundachtzig– fuenfundachtzig2015年03月14日 17:32:34 +00:00Commented Mar 14, 2015 at 17:32