STEP 1 / 6ESP + IOT

ESP8266 NodeMCU Integrated with MPU-6050 Accelerometer, Gyroscope, and Temperature Sensor (Arduino)

422.ESP8266 NodeMCU Integrated with MPU-6050 Accelerometer, Gyroscope, and Temperature Sensor (Arduino) Through the completion of this project, you will acquire the knowledge necessary to…

Because of this, we are able to figure out the orientation of an object.
PROJECT#422
TRACKIoT
PARTS06
STAGES06
STEP 1 / 6 · Overview

Know the mission before touching a wire.

Understand what you are making, prepare the right tools, and make the workbench safe.

01

Project details

ESP8266 NodeMCU Integrated with MPU-6050 Accelerometer, Gyroscope, and Temperature Sensor (Arduino) is a iot project. 422.ESP8266 NodeMCU Integrated with MPU-6050 Accelerometer, Gyroscope, and Temperature Sensor (Arduino) Through the completion of this project, you will acquire the knowledge necessary to…

Source pages
1005-1011
Named parts
6
Build goal
Working, tested prototype
02

Tools you need

  • Digital multimeter
  • Wire stripper and side cutters
  • Soldering iron with a fine tip
  • Current-limited bench supply
  • Computer with a data-capable USB cable

Use eye protection, good lighting, and a clean insulated surface throughout the build.

03

Safety precautions

  • Disconnect every power source before changing a connection.
  • Check component polarity, pinout, and supply voltage twice.
  • Use a current limit for the first power-up.
  • Keep liquids, loose metal, and uninsulated wires away from the bench.
Ready to continue?
STEP 2 / 6 · Parts library

Gather, identify, and understand every part.

Use the standardized inventory, then open What's this? to learn each part's role, advantages, limitations, handling, and specifications.

NAMED PROJECT INVENTORY6 PART LINES
PARTTYPEQTYREADY
PMPU-6050 Accelerometer GyroscopePART1
What's this?Image, role, pros, cons, handling & specifications
Because of this, we are able to figure out the orientation of an object.PART LEARNING VIEW

MPU-6050 Accelerometer Gyroscope

A named project component whose exact role is defined by the source circuit and build guide.

What it does here

It performs a documented electrical, control, interface, or construction function in this project.

Buy / compare this part

Advantages

  • Selected for this project
  • Can be checked independently
  • Supports modular troubleshooting

Limitations

  • Substitutes may differ
  • Generic names can hide variants
  • Pinouts and ratings vary

Handling

  • Compare the received part with the source
  • Keep it labelled
  • Do not force connectors or adjusters

Specifications to verify

  • Use the exact model, value, package, and rating listed for MPU-6050 Accelerometer Gyroscope; similar-looking parts are not always interchangeable.
  • Confirm dimensions, ratings, connection method, polarity, and environmental limits.
MESP8266 (read Best ESP8266 development boards)MODULE1
What's this?Image, role, pros, cons, handling & specifications
Because of this, we are able to figure out the orientation of an object.MODULE LEARNING VIEW

ESP8266 (read Best ESP8266 development boards)

A programmable controller that reads inputs, makes decisions, and drives the project's outputs.

What it does here

It is the control centre and must use the documented board, pin map, supply, and logic level.

Buy / compare this part

Advantages

  • Reprogrammable and reusable
  • Large learning ecosystem
  • Complex behaviour remains changeable

Limitations

  • GPIO voltage and current are limited
  • Some pins affect boot or communication
  • Loads normally need a driver

Handling

  • Disconnect power before rewiring
  • Avoid static discharge
  • Never power motors, relays, or pumps directly from GPIO

Specifications to verify

  • Use the exact model, value, package, and rating listed for ESP8266 (read Best ESP8266 development boards); similar-looking parts are not always interchangeable.
  • Confirm operating voltage, logic level, pinout, memory, USB interface, and maximum GPIO current.
MESP8266 NodeMCU Schematic Diagram, Including MPU-6050 andMODULE1
What's this?Image, role, pros, cons, handling & specifications
NodeMCU ESP8266 development boardMODULE LEARNING VIEW

ESP8266 NodeMCU Schematic Diagram, Including MPU-6050 and

A programmable controller that reads inputs, makes decisions, and drives the project's outputs.

What it does here

It is the control centre and must use the documented board, pin map, supply, and logic level.

Buy / compare this part

Advantages

  • Reprogrammable and reusable
  • Large learning ecosystem
  • Complex behaviour remains changeable

Limitations

  • GPIO voltage and current are limited
  • Some pins affect boot or communication
  • Loads normally need a driver

Handling

  • Disconnect power before rewiring
  • Avoid static discharge
  • Never power motors, relays, or pumps directly from GPIO

Specifications to verify

  • Use the exact model, value, package, and rating listed for ESP8266 NodeMCU Schematic Diagram, Including MPU-6050 and; similar-looking parts are not always interchangeable.
  • Confirm operating voltage, logic level, pinout, memory, USB interface, and maximum GPIO current.
MOLED DisplayMODULE1
What's this?Image, role, pros, cons, handling & specifications
Because of this, we are able to figure out the orientation of an object.MODULE LEARNING VIEW

OLED Display

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for OLED Display; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
MAdafruit SSD1306 library is properly installed. The Arduino LibraryMODULE1
What's this?Image, role, pros, cons, handling & specifications
Because of this, we are able to figure out the orientation of an object.MODULE LEARNING VIEW

Adafruit SSD1306 library is properly installed. The Arduino Library

A programmable controller that reads inputs, makes decisions, and drives the project's outputs.

What it does here

It is the control centre and must use the documented board, pin map, supply, and logic level.

Buy / compare this part

Advantages

  • Reprogrammable and reusable
  • Large learning ecosystem
  • Complex behaviour remains changeable

Limitations

  • GPIO voltage and current are limited
  • Some pins affect boot or communication
  • Loads normally need a driver

Handling

  • Disconnect power before rewiring
  • Avoid static discharge
  • Never power motors, relays, or pumps directly from GPIO

Specifications to verify

  • Use the exact model, value, package, and rating listed for Adafruit SSD1306 library is properly installed. The Arduino Library; similar-looking parts are not always interchangeable.
  • Confirm operating voltage, logic level, pinout, memory, USB interface, and maximum GPIO current.
MMPU6050 - motion sensor moduleMODULE1
What's this?Image, role, pros, cons, handling & specifications
Because of this, we are able to figure out the orientation of an object.MODULE LEARNING VIEW

MPU6050 - motion sensor module

A sensor converts a physical condition into an electrical signal the circuit can measure.

What it does here

It provides project input as an analogue, digital, resistive, frequency, or calibrated signal.

Buy / compare this part

Advantages

  • Adds real-world awareness
  • Can usually be tested independently
  • Often supports calibration

Limitations

  • Readings can drift
  • Placement affects results
  • Some sensors need warm-up or calibration

Handling

  • Protect the sensing surface
  • Observe supply voltage and polarity
  • Keep signal leads away from noisy power wiring

Specifications to verify

  • Use the exact model, value, package, and rating listed for MPU6050 - motion sensor module; similar-looking parts are not always interchangeable.
  • Confirm supply range, output type, measurement range, accuracy, response time, and pin order.
Ready to continue?
STEP 4 / 6 · Source code

Prepare, upload, and verify the program.

Follow the same software sequence every time: verify connections, prepare the toolchain, compile, and upload.

01

How to connect

  1. Match every controller label to the circuit view and source pin map.
  2. Join grounds before signal wires when separate low-voltage supplies are used.
  3. Keep motors, relays, pumps, and other loads on a suitable driver and external supply.

Common mistakes

Reversed VCC/GND, board-label versus GPIO-number confusion, missing common ground, and charge-only USB cables.

Troubleshoot

Disconnect loads, continuity-test one path at a time, then test with a current limit.

02

Software preparation

  1. Install the current Arduino IDE or the software named in the guide.
  2. Install the correct board package and required libraries.
  3. Select the exact board, processor, and serial port.
  4. Compile once before connecting external loads.
03

How to upload code

  1. Connect the board with a data-capable USB cable.
  2. Open the documented sketch and confirm configuration values.
  3. Compile, fix the first reported error, and upload.
  4. Test with external loads disconnected first.

Common mistakes

Wrong port, missing library, incorrect board selection, boot pins held in the wrong state, or a busy serial port.

Code
This sensor is demonstrated in a number of different ways within the
Adafruit library. In this part of the tutorial, we are going to look at
the fundamental example that prints the readings from the sensors in
the Serial Monitor.
Navigate to the basic readings folder by going to File > Examples >
Adafruit MPU6050. It is expected that the following code will load.
It obtains the temperature as well as the angular velocity (gyroscope)
on the x, y, and z axes, as well as the acceleration on the x, y, and z
axes.
Ready to continue?
STEP 5 / 6 · Build

Assemble, deploy, test, and troubleshoot.

Use the complete source notes in build order, then pass the final checks before calling the project finished.

ASSEMBLY

Build in functional stages

  • Power and regulation
  • Controller or processing stage
  • Inputs and sensors
  • Outputs and loads
  • Enclosure and strain relief
TEST

Power up safely

  • Inspect unpowered continuity first
  • Apply the lowest safe current limit
  • Measure supply rails before signals
  • Add one load at a time
  • Record expected and actual results
TROUBLESHOOT

Work from simple to complex

  • Confirm power, ground, polarity, and orientation
  • Compare each pin with the source
  • Test inputs separately from outputs
  • Replace only one variable at a time
  • Power off before every correction
PROJECT-SPECIFIC BUILD NOTES

Follow the documented instructions.

These notes come from this project's source and remain in their original order.

01

Project overview

Project build note

422.ESP8266 NodeMCU Integrated with MPU-6050 Accelerometer, Gyroscope, and Temperature Sensor (Arduino) Through the completion of this project, you will acquire the knowledge necessary to interface the ESP8266 NodeMCU with the MPU-6050 accelerometer and gyroscope module. The MPU-6050 Inertial Measurement

Unit (IMU) is a sensor that contains a 3-axis accelerometer as well as a 3- axis gyroscope. Both the accelerometer and the gyroscope measure the rotational velocity of the object. The accelerometer measures the acceleration due to gravity. In addition to that, this module is also capable of measuring temperature. This sensor works wonderfully for determining the orientation of an object that is in motion. The MPU-6050 is a module that contains a three-axis accelerometer as well as a three-axis gyroscope. The rotational velocity (in radians per second) along the X, Y, and Z axes is what the gyroscope measures. This can be thought of as the change in angular position over time (roll, pitch and yaw). Because of this, we are able to figure out the orientation of an object. Acceleration, or the rate at which the object's velocity is changing, is what the accelerometer measures. It is able to detect dynamic forces such as vibrations or movement in addition to static forces such as gravity (9.8m/s2). Acceleration along the X, Y, and Z axes can be measured with the MPU- 6050. In a perfect world, the acceleration along the Z axis of a static object

should be the same as the gravitational force, while the acceleration along the X and Y axes should be zero. Calculating the roll and pitch angles using trigonometry is possible if the values from the accelerometer are used. The yaw, on the other hand, cannot be determined by calculation. Installing Libraries Readings can be obtained from the sensor in a variety of different ways. We'll be utilizing the Adafruit MPU6050 library throughout this tutorial. In addition, the Adafruit Unified Sensor library and the Adafruit Bus IO Library need to be installed on your computer before you can use this library. Launch the Arduino Integrated Development Environment (IDE), then navigate to Sketch > Include Library > Manage Libraries . It ought to start up the Library Manager. Install the library by entering "adafruit mpu6050" into the search box on your computer. The next step is to conduct a search for "Adafruit Unified Sensor." To locate the library and to install it, scroll all the way to the bottom. Finally, look for "Adafruit Bus IO" in the search engine, and then install it. Readings Obtained From the MPU-6050 Sensors, Including Accelerometer, Gyroscope, and Temperature Readings of acceleration (x, y, and z), angular velocity (x, y, and z), and temperature will be discussed in this section so that you can learn how to retrieve them from the MPU-6050 sensor.

Readings from the Accelerometer, Gyroscope, and Temperature Sensors on the MPU-6050 Can Be Obtained Using the Following

02

Demonstration

Project build note

Transfer the code to the ESP8266 board you have. Select the ESP8266 board you are using by going to Tools > Board and making your selection there. To determine which port your board is connected to, navigate to Tools > Port and make your selection there. After that, click the button labelled "Upload."

Launch the Serial Monitor with the baud rate set to 115200, and then press the RST button located on the board. The readings obtained from the sensor will be displayed. You can see the values change in response to the different orientations of the sensor. Calibration of the Sensors In a perfect world, the values of the gyroscope would be zero along all axes when the sensor was in a stationary position. However, this is not the case in our situation. The following gyroscope values are obtained when the sensor

03

is in a stationary position

Project build note

x: 0.06 rad/s y: -0.02 rad/s z: 0.00 rad/s In order to obtain more accurate readings from practical applications, you will need to take into account the error and make the appropriate adjustments to the values in the code.

The same thing occurs with the values of the acceleration. On the other hand, the acceleration along the x and y axes should be closer to zero and the acceleration along the z axis should be closer to the gravitational force (9.8 m/s2). In our situation, the following is an approximation of the values that

04

we obtain when the sensor is not moving

Project build note

x: 0.71 m/s2 y: 0.28 m/s2 z: 9.43 m/s2 Showing readings from the MPU-6050 on the OLED display An example is provided by the Adafruit MPU6050 library that shows the readings from the MPU-6050 gyroscope and accelerometer on an OLED display.

05

The following components are necessary to finish off this example

Project build note

MPU-6050 Accelerometer Gyroscope ESP8266 (read Best ESP8266 development boards) Jumper wires for the 0.96-inch I2C OLED Display SSD1306 on the Breadboard Jumper wires ESP8266 NodeMCU Schematic Diagram, Including MPU-6050 and OLED Display

Connect each of the components using the wiring shown in the schematic diagram below. We are able to connect the OLED display and the MPU- 6050 sensors to the same I2C bus because these two types of components use different I2C addresses (same pins on the ESP8266). Display the MPU-6050 sensor readings on the OLED display with this code. In order to follow along with this example, you will need to ensure that the Adafruit SSD1306 library is properly installed. The Arduino Library Manager allows for the installation of this library on your device. You can get the SSD1306 library from Adafruit by going to Sketch > Library > Manage Libraries , searching for "SSD1306," and then installing it.

Ready to continue?
PROJECT ACHIEVED

You built ESP8266 NodeMCU Integrated with MPU-6050 Accelerometer, Gyroscope, and Temperature Sensor (Arduino).

You followed the full workflow from understanding the mission to testing the finished project. That is a real engineering achievement - well done.

The ESP8266 NodeMCU can be used to get Epoch/Unix Time (Arduino) project thumbnail featuring ESP8266, NodeMCU, NETWORK
NEXT IOT ADVENTURE

The ESP8266 NodeMCU can be used to get Epoch/Unix Time (Arduino)

Ready to reuse what you learned in another project from the same track?

Start this project
Browse all 500 projects