Skip to content

Can this lib be used on ATTiny85 ? #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebcaps opened this issue Mar 22, 2020 · 3 comments
Closed

Can this lib be used on ATTiny85 ? #43

sebcaps opened this issue Mar 22, 2020 · 3 comments

Comments

@sebcaps
Copy link

sebcaps commented Mar 22, 2020

I'd like to use this lib on ATtiny85, but while compiling I've got many errors which seems related to Wire.h lib (see below and here
Arduino: 1.8.10 (Windows 10), Board: "ATtiny25/45/85, ATtiny45, Internal 1 MHz" C:\Users\seb\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src\utility\twi.c: In function 'twi_init': C:\Users\seb\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src\utility\twi.c:76:16: error: 'SDA' undeclared (first use in this function) digitalWrite(SDA, 1);^~~C:\Users\seb\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src\utility\twi.c:76:16: note: each undeclared identifier is reported only once for each function it appears in C:\Users\seb\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src\utility\twi.c:77:16: error: 'SCL' undeclared (first use in this function); did you mean 'SPL'? digitalWrite(SCL, 1);^~~SPL In file included from c:\users\seb\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0, from C:\Users\seb\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src\utility\twi.c:25:C:\Users\seb\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src\utility\twi.c:80:7: error: 'TWSR' undeclared (first use in this function); did you mean 'ACSR'? cbi(TWSR, TWPS0);

I tried to replace Wire lib with TinyWire with no more success.

Any help appreciated !
Thx

@pwm84
Copy link

pwm84 commented Apr 23, 2020

In Adafruit MCP23017.h, change lines 17-22 as follows:

// Don't forget the Wire library
//#ifdef AVR_ATtiny85 //TinyWireM is now part of
#include <TinyWireM.h> // Adafruit version of Wire Library
//#else
//#include <Wire.h>
//#endif

@dertobias
Copy link

dertobias commented Mar 29, 2021

also you have to add those lines
after including TinyWireM.h
#define Wire TinyWireM
#define TwoWire USI_TWI

https://forum.arduino.cc/index.php?topic=656742.0

….and don't forget external pull-ups for scl & sda 😅

@caternuson
Copy link
Contributor

Yep, it should work as long as you can get an I2C library to build for the tiny. Fixing #63 should help with this also, since it will allow whatever I2C bus to be passed in, either Wire or TinyWire based.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants