Interface Accelerometer With NodeMCU

3,403

29

2

Published

Introduction: Interface Accelerometer With NodeMCU

About: Work until you no longer have to introduce yourself.

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

Hardware Requirement

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

Software Requirements

  • Arduino IDE

Step 2: 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

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.

Y - NIL

Z - NIL

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

const int xPin = A0;    //x-axis of the Accelerometer
void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}
<p>void loop() {  <br>  int x = analogRead(xPin);
  delay(100);
  Serial.print("X-axis : ");
  Serial.println(x);
}</p>

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

  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

That's all makers!

I hope it helps you.

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest
    • Casting Contest

      Casting Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    2 Comments

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