Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » ESP8266 & MPU6050 Tilt Angle Monitor on IoT Blynk
ESP8266 Projects IoT Projects

ESP8266 & MPU6050 Tilt Angle Monitor on IoT Blynk

Mamtaz AlamBy Mamtaz AlamUpdated:August 21, 20223 Comments5 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
ESP8266 MPU6050
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

We will interface MPU6050 Gyro/Accelerometer Sensor with NodeMCU ESP8266 & measure tilt angle. The measured till angle is monitored on Blynk using IoT Cloud.


Overview

In this post we will learn how to Measure Tilt Angle using MPU6050 & NodeMCU ESP8266. This can be done by simply interfacing MPU6050 6 axis Gyro/Accelerometer Sensor with ESP8266. The Accelerometer sends X, Y, and Z acceleration forces. We need to convert the forces into X, Y, Z 3D angle to determine the 3D Orientation of the sensor. The measured tilt angle is sent to the Blynk Application using the Blynk cloud. Hence the tilting position can be monitored over IoT.

The gyroscope measures rotational velocity or rate of change of the angular position over time, along the X, Y and Z-axis. It uses MEMS technology and the Coriolis Effect for measuring. The outputs of the gyroscope are in degrees per second, so in order to get the angular position, we just need to integrate the angular velocity.

You can refer to the previous post where we measured tilt angle using MPU6050 Gyro/Accelerometer & Arduino: Measure Tilt Angle Using MPU6050. Apart from this the MPU6050 can also be used to measure and control speed of DC Motor.



Components Required

Following are the components required for making this project. All the components can be easily purchased from Amazon. The component purchased link is added.

S.N.Components QuantityPurchase Links
1Nodemcu ESP8266 Board1Amazon | AliExpress
2MPU60501Amazon | AliExpress
3OLED Display1Amazon | AliExpress
4Connecting Wires10Amazon | AliExpress
5Breadboard1Amazon | AliExpress

MPU6050 Gyro/Accelerometer Sensor

Introduction:

MPU6050 Gyro/Accelerometer

The InvenSense MPU-6050 sensor contains a MEMS accelerometer and a MEMS gyro in a single chip. It is very accurate, as it contains 16-bits analog to digital conversion hardware for each channel. Therefor it captures the x, y, and z channel at the same time. The sensor uses the I2C-bus to interface with the Arduino.

The MPU-6050 is not expensive, especially given the fact that it combines both an accelerometer and a gyro.

MPU6050 Pinout:

The MPU-6050 module has 8 pins:
INT: Interrupt digital output pin.
AD0: I2C Slave Address LSB pin. This is 0th bit in 7-bit slave address of device. If connected to VCC then it is read as logic one and slave address changes.
XCL: Auxiliary Serial Clock pin. This pin is used to connect other I2C interface enabled sensors SCL pin to MPU-6050.
XDA: Auxiliary Serial Data pin. This pin is used to connect other I2C interface enabled sensors SDA pin to MPU-6050.
SCL: Serial Clock pin. Connect this pin to microcontrollers SCL pin.
SDA: Serial Data pin. Connect this pin to microcontrollers SDA pin.
GND: Ground pin. Connect this pin to ground connection.
VCC: Power supply pin. Connect this pin to +5V DC supply.



3-Axis Gyroscope:

The MPU6050 consist of 3-axis Gyroscope with Micro Electro Mechanical System(MEMS) technology. It is used to detect rotational velocity along the X, Y, Z axes as shown in below figure.
3-Axis Gyroscope

3-Axis Accelerometer:

The MPU6050 consist 3-axis Accelerometer with Micro Electro Mechanical (MEMs) technology. It used to detect angle of tilt or inclination along the X, Y and Z axes as shown in below figure.
3-Axis Accelerometer


Circuit: ESP8266 & MPU6050 Tilt Angle Monitor on IoT Blynk

Here is the circuit diagram for interfacing MPU6050 Gyro/Accelerometer with NodeMCU ESP8266. The circuit can be assembled on breadboard.

MPU6050 ESP8266 Circuit

Both the MPU6050 & OLED display are I2C Module. So we need only 2 wires for interfacing them with NodeCMU. The SDA pins of both modules are connected to D2 of NodeMCU ESP8266 & SCL to D1. Supply 3.3V power to both modules.

gyro accelerometer nodemcu


Setting Up Blynk IoT Application for Remote Weight Monitoring

Blynk is an application that runs over Android and IOS devices to control any IoT based application using Smartphones. It allows you to create your Graphical user interface for IoT application. Here we will set up the Blynk application to monitor MPU6050 Angles over Wi-Fi using NodeMCU ESP8266.



So download and install the Blynk Application from Google Play store. IOS users can download from the App Store. Once the installation is completed, open the app & sign-up using your Email id and Password.

Blynk ESP8266

Now follow the photos below to set up the complete Blynk application.

Blynk Setup

So create gauge and value display. After the successful creation of the Project, go back to setting and click on Send Email. You will get an Authenticate ID on registered mail. Save the Authenticate ID. You will need to enter this on code.


Source Code/Program

The source code/program for interfacing MPU6050 with ESP8266 on IoT cloud is given below. We will need few libraries to compile the code. So download the libraries from the link below and add it to Arduino Library.

  1. Adafruit_SSD1306 : https://github.com/adafruit/Adafruit_SSD1306
  2. Adafruit_GFX : https://github.com/adafruit/Adafruit-GFX-Library
  3. Blynk ESP8266 Library

Make sure to do the following changes in the code. Change the wifi SSDI & Password. And change the Blynk Authentication Token as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include<Wire.h>
#include <SPI.h>
#define BLYNK_PRINT Serial
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define SCREEN_WIDTH 128  // OLED display width, in pixels
#define SCREEN_HEIGHT 64  // OLED display height, in pixels
#define OLED_RESET    -1  // Reset pin # (or -1 if sharing reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
char auth[] = "vB00BQor2wyZ927WnWe5JoBPgOi-fMQ7";       // You should get Auth Token in the Blynk App.
char ssid[] = "Sri Krishna 3rd.";                       // Your WiFi credentials.
char pass[] = "subbu@123";
 
const int MPU_addr=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
 
int minVal=265;
int maxVal=402;
 
double x;
double y;
double z;
 
void setup(){
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
 
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
}
display.display();
delay(2);
display.clearDisplay();
 
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(0,5);
display.print("MPU Angles");
display.display();
delay(3000);
}
void loop(){
Blynk.run();
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
AcX=Wire.read()<<8|Wire.read();
AcY=Wire.read()<<8|Wire.read();
AcZ=Wire.read()<<8|Wire.read();
int xAng = map(AcX,minVal,maxVal,-90,90);
int yAng = map(AcY,minVal,maxVal,-90,90);
int zAng = map(AcZ,minVal,maxVal,-90,90);
 
x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);
y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI);
z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI);
 
Serial.print("AngleX= ");
Serial.println(x);
 
Serial.print("AngleY= ");
Serial.println(y);
 
Serial.print("AngleZ= ");
Serial.println(z);
Serial.println("-----------------------------------------");
 
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,0);
display.print("X: ");
display.println(x);
 
display.setTextSize(2);
display.setCursor(0,20);
display.print("Y: ");
display.println(y);
 
display.setTextSize(2);
display.setCursor(0,40);
display.print("Z: ");
display.println(z);
display.display();
 
Blynk.virtualWrite(V2, x);
Blynk.virtualWrite(V3, y);
Blynk.virtualWrite(V4, z);
 
delay(1000);
}



Output/Results

So once the code is uploaded, you can click on serial monitor to check the outputs. You need to tilt the MPU6050 Gyro/Accelerometer to detect the angular position of X, Y & Z axis. The same tilting angles can be observed on OLED Display as well.

Since MPU6050 ESP8266 is connected to the internet, the ESP8266 will start sending the data to Blynk Application. You can open your serial monitor and check the status as shown below.

Now you can simply see the status on Blynk App as well. The Blynk will start displaying the gauge with changing parameters of X, Y & Z angles.

MPU6050 Blynk

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleESP32 & DS3231 Based Real Time Clock (RTC) on OLED
Next Article Measure Tilt Angle with MPU6050 & STM32 Microcontroller

Related Posts

IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

Updated:February 1, 20261K
View 3 Comments

3 Comments

  1. 1 on February 24, 2020 2:05 PM

    where is the source code to download?

    Reply
  2. Erick on March 26, 2020 2:40 AM

    Hello, how are you? I wonder if you used any library for the MPU6050. Library usually is needed to define its x, y and z axes.

    Reply
  3. Frederick Gear on December 10, 2021 11:48 PM

    is there a way to set 0 deg in this code or in the sensor?

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • IoT Based Electricity Energy Meter using ESP32 & Blynk
    IoT Based Electricity Energy Meter using ESP32 & Blynk
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.