Introduction
The GY-61 is a digital accelerometer module designed to measure acceleration along three axes: X, Y, and Z. It is based on the ADXL345 sensor, which provides high-resolution (13-bit) data for motion detection, tilt sensing, and orientation measurement. The module is compact, lightweight, and easy to integrate into various projects, making it ideal for applications such as robotics, mobile devices, gaming controllers, and wearable technology.
Common Applications
- Motion detection and gesture recognition
- Tilt and orientation sensing
- Robotics and drone navigation
- Vibration monitoring
- Wearable devices and fitness trackers
Technical Specifications
The GY-61 module is built around the ADXL345 accelerometer sensor. Below are the key technical details:
Pin Configuration
The GY-61 module has a 6-pin interface. Below is the pinout description:
Usage Instructions
Connecting the GY-61 to an Arduino UNO
The GY-61 can be easily interfaced with an Arduino UNO using the I2C protocol. Below is the wiring guide:
Sample Arduino Code
The following code demonstrates how to read acceleration data from the GY-61 module using the I2C interface:
#include <Wire.h>
// ADXL345 I2C address
#define ADXL345_ADDRESS 0x53
// Register addresses
#define POWER_CTL 0x2D
#define DATA_FORMAT 0x31
#define DATAX0 0x32
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Initialize serial communication for debugging
// Initialize the ADXL345
Wire.beginTransmission(ADXL345_ADDRESS);
Wire.write(POWER_CTL); // Access POWER_CTL register
Wire.write(0x08); // Set measurement mode
Wire.endTransmission();
Wire.beginTransmission(ADXL345_ADDRESS);
Wire.write(DATA_FORMAT); // Access DATA_FORMAT register
Wire.write(0x08); // Set range to ±2g
Wire.endTransmission();
Serial.println("GY-61 initialized successfully!");
}
void loop() {
int16_t x, y, z;
// Request 6 bytes of data starting from DATAX0
Wire.beginTransmission(ADXL345_ADDRESS);
Wire.write(DATAX0);
Wire.endTransmission(false);
Wire.requestFrom(ADXL345_ADDRESS, 6);
// Read acceleration data
if (Wire.available() == 6) {
x = (Wire.read() | (Wire.read() << 8)); // Combine low and high bytes for X-axis
y = (Wire.read() | (Wire.read() << 8)); // Combine low and high bytes for Y-axis
z = (Wire.read() | (Wire.read() << 8)); // Combine low and high bytes for Z-axis
}
// Print acceleration values
Serial.print("X: ");
Serial.print(x);
Serial.print(" Y: ");
Serial.print(y);
Serial.print(" Z: ");
Serial.println(z);
delay(500); // Delay for readability
}
Important Considerations
- Power Supply: Ensure the module is powered within the specified voltage range (3.3V to 5V).
- I2C Pull-Up Resistors: If the I2C lines (SCL and SDA) are not already pulled up, add 4.7kΩ resistors to VCC.
- Interrupt Pin: The INT pin can be used for advanced features like motion detection but is optional for basic usage.
- Orientation: Mount the module securely to avoid vibrations or misalignment that could affect readings.
Troubleshooting and FAQs
Common Issues
No Data Output
- Cause: Incorrect wiring or loose connections.
- Solution: Double-check the wiring and ensure all connections are secure.
Incorrect or Unstable Readings
- Cause: Excessive noise or vibrations.
- Solution: Mount the module on a stable surface and use software filtering if needed.
I2C Communication Failure
- Cause: Incorrect I2C address or missing pull-up resistors.
- Solution: Verify the I2C address (default is 0x53) and add 4.7kΩ pull-up resistors to SCL and SDA lines.
FAQs
Can the GY-61 be used with 3.3V microcontrollers?
- Yes, the module supports both 3.3V and 5V logic levels.
How do I change the measurement range?
- Modify the
DATA_FORMAT register in the code to set the desired range (±2g, ±4g, ±8g, or ±16g).
What is the maximum sampling rate of the GY-61?
- The ADXL345 sensor supports a maximum output data rate of 3200 Hz.
By following this documentation, you can effectively integrate the GY-61 accelerometer module into your projects for reliable motion and orientation sensing.