How to Interface ADXL335 Accelerometer Sensor with Arduino Uno

Have you ever wondered how your smartphone knows which way is up and which way is down? One of the greatest features of today’s smartphones is the ability to do so. They all have an accelerometer incorporated into the circuitry that detects when you tilt the device from side to side. This is how your smartphone determines when to change the screen layout from portrait to landscape.

Mobile devices, gaming systems, disc drive protection, image stabilisation, and sports and health equipment all use accelerometers in low-cost, low-power motion and tilt detection applications.In this blog, we will discuss what is an accelerometer and how to interface the ADXL335 accelerometer sensor with Arduino UNO.

ADXL335 Accelerometer

ADXL335 is an integrated, compact, ultra; low power, 3-axis MEMS accelerometer with signal conditioned voltage output. This breakout board for analogue devices is used for sensing motion and accelerometers using I2c or SPI communication.  This 3 axis accelerometer measures dynamic acceleration (motion, shock, or vibration) and static acceleration (tilt or gravity). Meanwhile, the ADXL335 Accelerometer Module requires no external devices and works on a 5V power supply. It can be directly interfaced to the ADC of a microcontroller without any external components. ADXL335 was designed with extremely low noise and power consumption of only 320uA used to sense motion or tilt(in case of non-moving) in 3 axes.

The MEMS (Micro Electrical Mechanical System) consists of a micromachined structure made of the silicon wafer suspended freely, which allows it to deflect in any direction when subject to acceleration. Thus, the deflection cause change in capacitance between plates and structure. Hence the change in deflection on each axis is measured as the output voltage proportional to acceleration on that axis. In order to interface with different devices of microcontrollers, a MOSFET based voltage level circuitry is used this module can sense with a full-scale sensing range of ±3 g. The compact size (1″ x 1″) of the breakout board makes it easy to mount the accelerometer to an existing system without the need for additional hardware. As a result,  provides a minimal effect on the performance of the system and of the accelerometer.

Features of ADXL335 Accelerometer

  • 3-axis sensing
  • Operating Voltage: 3V to 6V DC
  • Low power: 350 μA (typical)
  • Single-supply operation: 1.8 V to 3.6 V
  • 10,000 g shock survival
  • Excellent temperature stability
  • BW adjustment with a single capacitor per axis
  • Small, low profile package.
  • 4 mm × 4 mm × 1.45 mm LFCSP.
  • RoHS/WEEE lead-free compliant.

Pinout Diagram for ADXL335

  • VCC: Power supply pin i.e. connect 5V here.
  • X_OUT: X axis analog output.
  • Y_OUT: Y axis analog output.
  • Z_OUT: Z axis analog output.
  • GND: Ground pin i.e. connect ground here.

ADXL335 accelerometer provides analog voltage at the output X, Y, Z pins; which is proportional to the acceleration in respective directions i.e. X, Y, Z.

Hardware Required

  • Arduino Uno
  • ADXL335 Accelerometer
  • Breadboard.
  • Some Jumper Cables

Software Required

  • Arduino IDE
  • ADXL335 Library (Optional)

Wiring ADXL335 Accelerometer to Arduino UNO

Place the accelerometer on your breadboard first. Connect the VCC pin to the Arduino’s 5V pin and the GND pin to the Arduino’s Ground pin. Connect the X, Y, and Z outputs to Arduino’s analogue pins A0, A1, and A2.

The analogue reference (AREF) voltage of the Arduino must be changed for precise results. This can be accomplished by connecting the Arduino’s 3.3V pin to the AREF pin.

After you’ve finished, you should have something that looks like the illustration below.

Arduino Code – Reading ADXL335 accelerometer

const int xInput = A0;
const int yInput = A1;
const int zInput = A2;

// initialize minimum and maximum Raw Ranges for each axis
int RawMin = 0;
int RawMax = 1023;

// Take multiple samples to reduce noise
const int sampleSize = 10;

void setup()

void loop()
//Read raw values
int xRaw = ReadAxis(xInput);
int yRaw = ReadAxis(yInput);
int zRaw = ReadAxis(zInput);

// Convert raw values to ‘milli-Gs”
long xScaled = map(xRaw, RawMin, RawMax, -3000, 3000);
long yScaled = map(yRaw, RawMin, RawMax, -3000, 3000);
long zScaled = map(zRaw, RawMin, RawMax, -3000, 3000);

// re-scale to fractional Gs
float xAccel = xScaled / 1000.0;
float yAccel = yScaled / 1000.0;
float zAccel = zScaled / 1000.0;

Serial.print(“X, Y, Z :: “);
Serial.print(“, “);
Serial.print(“, “);
Serial.print(” :: “);
Serial.print(“G, “);
Serial.print(“G, “);


// Take samples and return the average
int ReadAxis(int axisPin)
long reading = 0;
for (int i = 0; i < sampleSize; i++)
reading += analogRead(axisPin);
return reading/sampleSize;


Following image shows the accelerometer output on serial monitor at different positions.

ADXL335 Accelerometer Output on +X axis
ADXL335 Accelerometer Output on -Y axis
ADXL335 Accelerometer Output on -X axis
ADXL335 Accelerometer Output on +Y axis
ADXL335 Accelerometer Output on -Z axis
ADXL335 Accelerometer Output on +Z axis


  • Mobile phones use an accelerometer to check the rotation of devices and play games.
  • Smart bands/Smartwatches use accelerometer which detects running, walking, climbing, etc…
  • Automotive vehicles use an accelerometer to detect collisions and open airbags in an instant.
  • GPS systems use the accelerometer for navigation and checking the speed of moving objects.
  • Cameras use an accelerometer for image stabilization to capture clear photographs.
  • RC Drones use an accelerometer for balancing and stabilization.
  • Used in laptop hard drive to shut it off when the laptop is on free fall.
  • Game controllers also use an accelerometer. Such as PSP, XBOX
  • Used to measure earthquake activity and aftershocks.
  • Used in the Internal Navigation System (INS). That is, measuring the position, orientation, and velocity of an object in motion without the use of any external reference.

Leave a Reply

Your email address will not be published.