Trybotics Logo

Interface Accelerometer With NodeMCU

DESCRIPTION

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.

Description:

Hardware Requirement

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

Software Requirements

  • Arduino IDE

Description:

Description
2 More Images

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.

Description:

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

Description:

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.

Attachments

Description:

  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.

Description:

That's all makers!

I hope it helps you.


YOU MIGHT ALSO LIKE