Espruino and ADXL335 accelerometer example

The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tiltsensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.

The user selects the bandwidth of the accelerometer using the CX, CY, and CZ capacitors at the XOUT, YOUT, and ZOUT pins. Bandwidths can be selected to suit the application, with a range of 0.5 Hz to 1600 Hz for X and Y axes, and a range of 0.5 Hz to 550 Hz for the Z axis.

Here is a typical module that makes it easy to work with the ADXL335


Name: ADXL335 module (triaxial accelerometer analog output)
Model: GY-61
Power supply :3-5v
Analog X, Y, Z three-axis output


The following layout shows how to wire the ADXL335 module up to an Espruino

espruino and ADXL335
espruino and ADXL335



This is code from the default example, I used the Espruino Web IDE

[codesyntax lang=”javascript”]

 var foo = require("ADXL335").connect(C3,A0,A1);
  setInterval(function() {
    var d= foo.readG();
    console.log("x " + d[0] + " y " + d[1] + " z " + d[2]);
  }, 1000);



x 0.46150911726 y -0.37102311741 z -0.69085221637
x 0.46883344777 y -0.36858167391 z -0.69573510337
x 0.46395056076 y -0.37346456092 z -0.69573510337
x 1.56015869382 y -0.13664454108 z 0.74959945067
x 0.63973449301 y 0.53963530937 z -0.20744640268
x 0.15388723582 y 0.06599526970 z 0.06599526970
x 0.62264438849 y -0.29533836881 z 0.57869840543
x 1.08896009765 y -0.53704127565 z 0.02204928664
x 0.23201342793 y -0.39543755245 z 0.56160830090

The sensor costs under $2

GY-61 ADXL335 Module Triaxial Acceleration Gravity Angle Sensor

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :