Adafruit Analog Accelerometer Breakouts Created by Bill Earl Last updated on 2013-10-02 06:15:18 AM EDT
Guide Contents Guide Contents 2 Overview 3 How it Works: 3 MEMS - Micro Electro-Mechanical Systems 3 Ratiometric Output 4 Assembly and Wiring 5 Assembly: 5 Prepare the header strip: 5 Add the breakout board: 5 And Solder! 5 Wiring: 5 Connect the Power: 5 Connect the X, Y and Z Signal Outputs: 6 Using the Voltage Reference: 6 Calibration and Programming 8 Static Calibration: 8 Gravity as a Calibration Reference 8 Calibration Method: 8 Run the Calibration Sketch 10 Calibr
Overview The ADXL335 , ADXL326 and ADXL377 are low-power, 3-axis MEMS accelerometer modules with ratiometric analog voltage outputs. The Adafruit Breakout boards for these modules feature on-board 3.3v voltage regulation which makes them simple to interface with 5v microcontrollers such as the Arduino. The ADXL335 can measure at least +/3G in the X, Y and Z axis.
converted to an output voltage proportional to the acceleration on that axis. Ratiometric Output Ratiometric output means that the output voltage increases linearly with acceleration over the range. For the ADXL335, that is approximately 0v at -3G to 3.3v at +3G. For the ADXL326, that is approximately 0v at -16G to 3.3v at +16G. For the ADXL377, that is approximately 0v at -200G to 3.3v at +200G. For all modules, the output at 0G in each axis, is about 1/2 full-scale, or 1.65v.
Assembly and Wiring Assembly: These boards come with all surface-mount components pre-soldered. The included header strip can be soldered on for convenient use on a breadboard or with 0.1" connectors. However, for applications subject to extreme accelerations, shock or vibration, locking connectors or direct soldering plus strain relief is advised. Prepare the header strip: Cut the strip[ to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down.
Connect the VIN pin to the 5v pin on the Arduino. (For 3.3v microprocessors, connect the pin marked 3Vo to the 3.3v supply) Connect the X, Y and Z Signal Outputs: Connect X, Y and Z to the analog pins as shown below: Using the Voltage Reference: For the best possible accuracy and precision, you can use the output of the accelerometer boards voltage regulator as the analog reference for the Arduino. Connect the 3Vo pin on the accelerometer board to the AREF pin on the Arduino.
analog reference to EXTERNAL before calling analogRead() (e.g. in your setup() function). Otherwise, you will short the internal reference with the external reference, possibly damaging your Arduino board. © Adafruit Industries http://learn.adafruit.
Calibration and Programming Static Calibration: As with all sensors, there is some variation in output between samples of these accelerometers. For non-critical applications such as game controllers, or simple motion or tilt sensors, these variations are not important. But for applications requiring precise measurements, calibration to a reliable reference is a good idea.
Mo unt the Senso r: First mount the sensor to a small breadboard (http://adafru.it/65) like the one on the left. The back and squared edges of the breadboard make a reasonably accurate set of reference planes to orient the sensor for calibration. Wire the Senso r: Wire the sensor as shown below. This is equivalent to the circuit shown on the previous page, with the addition of a switch. © Adafruit Industries http://learn.adafruit.
Run the Calibration Sketch Load the sketch below onto the Arduino and run it. Open the Serial Monitor. Lay the breadboard with the sensor on a flat surface Press and hold the button until you see "Calibrate" in the serial monitor. This will calibrate the minimum value for the z axis. Stand the breadboard on the front edge and press the button again. to calibrate +y Repeat this for the three other edges to calibrate +x, -y and -x. Turn the breadboard upside down and press the button again to calibrate +z.
const int xInput = A0; const int yInput = A1; const int zInput = A2; const int buttonPin = 2; // Raw Ranges: // initialize to mid-range and allow calibration to // find the minimum and maximum for each axis int xRawMin = 512; int xRawMax = 512; int yRawMin = 512; int yRawMax = 512; int zRawMin = 512; int zRawMax = 512; // Take multiple samples to reduce noise const int sampleSize = 10; void setup() { analogReference(EXTERNAL); Serial.
Serial.print(zRaw); // Convert raw values to 'milli-Gs" long xScaled = map(xRaw, xRawMin, xRawMax, -1000, 1000); long yScaled = map(yRaw, yRawMin, yRawMax, -1000, 1000); long zScaled = map(zRaw, zRawMin, zRawMax, -1000, 1000); // re-scale to fractional Gs float xAccel = xScaled / 1000.0; float yAccel = yScaled / 1000.0; float zAccel = zScaled / 1000.0; Serial.print(" :: "); Serial.print(xAccel); Serial.print("G, "); Serial.print(yAccel); Serial.print("G, "); Serial.print(zAccel); Serial.
if (yRaw > yRawMax) { yRawMax = yRaw; } if (zRaw < zRawMin) { zRawMin = zRaw; } if (zRaw > zRawMax) { zRawMax = zRaw; } } © Adafruit Industries http://learn.adafruit.
Downloads Data Sheets: ADXL335 Documentation Page (http://adafru.it/aRF) ADXL326 Documentation Page (http://adafru.it/aRG) ADXL377 Data Sheet: (http://adafru.it/cLj) Board Files: ADXL335 and ADXL326 Breakout Board Eagle Files (http://adafru.