user29725: I am trying to connect the MMA8452Q with AtTiny85 using the TinyWireM library.
I made the proper hardware setup with  pull-ups on  SCL and SDA pins - tested it on Arduino
Uno and it works, however when i connect the Tiny I cannot even get the handshake.
The following code produces output 13 instead of 42 (0x2A)
HARDWARE SETUP
MMA8452 Breakout ------------AtTiny85
3.3V -------voltage regulator------ 5V
SDA -----------^^(330)^^----------- PB0 (on attiny programmer marked as 5)
SCL -----------^^(330)^^----------- PB3 (on attiny programmer marked as 2)
GND --------------------------------- GND
(I also tried different pins with no luck)
CODE
//---bluetooth console communication stuff---//
#include <SoftwareSerial.h>
#define rxPin 1 //not important - needed for initialization
#define txPin A2
SoftwareSerial blueTooth(rxPin, txPin);
//      ---     //


#include "TinyWireM.h" // Used for I2C

// The SparkFun breakout board defaults to 1, set to 0 if SA0 jumper on the bottom of the board is set
#define MMA8452_ADDRESS 0x1D  // 0x1D if SA0 is high, 0x1C if low


#define WHO_AM_I   0x0D



void setup() {

  blueTooth.begin(9600);
  delay(1000);
  TinyWireM.begin(); //Join the bus as a master
  delay(1000);
 }

void loop() {
   byte c =0;
   c = readRegister(WHO_AM_I); 
   blueTooth.println(c); 
   delay(1000);
  }


 // Read a single byte from addressToRead and return it as a byte
byte readRegister(byte addressToRead) {
  TinyWireM.beginTransmission(MMA8452_ADDRESS);
  TinyWireM.send(addressToRead);
  TinyWireM.endTransmission(); //endTransmission but keep the connection active

  TinyWireM.requestFrom(MMA8452_ADDRESS, 1); //Ask for 1 byte, once done, bus is released by default

  while(!TinyWireM.available()) ; //Wait for the data to come back
  return TinyWireM.receive(); //Return this one byte
} 

Would anyone know how to get it right?

user50469: On an ATtiny85 pin 5 (PB0) is SDA and pin 7 (PB2) is SCL for the I2C interface.  You're using the wrong pin for SCL.
Additionally, your pull-up resistors are too strong.  Somewhere between 4.7K Ohm and 10K Ohm are recommended for pull-up's on the SDA and SCL lines.

29725: <p>I am trying to connect the MMA8452Q with AtTiny85 using the TinyWireM library.
I made the proper hardware setup with  pull-ups on  SCL and SDA pins - tested it on Arduino
Uno and it works, however when i connect the Tiny I cannot even get the handshake.
The following code produces output <code>13</code> instead of <code>42</code> (0x2A)</p>

<p><strong>HARDWARE SETUP</strong></p>

<p>MMA8452 Breakout ------------AtTiny85</p>

<p>3.3V -------voltage regulator------ 5V</p>

<p>SDA -----------^^(330)^^----------- PB0 (on attiny programmer marked as 5)</p>

<p>SCL -----------^^(330)^^----------- PB3 (on attiny programmer marked as 2)</p>

<p>GND --------------------------------- GND</p>

<p>(I also tried different pins with no luck)</p>

<p><strong>CODE</strong></p>

<pre><code>//---bluetooth console communication stuff---//
#include &lt;SoftwareSerial.h&gt;
#define rxPin 1 //not important - needed for initialization
#define txPin A2
SoftwareSerial blueTooth(rxPin, txPin);
//      ---     //


#include "TinyWireM.h" // Used for I2C

// The SparkFun breakout board defaults to 1, set to 0 if SA0 jumper on the bottom of the board is set
#define MMA8452_ADDRESS 0x1D  // 0x1D if SA0 is high, 0x1C if low


#define WHO_AM_I   0x0D



void setup() {

  blueTooth.begin(9600);
  delay(1000);
  TinyWireM.begin(); //Join the bus as a master
  delay(1000);
 }

void loop() {
   byte c =0;
   c = readRegister(WHO_AM_I); 
   blueTooth.println(c); 
   delay(1000);
  }


 // Read a single byte from addressToRead and return it as a byte
byte readRegister(byte addressToRead) {
  TinyWireM.beginTransmission(MMA8452_ADDRESS);
  TinyWireM.send(addressToRead);
  TinyWireM.endTransmission(); //endTransmission but keep the connection active

  TinyWireM.requestFrom(MMA8452_ADDRESS, 1); //Ask for 1 byte, once done, bus is released by default

  while(!TinyWireM.available()) ; //Wait for the data to come back
  return TinyWireM.receive(); //Return this one byte
} 
</code></pre>

<p>Would anyone know how to get it right?</p>
 50469: <p>On an ATtiny85 pin 5 (PB0) is SDA and pin 7 (PB2) is SCL for the I2C interface.  You're using the wrong pin for SCL.</p>

<p>Additionally, your pull-up resistors are too strong.  Somewhere between 4.7K Ohm and 10K Ohm are recommended for pull-up's on the SDA and SCL lines.</p>
