The Adafruit MSA301 is a compact and versatile 3-axis accelerometer module capable of detecting acceleration in three-dimensional space. This sensor is ideal for a wide range of applications, including motion detection, tilt sensing, robotics, gaming devices, and fitness trackers. Its I2C communication protocol allows for easy integration with microcontrollers and development boards such as the Arduino UNO.
Pin Number | Name | Description |
---|---|---|
1 | VIN | Power supply (1.62V to 3.6V) |
2 | GND | Ground connection |
3 | SCL | I2C clock line |
4 | SDA | I2C data line |
5 | INT | Interrupt output (active low) |
#include <Wire.h>
#include <Adafruit_MSA301.h>
Adafruit_MSA301 msa;
void setup() {
Serial.begin(9600);
if (!msa.begin()) {
Serial.println("Failed to find MSA301 chip");
while (1) { delay(10); }
}
Serial.println("MSA301 Found!");
}
void loop() {
msa.read();
Serial.print("X: "); Serial.print(msa.x); Serial.print(" \tY: ");
Serial.print(msa.y); Serial.print(" \tZ: "); Serial.println(msa.z);
delay(100);
}
This example initializes the MSA301 accelerometer and continuously reads the X, Y, and Z acceleration values, printing them to the Serial Monitor.
Serial.begin(9600)
in your code.Q: Can the MSA301 be used with a 5V microcontroller? A: Yes, but ensure that the logic level for I2C communication is shifted down to 3.3V to avoid damaging the sensor.
Q: How can I change the sensitivity range of the accelerometer?
A: The sensitivity range can be set using the setRange()
function provided by the Adafruit_MSA301 library.
Q: What is the default I2C address of the MSA301? A: The default I2C address is 0x26.
For further assistance, consult the Adafruit MSA301 datasheet and the Adafruit_MSA301 library documentation.