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

What size? The short and easy answer is that you want a resistor value on the order of 10k for the pull-up. A low resistor value is called a strong pull-up (more current flows), a high resistor value is called a weak pull-up (less current flows). You may have to play around with different values to get it right. I've always ended up using 10k though.
I think he's saying any length of wire you have attached to the unit. It's been my experience that if it's not listed on their website that they have discontinued or stopped selling the part. These boards sell dirt cheap on Amazon. You could probably buy a couple different brands and try them out. Return the ones that don't work or keep a back up.Have FUN!!! It sounds like you are elbow deep in something very interesting.
@Dave, Well I am trying to get into something interesting but the skill for the MPU6050 running on a EZB Arduino UNO firmware does not work or at least I can't get it to work for me. Jeremie made I comment in that post I may want to use a EZB4 in my project so then I looked at this skill and the part they show being used with it is no longer for sale by EZ-Robot so this skill has not been updated with more current information. I am working on trying to build a 4 foot tall walking robot and I wanted to try and use the Auto Position skill in ARC but I also need to be able to leverage a MPU 6050 in ARC also.
On the distance question above: the wire run would be about 15" tops.
It would be nice to know how this works in more detail but I guess it is another trial and error type of exercise.
I understand, trial and error is my middle name. Lol. Good luck I hope you find your results.Usually I have to try different things in different combinations before I am happy. Do you have an ezb You can start out with. Maybe you get it to work on that first?
Yep I do. I need to strip it from another project to try it and see if I can make it work.
Hello @smiller29
This board above was prototyped but never sold. I believe I had to use pull-ups as strong as 330ohms on the SDA and SCL lines. You can use off the shelf MPU-6050s but you may have to replace the pull-ups that the board comes with.
Jeremie not sure what to parts to replace on a standard MPU 6050. Do you have a picture of what components on the board needs to be replaced.
You’ll have to trace back the resistors that are connected to the SDA and SCL lines. It looks like they are the 2.2kohm (222) resistors in this case but you’ll need a ohmmeter to confirm.
Thanks guy but at my age I am not sure I can change those out LOL! Eyes and hands not as good they’d use to be.
So now I am really thinking I am screwed. Leaving me my only option doing it all with arduino’s and custom arduino code and not using ARC. This was not my plan but it sounds like it is my only option.