[HELP] Teensy 3.5 - I2C - ATTiny85-20PU (TinyWireS.OnRequest not triggering!)

Status
Not open for further replies.

solsnare

Member
Hello Teensy Tinkerers,

I recently got the teensy, and am working on a project to create modular buttons that can attach to each other in a multitude of fashions.

I have most all of the design down, and have figured out how to achieve this.

The answer: Using ATTiny85 per module, and communicating to the master (Teensy 3.5).

And so far, development is working dandy:

I got the Teensy 3.5 programming, and succesfully SENDING data out to the ATTiny, and the ATTIny, depending on the amount of bytes, is flashing an LED so many times.

However, when trying to Request data from it, it doesn't trigger the function on the ATTiny slave (Tried many diff LED indications if the function is triggering, and sadly, it is not.)

Here is the GIST:
https://gist.github.com/anonymous/8d8b38a7e703fa75a33a453424f15f85

Please let me know wtf im doing wrong here... I've got sending data working, why does requesting it from the dang thing total shit..

BTW the response i get when testing this in the Serial Monitor looks like this:

Code:
Sent out byte: 0
returned # bytes: 1
Got Bytes back: 255
Sent out byte: 1
returned # bytes: 1
Got Bytes back: 255
Sent out byte: 5
returned # bytes: 1
Got Bytes back: 255

As you can see, something is wrong, it apparently /does/ get a response back, but it's always 255??? The dang OnRequest function definetly isn't triggering!
 
Any chance those 200 ms delays in receiveEvent() may be causing a problem?

I've moved that LED blink code to the requestEvent(), but still had the same problem. Except that it didnt blink anymore :(

But you're right, there shouldn't be any delays in those functions, unless also reciprocated on the master side (for any timed functions).

Just doesn't seem to be the issue :/
 
Any chance you could try using the Wire library on both sides?

Maybe Brian will comment about i2c_t3? But if I'm going to look into this, I'm pretty much only going to work with the Wire lib.

If there isn't a possibility of Wire lib on that attiny chip, maybe an Arduino Uno could be used as a stand-in for testing, at least to check whether the Teensy side is really working as it should?
 
Any chance you could try using the Wire library on both sides?

Maybe Brian will comment about i2c_t3? But if I'm going to look into this, I'm pretty much only going to work with the Wire lib.

If there isn't a possibility of Wire lib on that attiny chip, maybe an Arduino Uno could be used as a stand-in for testing, at least to check whether the Teensy side is really working as it should?

I've originally used Wire, and just recently tried i2c_t3 when looking for solutions. Sadly didn't effect anything.

Also i def can't use Wire lib on the ATTiny, doesn't compile, pretty sure using the TinyWireS library was the way to go (considering i've had decent success for most of it).

I don't have an UNO sadly, and am running dangerously low on funds as of late :(

I'm gonna keep dicking around until i get it to work, I just really don't get how recieving works but requesting doesnt... what the hellllllllll
 
Bump!

I'm totally stuck...

I loaded up the example programs that are 100% working in the TinyWireS library, which does a stress test and compares if the value sent, and value recieved is a match or not.

Looks like it's the same shit, the amount of bytes to be recieved back is a match, sent 4 bytes, recieved 4 bytes, but all the bytes are of value "FF", hence, 255... just as i am experiencing.

I tried a bunch of diff resistor values, 1k, 2.2k, 3.3k, 4.7k, 10k for the pull-ups on the lines, and though without pull-ups, the I2C's cant communicate at all, with any of these, the values on request only give me FF.

I was searching through the library that's provided, usiTwiSlave is what the TinyWireS library is referencing, and i really don't understand what's going on.

Don't mean to be a beggar, but i am so lost right now and am spending so much of my time trying every possible solution in the dark, with my limited understanding of electronics as a whole i feel like i'm going crazy.


Could someone please point me down some path that has light at the end of the tunnel?

I would love to debug whats going on here, apparently there some sort of "logic scanners" that exist, but i'm really poor and can't afford that right now..

Is it possible to hook up the SDA, and SCL lines to some digital or analog pins in the Teensy, to check the SDA line everytime the clock pulses, and print out a 1 or a 0, to see what bit data it's actually sending? Not really sure how this works, but that's the vibe i'm getting from it.
 
I've originally used Wire

Please post the code you tried with Wire, and I'll take a quick look. Also please remove any delays in the callback functions.

I don't have the attiny chip, so I'm going to have to use another board as a stand-in. But I'll use the Wire lib, so multiple boards can be pretty easily tested.

Just to set expectations, I'm *only* going to look at whether the Teensy side is working as it should. If the problem is on the attiny chip (in other words, if other boards work) and everything looks good on the oscilloscope, then you'll need to ask elsewhere for help with the attiny. I'm only going to run the code you post, and only if it uses Wire. Please be careful to post the correct code you've actually used. (yes, it happens sometimes that we get threads like this and the code I run turns out to be something the author cobbled together for the forum, not what they actually needed.... imagine I'm going to test once, so make sure you give me the right code you want tested)

If there does turn out to be problem on the Teensy side when using Wire, of course I intend to fully investigate and fix whatever's wrong.

Also, please test with 1.41-beta2. Some other fixes were recently made to Wire. That is the version I will use for testing. Please make sure the problem actually happens with version 1.41-beta2 before I test, ok?
 
I just did the test with the beta code, including the beta arduino that you specified it should use.

https://gist.github.com/anonymous/b1bec3b298f72056d6d0d0e90585b8a5

Here's the code i used. as stated, i can't use Wire on the ATTiny85-20pu. Must use the TinyWireS library.

Another thing, TinyWireM doesn't compile on the Teensy 3.5, not sure why but there a bunch of issues with the compilation that i'm not even gonna get into.

Anyways, with the new beta, the same behaviour happens.

On the slave code, the ATTiny, if the OnRequest call is being called, should follow the pattern of
OnRecieve -> Turn off the LED.
OnRequest -> Turn on the LED.
and that behaviour should loop.

Whats happening is
OnRecieve -> Turns off LED.
OnRequest -> Nothing happens apparenrly, cause the LED never turns back on... Whats happening here? No idea.
 
Hey

I just want to say that I'm dealing with the exact same issue. Except I am using an Arduino Uno togerther with an ATtiny85

-> Wire library on Arduino Uno Rev3
-> TinywireS lib. on ATtiny85 with 8Mhz internal clock

Using the stress test I always get 255 (ff) as an response

size: 4/ 4,MATCH
data: MISMATCH <<--- !!!
rand[0]: 55/ff
rand[1]: 8d/ff
rand[2]: 28/ff

With several "LED blinking tests" it seems that the requestEvent function doesn't gets triggerd.
I use 4.7k resistors
 
Status
Not open for further replies.
Back
Top