1

I'm trying to make the ATTiny85 work with the MMA7660 accelerometer, so far, without any success. Google search for "ATTiny85 MMA7660" gives poor results, and I'm not sure it has been done at all, at least publicly, so I thought I'll try my luck here.

What I've tried is using the TinyWireM library, in different combinations. The last one is based on the MMA7660 Arduino library, specially adjusted to the TinyWireM, and taken from this post in Arduino forums (direct link to download).

The SCL is connected to PB0 and SDA to PB2, with 5k ohm pull-ups (I know that the recommended is 4.7k but this is what I have available, and I assumed it shouldn't make much difference).

I am using the Arduino IDE v1.5.6, which works successfully with other non-I2C attiny projects I have.

As for the final code I am using the .pde example that comes with the MMA7660, altered to use SoftwareSerial:

#include <TinyWireM.h>
#include <MMA7660.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(-1,4);

void setup()
{
  mySerial.begin(9600);
  MMA7660.init();
}

void loop()
{
  int x,y,z;
  delay(100); // There will be new values every 100ms
  MMA7660.getValues(&x,&y,&z);
  mySerial.print("x: ");
  mySerial.print(x);
  mySerial.print(" y: ");
  mySerial.print(y);
  mySerial.print(" z: ");
  mySerial.println(z);

}

The current problem with the above code is that the pointers just dump some memory without making any sense. If I try to see what TinyWireM.receive() command returns, values are 216 for all three variables. This is true even when I disconnect the MMA7660 from the prototyping board...! so I assume the problem is with the I2C itself, not working properly. The actual I2C address for the MMA (0x4C) and other relevant code is in MMA7660.cpp.

Any ideas?... Unfortunately I don't currently have another I2C device to examine the health of this protocol with my ATTiny85, so any experience you might have with this sort of configuration will be blessed.

EDIT: I marked dvlabsllc's answer as accepted answer since it gave me the right direction to pinpoint the issue further down the library path. I have opened a new question regarding TinyWireM library here.

1

I have run into similar frustrations using standard libraries and I2C. I would have to look into the code and try it out on my own before confirming anything about this particular code; however, in the meantime you might want to try a tool such as I2cScanner that simply scans the I2C bus for all possible addresses and reports addresses that are "alive". This (or something similar as I am not sure if you are using Arduino API) might be a good start to just see if the I2C is working and that you have the correct address.

  • I am using the Arduino API. Unfortunately it seems that the I2C scanner was built to use the Wire library, which relays on the Atmega328 built-in I2C chip. I will try to alter it to work with TinyWire. – Omer Jun 3 '14 at 17:58

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.