SparkFun
SparkFun Triple Axis Accelerometer Breakout - ADXL335
Breakout board for the 3 axis ADXL335 from Analog Devices. This is the latest in a long, proven line of analog sensors - the holy grail of accelerometers. Th...
Breakout board for the 3 axis ADXL335 from Analog Devices. This is the latest in a long, proven line of analog sensors - the holy grail of accelerometers. The ADXL335 is a triple axis MEMS accelerometer with extremely low noise and power consumption - only 320uA! The sensor has a full sensing range of +/-3g.
There is no on-board regulation, provided power should be between 1.8 and 3.6VDC.
Board comes fully assembled and tested with external components installed. The included 0.1uF capacitors set the bandwidth of each axis to 50Hz.
Not sure which accelerometer is right for you? Our Accelerometer and Gyro Buying Guide might help!
Dimensions: 0.7x0.7"
Documents:
- Schematic
- Eagle Files
- Datasheet (ADXL335)
- Wiring Example
- 3D cube project using a PIC
- GitHub
Jargon buster
Plain-language definitions for the technical terms used above.
- breakout
- A breakout is a small circuit board that makes a tiny or hard-to-solder component easier to connect to with standard pins. It matters because this OLED module can be wired into a microcontroller project without needing to solder directly to the display’s fine contacts.
- MEMS accelerometer
- A tiny motion sensor made using micro-electromechanical systems technology that measures acceleration and tilt. In a compass module, it helps correct the heading when the board is not perfectly flat.
Find this product in
Brands
Sensors & Input
ADXL335 Breakout Schematic
Schematic · 18.0 KB · Click any page to view full size
ADXL335 Datasheet
Datasheet · 417.0 KB · Click any page to view full size
Supplier page — sparkfun.com
Supplier Description · 624.8 KB · Click any page to view full size
Resources & Downloads
Guides, code examples, and more
Code Examples
Sample code to get started with this product
How to connect and code the ADXL335 with Arduino
/*
* ADXL335 3-Axis Analog Accelerometer with Arduino
* ------------------------------------------------------------
* The ADXL335 gives a separate analog voltage for each axis (X, Y, Z).
* 0 g sits near half the supply voltage; acceleration/tilt shifts each
* output by ~330 mV per g (at a 3.3 V supply).
*
* >>> The ADXL335 is a 3.3 V part (1.8-3.6 V). Do NOT power it from 5 V. <<<
*
* For accurate readings, power the sensor from 3.3 V and wire that SAME
* 3.3 V rail to the Arduino's AREF pin, then use analogReference(EXTERNAL)
* so the ADC and the sensor share one reference voltage.
*
* Wiring (Arduino Uno / Nano, 10-bit ADC):
* ADXL335 VCC -> 3.3 V
* ADXL335 GND -> GND
* ADXL335 X -> A0
* ADXL335 Y -> A1
* ADXL335 Z -> A2
* Arduino 3.3V -> AREF (the same rail that feeds VCC)
* ADXL335 ST -> leave unconnected (self-test pin)
*
* Calibration:
* 1. Set CALIBRATE_MODE = true, upload, open Serial Monitor (9600 baud).
* 2. Lay the board flat: Z reads ~1 g, X and Y read ~0 g. Note the
* 0 g raw count for each axis -> ZERO_X / ZERO_Y / ZERO_Z.
* 3. Point one axis straight up, then straight down; the two raw counts
* are 2 g apart, so (up - down) / 2 = COUNTS_PER_G.
* 4. Set CALIBRATE_MODE = false and re-upload.
*/
const bool CALIBRATE_MODE = false; // true = print raw ADC counts for calibration
// ----- Pins -----
const uint8_t PIN_X = A0;
const uint8_t PIN_Y = A1;
const uint8_t PIN_Z = A2;
// ----- Calibration constants (update from CALIBRATE_MODE output) -----
const int ZERO_X = 512; // raw count at 0 g
const int ZERO_Y = 512; // raw count at 0 g
const int ZERO_Z = 512; // raw count at 0 g
const float COUNTS_PER_G = 102.0f; // ~330 mV/g / (3.3 V / 1023) with 3.3 V AREF
const uint8_t SAMPLES = 16; // averaged reads per axis (noise reduction)
int readAxis(uint8_t pin) {
long sum = 0;
for (uint8_t i = 0; i < SAMPLES; i++) sum += analogRead(pin);
return (int)(sum / SAMPLES);
}
float toG(int raw, int zero) {
return (raw - zero) / COUNTS_PER_G;
}
void setup() {
Serial.begin(9600);
// MUST set EXTERNAL before any analogRead() when AREF is driven externally,
// otherwise the internal reference is shorted to AREF (can damage the MCU).
analogReference(EXTERNAL);
for (uint8_t i = 0; i < 8; i++) { analogRead(PIN_X); delay(2); } // let ADC settle
}
void loop() {
int rawX = readAxis(PIN_X);
int rawY = readAxis(PIN_Y);
int rawZ = readAxis(PIN_Z);
if (CALIBRATE_MODE) {
Serial.print("RAW X="); Serial.print(rawX);
Serial.print(" Y="); Serial.print(rawY);
Serial.print(" Z="); Serial.println(rawZ);
} else {
Serial.print("X="); Serial.print(toG(rawX, ZERO_X), 2); Serial.print(" g ");
Serial.print("Y="); Serial.print(toG(rawY, ZERO_Y), 2); Serial.print(" g ");
Serial.print("Z="); Serial.print(toG(rawZ, ZERO_Z), 2); Serial.println(" g");
}
delay(200);
}
Related Tutorials
Free guides on learn.littlebird.com.au