I2C - MPU6050 Accelerometer Gyro Temperature

How To Add This Control To Your Project

Step #1) Load the most recent release of EZ-Builder
Step #2) Press the Project tab from the top menu bar of EZ-Builder
Step #3) Press Add Control from the button ribbon bar of EZ-Builder
Step #4) Choose the I2C category tab
Step #5) Press the MPU6050 Accelerometer Gyro Temperature icon to add the control to your project


Description

The MPU6050 EZ-Bit module is an all-in-one Gyro/Accelerometer/Temperature sensor over an i2c connection. This EZ-Builder control will read data from the sensor and set EZ-Script Variables, respectively. The control will require an Initialization (INIT) before the sensor will return data. If the sensor is not connected, the EZ-B v4 will lock up. This control will not read data automatically. We have provided a ControlCommand() for querying the device and setting the variables. Each time you wish to receive data from the MPU6050, you must ask the control to RUN ONCE with ControlCommand().

Here is an example code for looping every 100 milliseconds to request data from the MPU6050. The data from the MPU6050 will be stored in EZ-Script Variables. You may press the CONFIG button on the control to see what variables are being set with data. Ensure you have an MPU6050 EZ-Builder control added, an MPU6050 connected to the i2c of the EZ-B, and paste this code into an EZ-Script control. When this script is running, the MPU6050 will continually update the specified variables with data every 100ms... Check the Variable Watcher to view the data from the sensor.

ControlCommand("MPU6050", Init)

:loop

ControlCommand("MPU6050", RunOnce)
  
sleep(100)

goto(loop)


In this video below, I am using the JD project with MPU. The project can be found on the EZ-Cloud as JD With MPU6050 Accelerometer.

How It Works

Interested in how the IMU Sensor works? Find out by reading this fantastic article HERE.


Video

Related Articles: N/A