Configure Microcontroller Using Mpu6050 and Mcu ESP8266 (V 0.9)
Configure Microcontroller Using Mpu6050 and Mcu ESP8266 (V 0.9)
Configure Microcontroller Using Mpu6050 and Mcu ESP8266 (V 0.9)
MICROCONTROLLER
USING MPU6050 AND MCU
ESP8266 (V 0.9)
Group Assignment 1
Internet of Things
Team 4
Team 4
2|I n t e r e t o f T h i n g s – M P U 6 0 5 0
1. Preparation
This step provides all the needed materials in the form of software and hardware.
1.1. Hardware
No Device Name Qty Description
1 MCU ESP8266 1 There are some version about this device, make sure we now
the exact version to decide the driver software that we need to
install and it decide the board type to be used.
2 Breadboard 1 Its an optional item, because we can replace it functionality
using jumper cable (female to female).
3 Data Cable 1 It has to be a data cable, not the charging only cable.
4 MPU6050 1 It’s an accelerometer, gyroscope, and thermometer sensor.
There are some type about this sensor device, we can choose
any type but we have to know the other tools we need for each
type.
5 Jumper Cables 4 It’s an optional item. There are 3 type of the jumper cable : male
to male, female to female, and male to female. On my case, I
use the male to male cable.
1.2. Software
No Device Name Description
1 Arduino IDE Main software that we need to make a
program/code to be uploaded into the
microcontroller
2 Adafruit Library A software library containing constructing
method that can be use to gather information from
the sensor device (MPU6050).
3 MCU Port Driver Driver that used to make the MCU port got
acknowledge by the operating system.
3|I n t e r e t o f T h i n g s – M P U 6 0 5 0
2. Configuration
This step provides a thorough step-by-step process of integrating the software and the hardware.
2.1. Hardware Configuration
a. Plug the MCU ESP8266 into the breadboard.
4|I n t e r e t o f T h i n g s – M P U 6 0 5 0
MCU ESP 8266 MPU6050 Pins
Pins
D1 → SCL
D2 → SDA
3V3 → VCC
GND → GND
5|I n t e r e t o f T h i n g s – M P U 6 0 5 0
2.2. Software Configuration
a. Open Arduino IDE on computer
b. Create new sketch
c. Write the following code on the sketch we create earlier. These code MPU6050 library
by AdaFruit.
6|I n t e r e t o f T h i n g s – M P U 6 0 5 0
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
void setup(void) {
Serial.begin(9600); //Setup baudrate on 9600
// while (!Serial)
delay(3000); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("==============================================");
Serial.println("Start of initialization step");
// Try to initialize!
if (!mpuObj.begin()) { //Start mpuObj by running method begin, and check if it failed or succeed
Serial.println("Failed to find MPU6050 chip"); //Print information about the connecting process to MPU6050 device
is failed
}else{
Serial.println("MPU6050 Found!"); //Print information about the connecting process to MPU6050 device is succeed
}
7|I n t e r e t o f T h i n g s – M P U 6 0 5 0
void loop() {
Serial.println("--------------------------------------------------------------");
delay(2000);
}
8|I n t e r e t o f T h i n g s – M P U 6 0 5 0
3. Deploy & Test
Now that both hardware & program code is ready. The next step is to upload the program code
into the microcontroller.
a. Open the Serial Monitor and choose the correct baudrate (9600)
b. Choose the correct board type and the port used to be identified by the computer.
c. Open the sketch that we created earlier.
d. Click Deploy button on the top left window.
e. Wait for the uploading process.
f. See the log on the serial monitor. The data gathered are:
• Rotation in x, y and z axes
• Acceleration in x, y and z aces
• Temperature
9|I n t e r e t o f T h i n g s – M P U 6 0 5 0
4. Notes & Summary
As the result that shown on the Image of step 3. It gave the information about the gyro value,
accelerometer value, and temperature value. The code use on this report is still a simple code, it
can be developed for more complex logic like sending it to API in cloud and save it into database.
Or we can also make the circuit to be more complex by add others sensor device.
10 | I n t e r e t o f T h i n g s – M P U 6 0 5 0