Go Down

Topic: Acceleration Sensor BMA020 (Read 6 times) previous topic - next topic

wayneft

Post your code and tell us what problem you're having.
I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter

domj

hey everybody,

i spend the last days getting to learn arduino (uno), made some things work and now im trying to learn i2c with the wire library.

my goal is to read the acceleration values from the bosch bma020, so exactly what has been discussed in this topic - it just doesnt want to work!

i wired the ardunio correctly to the bma as shown here:
http://static.rcgroups.net/forums/attachments/3/0/8/5/3/6/a3730195-245-BMA020%20to%20Arduino%20V1.jpg?d=1295131257

its all connected to 5v which should be ok since the IC has internal converter.

i attached pullups to the data and clock line vs vcc (tried 2k and 7.5 k) - nothing helps.

all i get back from the i2c bus are zeros. it stops giving me zeros when i disconnect vcc from the ciruit.

i took the sourcecode from above an modified it to see, if the 0x00 adress gives back a 2 - it doesnt :(

it would be great if somebody could take a look at my code an tell me, if i did something obviously wrong. if not the ic has to be broken...

here is my code:

Code: [Select]

/*
*  Arduino analog input 5 - I2C SCL
*  Arduino analog input 4 - I2C SDA
*/

#include <Wire.h>

#define ACCELEROMETER 0x38

#define Test_OUT   0x00
#define X_OUT1    0x02
#define X_OUT2    0x03
#define Y_OUT1    0x04
#define Y_OUT2    0x05
#define Z_OUT1    0x06
#define Z_OUT2    0x07


void setup() {

    Wire.begin();
    Serial.begin(9600);
}


void loop() {

    Serial.println(); 
    Serial.print("Signal on Device Address ");
    Serial.print(ACCELEROMETER, HEX);
    Serial.print(" in Register No ");   
    Serial.print(Test_OUT, HEX);
    Serial.print(" is: ");       
    Serial.print((unsigned int)accRead(Test_OUT), BIN);
    Serial.println(); 
/*    Serial.print("X: ");
    Serial.print((unsigned int)accRead(X_OUT1), BIN);   
    Serial.print ("      ");
    Serial.print((unsigned int)accRead(X_OUT2), BIN);
    Serial.println(); 
    Serial.print("Y: ");
    Serial.print((unsigned int)accRead(Y_OUT1), BIN);
    Serial.print ("      ");
    Serial.print((unsigned int)accRead(Y_OUT2), BIN);
    Serial.println(); 
    Serial.print("Z: ");
    Serial.print((unsigned int)accRead(Z_OUT1), BIN);
    Serial.print ("      ");
    Serial.print((unsigned int)accRead(Z_OUT2), BIN);
    Serial.println();
*/   
    delay(500);
}

byte accRead(byte address){
    byte val = 0x00;
    Wire.beginTransmission(ACCELEROMETER);
         
    Wire.send(address);

    Wire.endTransmission();
   
    Wire.requestFrom(ACCELEROMETER, 1);

    val = Wire.receive();

    return val;
}


here is what comes from the serial montior:

Quote
Signal on Device Address 38 in Register No 0 is: 0


Thanks!!!


[/size]

domj

PS:

i removed the last Wire.endTransmission() because this tutorial says it is not neccesary:

http://tronixstuff.wordpress.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/

(which is a really good tutorial for newbies like me ;)  )

cheers

dom

domj

PPS:

i have to correct myself - Of Course the ic itself can NOT handle 5v - however i use the IC on a breakout board deliverd/made by elv which has the level translator on board.

wayneft

Well if you're confident you have it wired up correctly and the above code is not returning a 2 then there may be something wrong with the sensor.  I can see that your link has additional pins on the breakout board.  Do you have a link to that schematic by any chance?
I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter

Go Up