Introduction: Interface Accelerometer With NodeMCU

Picture of Interface Accelerometer With NodeMCU

Hey Makers,

I'm with another simple Instructable. In this Instructable we will learn how to interface ADXL335 / GY-61 called as accelerometer with NodeMCU.

Step 1: Things Needed

Picture of Things Needed

Hardware Requirement

  • ADXL335 : Accelerometer Sensor
  • NodeMCU
  • Connecting Wires
  • BreadBoard
  • Micro USB Cable

Software Requirements

  • Arduino IDE

Step 2: Description

Picture of Description

The ADXL335 / GY-61 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 tilt-sensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.

There is no on-board regulation, provided power should be between 1.8 and 3.6VDC.

In general, ADXL335 is 3v3 compatible device, it's powered by a 3.3v source and also generates 3.3v peak outputs. It has three outputs for each axis, i.e. X, Y & Z. These are analog outputs and thus require an ADC in a micro-controller. NodeMCU solves this problem. We will be using the analog pin of NodeMCU.

Step 3: Circuit Connection

Picture of Circuit Connection

The Accelerometer module has 5 pins i.e.,

VCC - To be connected to NodeMCU +3.3v.

X - To be connected to Analog Pin A0 of the NodeMCU.



GND - To be connected to Ground Pin (GND) of the NodeMCU.

Note : Since NodeMCU has only one Analog Pin, you can connect either of X, Y, or Z pin to it.

Before you get started with coding you need Arduino IDE.To download Arduino IDE and for NodeMCU setup, you can check my previous instructacle.

Interfacing Servo Motor With NodeMCU

Step 4: Let's Begin to Code

Picture of Let's Begin to Code
const int xPin = A0;    //x-axis of the Accelerometer
void setup() {
  // initialize serial communications at 9600 bps:
<p>void loop() {  <br>  int x = analogRead(xPin);
  Serial.print("X-axis : ");

Download the "Accelerometer.ino" file and open it up in the Arduino IDE.

Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload.

You can tinker with it if you like based on the application, or just use it as it is.

Step 5: Upload the Code

Picture of Upload the Code
  1. Goto Tools
  2. Board > NodeMCU 1.0 (ESP - 12E Module)
  3. Port ( Choose the right Port )

**Make sure you have your NodeMCU model selected and the correct serial port ticked (see pics). Then just click the Upload button**

After you upload the code, you can see the Output on the Serial Monitor.

Step 6: Output Demonstration

Picture of Output Demonstration

That's all makers!

I hope it helps you.


FuadĆ1 (author)2017-07-25

How do I add Y and Z axis?

TheCircuit (author)FuadĆ12017-07-29

I had already mentioned, NodeMCU have only one Analog Pin so based on your application you can use either X, Y, Z axis

About This Instructable




Bio: Work until you no longer have to introduce yourself.
Add instructable to: