BMA180 Three-Axis Accelerometer Demo Test with Arduino

They are a lot of postures sensors are available on our sites, such as ITG3200、ADXL345、ADXL335、HMC5883L、MPU6050、BMP085、MMA7361, and these ICs are more used on flying control, now we did some simple test with the Bosch BMA180 module.

Bosch BMA180 three axis digital accelerometer module has great performance than many others, it provides 14 bits digital output via a four-wires SPI jack or two-wires IIC (I2C) jack. Testing range can be set to ±1g, 1.5g, 2g, 4g, 8g, or 16g.

Further functions such as programmerable wake up, high or low g detection, water detection, slope detection, self-detection. This sensor has two operation modes: low filter, low power. BMA180 use a very tiny 3x3mm 12 pins LGA package, and it can works between 1.62 till 3.6V VDD and 1.2V till 3.6V VDDIO power, normally it only consume 650uA in standard mode.

Application

BMA 180 is a high performance three axis digital accelerometer sensor, aiming at low power consumer market.

Due to the high precision, it widely uses in Sen-Ses, motion, shock and vibration in cell phone, PDA and computer, human and machin e interface, face recognition, virtual reality or game control.

Please read more information on our BMA180 product page here, and check the datasheet in the product page too.

Pin Map of BMA 180

Compare BMA 180 with ADXL 345

Wiring

Wire the BMA180 module to Arduino

Demo code

after the wiring, now we can put the following demo codes into your arduino.

#include 

void setup()
{
  Serial.begin(115200);
  Wire.begin(); 

  Serial.println("Demo started, initializing sensors"); 

  AccelerometerInit();
//  GyroInit(); 

  Serial.println("Sensors have been initialized");
} 

void AccelerometerInit()
{
  Wire.beginTransmission(0x40); // address of the accelerometer
  // reset the accelerometer
  Wire.send(0x10);
  Wire.send(0xB6);
  Wire.endTransmission();
  delay(10); 

  Wire.beginTransmission(0x40); // address of the accelerometer
  // low pass filter, range settings
  Wire.send(0x0D);
  Wire.send(0x10);
  Wire.endTransmission(); 

  Wire.beginTransmission(0x40); // address of the accelerometer
  Wire.send(0x20); // read from here
  Wire.endTransmission();
  Wire.requestFrom(0x40, 1);
  byte data = Wire.receive();
  Wire.beginTransmission(0x40); // address of the accelerometer
  Wire.send(0x20);
  Wire.send(data & 0x0F); // low pass filter to 10 Hz
  Wire.endTransmission(); 

  Wire.beginTransmission(0x40); // address of the accelerometer
  Wire.send(0x35); // read from here
  Wire.endTransmission();
  Wire.requestFrom(0x40, 1);
  data = Wire.receive();
  Wire.beginTransmission(0x40); // address of the accelerometer
  Wire.send(0x35);
  Wire.send((data & 0xF1) | 0x04); // range +/- 2g
  Wire.endTransmission();
} 

void AccelerometerRead()
{
  Wire.beginTransmission(0x40); // address of the accelerometer
  Wire.send(0x02); // set read pointer to data
  Wire.endTransmission();
  Wire.requestFrom(0x40, 6); 

  // read in the 3 axis data, each one is 16 bits
  // print the data to terminal
  Serial.print("Accelerometer: X = ");
  short data = Wire.receive();
  data += Wire.receive() << 8;
  Serial.print(data);
  Serial.print(" , Y = ");
  data = Wire.receive();
  data += Wire.receive() << 8;
  Serial.print(data);
  Serial.print(" , Z = ");
  data = Wire.receive();
  data += Wire.receive() << 8;
  Serial.print(data);
  Serial.println();
} 

/*void GyroInit()
{
  Wire.beginTransmission(0x69); // address of the gyro
  // reset the gyro
  Wire.send(0x3E);
  Wire.send(0x80);
  Wire.endTransmission(); 

  Wire.beginTransmission(0x69); // address of the gyro
  // low pass filter 10 Hz
  Wire.send(0x16);
  Wire.send(0x1D);
  Wire.endTransmission(); 

  Wire.beginTransmission(0x69); // address of the gyro
  // use internal oscillator
  Wire.send(0x3E);
  Wire.send(0x01);
  Wire.endTransmission();
} 

void GyroRead()
{
  Wire.beginTransmission(0x69); // address of the gyro
  Wire.send(0x1D); // set read pointer
  Wire.endTransmission(); 

  Wire.requestFrom(0x69, 6); 

  // read in 3 axis of data, 16 bits each, print to terminal
  short data = Wire.receive() << 8;
  data += Wire.receive();
  Serial.print("Gyro: X = ");
  Serial.print(data);
  Serial.print(" , Y = ");
  data = Wire.receive() << 8;
  data += Wire.receive();
  Serial.print(data);
  Serial.print(" , Z = ");
  data = Wire.receive() << 8;
  data += Wire.receive();
  Serial.print(data);
  Serial.println();
} */

void loop()
{
  AccelerometerRead();
//  GyroRead(); 

  delay(500); // slow down output
}

From the arduino monitor, we can see the output from the sensor looks like this.

Tagged

Related Posts

6 comments on “BMA180 Three-Axis Accelerometer Demo Test with Arduino

  1. It error
    “‘amp’ was not declared in this scope”

    on this line
    “Wire.send(data & 0x0F); // low pass filter to 10 Hz”

  2. Aletzandre on said:

    Got the same prob, and I’ve got the latest Arduino version. =/

    sketch_oct15a.cpp: In function ‘void AccelerometerInit()’:
    sketch_oct15a:37: error: ‘amp’ was not declared in this scope

  3. #include

    void setup()
    {
    Serial.begin(115200);
    Wire.begin();

    Serial.println(“Demo started, initializing sensors”);

    AccelerometerInit();
    // GyroInit();

    Serial.println(“Sensors have been initialized”);
    }

    void AccelerometerInit()
    {
    Wire.beginTransmission(0×40); // address of the accelerometer
    // reset the accelerometer
    Wire.write(0×10);
    Wire.write(0xB6);
    Wire.endTransmission();
    delay(10);

    Wire.beginTransmission(0×40); // address of the accelerometer
    // low pass filter, range settings
    Wire.write(0x0D);
    Wire.write(0×10);
    Wire.endTransmission();

    Wire.beginTransmission(0×40); // address of the accelerometer
    Wire.write(0×20); // read from here
    Wire.endTransmission();
    Wire.requestFrom(0×40, 1);
    byte data = Wire.read();
    Wire.beginTransmission(0×40); // address of the accelerometer
    Wire.write(0×20);
    Wire.write(data & 0x0F); // low pass filter to 10 Hz
    Wire.endTransmission();

    Wire.beginTransmission(0×40); // address of the accelerometer
    Wire.write(0×35); // read from here
    Wire.endTransmission();
    Wire.requestFrom(0×40, 1);
    data = Wire.read();
    Wire.beginTransmission(0×40); // address of the accelerometer
    Wire.write(0×35);
    Wire.write((data & 0xF1) | 0×04); // range +/- 2g
    Wire.endTransmission();
    }

    void AccelerometerRead()
    {
    Wire.beginTransmission(0×40); // address of the accelerometer
    Wire.write(0×02); // set read pointer to data
    Wire.endTransmission();
    Wire.requestFrom(0×40, 6);

    // read in the 3 axis data, each one is 16 bits
    // print the data to terminal
    Serial.print(“Accelerometer: X = “);
    short data = Wire.read();
    data += Wire.read() << 8;
    Serial.print(data);
    Serial.print(" , Y = ");
    data = Wire.read();
    data += Wire.read() << 8;
    Serial.print(data);
    Serial.print(" , Z = ");
    data = Wire.read();
    data += Wire.read() << 8;
    Serial.print(data);
    Serial.println();
    }

    /*void GyroInit()
    {
    Wire.beginTransmission(0×69); // address of the gyro
    // reset the gyro
    Wire.send(0x3E);
    Wire.send(0×80);
    Wire.endTransmission();

    Wire.beginTransmission(0×69); // address of the gyro
    // low pass filter 10 Hz
    Wire.send(0×16);
    Wire.send(0x1D);
    Wire.endTransmission();

    Wire.beginTransmission(0×69); // address of the gyro
    // use internal oscillator
    Wire.send(0x3E);
    Wire.send(0×01);
    Wire.endTransmission();
    }

    void GyroRead()
    {
    Wire.beginTransmission(0×69); // address of the gyro
    Wire.send(0x1D); // set read pointer
    Wire.endTransmission();

    Wire.requestFrom(0×69, 6);

    // read in 3 axis of data, 16 bits each, print to terminal
    short data = Wire.receive() << 8;
    data += Wire.receive();
    Serial.print("Gyro: X = ");
    Serial.print(data);
    Serial.print(" , Y = ");
    data = Wire.receive() << 8;
    data += Wire.receive();
    Serial.print(data);
    Serial.print(" , Z = ");
    data = Wire.receive() << 8;
    data += Wire.receive();
    Serial.print(data);
    Serial.println();
    } */

    void loop()
    {
    AccelerometerRead();
    // GyroRead();

    delay(500); // slow down output
    }

Leave a reply

Your email address will not be published. Required fields are marked *

*