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
The MPU6050 EZ-Bit module is an all-in-one Gyro/Accelerometer/Temperature sensor over an i2c connection. This ARC 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 ARC control added and an MPU6050 connected to the i2c of the EZ-B, and paste this code into an EZ-Script control. When this script runs, 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.
Code:
I have used this to help adjust the MPU in Arduino code using the MPU6050_6Axis_MotionApps20.h lib.
This would allow you to zero/calibrate the gyro. That has been used within your project as every MPU6050 is not the same.
For example, if you have a variable $AccelX, you can add to it by doing this.
$AccelX = $AccelX + 2
That will add the value of 2 to the previous value in the variable.
You’re always welcome to post code and pictures if you’d like.
When using DIY electronic modules with I2C sometimes some tinkering around needs to be done.
I really don't have a good idea of what your setup looks like. Are your I2C wires long? Which MPU-6050 module are you using? Have you tried changing the pullup resistors to a different value? Is there an LED on the MPU6050 module that tells you the 3.3V power is reaching the module? Are you powering the module with 3.3V before or after the voltage regulator?
I would try the following: shorten the wires, check your supply voltage to the module, and if all looks good then try bringing the pull-ups down to the next standard resistor value (likely 220 ohm).
The sda pins on the ezb4 and the MPU connected together and the same goes for the scl pins.
Is there anything else I can provide for you.
In the skill it shows the temp but as soon as I click the int button in the skill it normally makes the red LED light up and stays on and the ezb4 disconnects from the network.
1. Your wires may be too long I would look at shortening those.
2. It looks like you used 470ohm resistors in parallel with the onboard pull-ups, I would recommend going lower (220 ohms).
It looks like we have very similar boards. Here's my setup (works solidly):
8 inch cable:
220 ohm Pull-up resistors soldered in place of the original (2.2Kohm resistors) I believe:
Yeah, I also powered it from the EZ-B 3.3V.
I just use the example code from above for testing:
Code:
This is not a plugin robot skill, which means it's part of ARC native. For you to make it a plugin, the code can be copied into the plugin template. You have to change the namespace.
Follow this tutorial to create a robot skill: https://synthiam.com/Support/Create-Robot-Skill/Overview
The following code is from the MPU6050.cs file in the source you sent me. Just as an FYI this skill is not returning the correct temp value. I get a value of like 217c in the skill.
Code:
it appears from reading the code that there is 14 bytes read and they’re split into different variables that have names which explain what they are.