Reads MPU6050 gyro, accelerometer and temperature via I2C, initializes and returns data on-demand to EZ-Script variables using ControlCommand RunOnce
How to add the MPU6050 Accelerometer Gyro Temperature robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the I2C category tab.
- Press the MPU6050 Accelerometer Gyro Temperature icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the MPU6050 Accelerometer Gyro Temperature robot skill.
How to use the MPU6050 Accelerometer Gyro Temperature robot skill
- Accelerometer (detects movement/tilt by measuring acceleration)
- Gyroscope (detects rotation rate)
- Temperature sensor (reports the chip’s temperature)
Before You Start (Beginner Checklist)
-
Hardware connected: Plug the MPU6050 EZ-Bit into the EZ-B’s I2C port.
Important: I2C devices require the correct wiring. If the sensor is not connected properly (or not connected at all), the EZ-B v4 can lock up when a read is attempted.
- Add the skill to your ARC project: Add the MPU6050 control/skill to the ARC workspace.
- Have a way to run a script: Add an EZ-Script control where you will place the example code below.
Key Concept: INIT First, Then Read On Demand
This skill does not continuously read the sensor automatically. You must:
- Run
Initonce to initialize the MPU6050. - Run
RunOnceeach time you want fresh sensor values.
Init, the MPU6050 will not return data.
If you call RunOnce repeatedly, the variables will be updated each time.
Where the Sensor Data Goes (EZ-Script Variables)
Each time you read the MPU6050, this skill updates a set of EZ-Script Variables. The exact variable names can vary by version/configuration, so the easiest way to see them is:
- Click the Config button on the MPU6050 control.
- Look for the list of variables that the skill updates.
- Use the Variable Watcher to watch those values change live.
Example: Read the MPU6050 Every 100ms (10 Times/Second)
The script below initializes the sensor once, then loops forever. Every loop it:
- Requests a new reading from the MPU6050 using
RunOnce - Waits
100milliseconds - Repeats
ControlCommand("MPU6050", Init)
:loop
ControlCommand("MPU6050", RunOnce)
Sleep(100)
Goto(loop)
Sleep(250)).
If you want faster updates, decrease it (example: Sleep(50)). Very fast loops can overwhelm your project if you don’t need them.
Troubleshooting
- EZ-B v4 locks up when running the script: This usually means the MPU6050 is not connected correctly, not powered, or not on I2C. Disconnect power, check the I2C connection, then try again.
-
Variables are not changing: Make sure you ran
Initfirst, and that the loop is callingRunOnce. Also confirm you’re watching the correct variables in the Variable Watcher. - Data looks “noisy” or jumpy: That is common with IMU sensors. Consider averaging values in your script or reading at a steadier rate.
Example Project (Video Mention)
A working example is shown in the video using the JD project with the MPU sensor. You can find it in the EZ-Cloud as: JD With MPU6050 Accelerometer.
How It Works (Learn More)
Want to understand IMU sensors (accelerometer + gyro) in more detail? This is an excellent beginner-friendly article: https://www.starlino.com/imu_guide.html

@smiller29
Not sure what .stl files you are asking about but here are the ones I know about.
---Link---
Herr Ball, Thanks for the link I found what I needed on this site thanks to you. I did not think to look here for those files. I could not find these items on the EZ Robot website.
Looks like we'll need to update our site to have more STL files.
Besides Thingiverse, I forgot that the files were still hosted here and I also forgot that you can get some of the STLs from within the ARC Robot design skill and in the build instructions.
Several of my EZ-Robots are either in part or fully 3D printed. I purchased a stack of the development kits a while ago for parts and 3D print the other pieces. When you have a bunch of kids building robots they will break things.
This is probably the best way to go to market. No one can afford $1000 for a robot but a handful of servos, a microcontroller and the 3D printer at school or library and you have a fully functional robot.
DJ, above it says "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." I would love to see the code you created for this can you provide a link to it, because I am not sure where to find EZ-Cloud?
You can find the EZ-Cloud in ARC. Look at the top menu bar on the main screen and you will see it right in the center. Once you get there there will be several ways to look at what's available. On the left menu there is a drop down menu showing everyone who has uploaded a project. Scroll down and find DJ's name and click on it. Depending what you have checked in the search box above there depends on what is returned in the right window. Good luck. It gets some getting used to and experimentation to find what you what.
Thanks Dave I was looking for it on the website. Then I thought it may of been on the EZ Robot website but I could not find it there also. Did not think to check ARC:(
I'm glad I was able to help. There's a ton of good examples and projects to download and look through. Doing this really helped me learn how ARC works and gave me ideas on how to write scripts and set up my project. Have fun!!