My circuit uses an Arduino Nano which I communicate via Α4 and A5 via I2C. There are several BMP280, HMC5883 and MPU6050 sensors on the I2C line. While I was dealing with these other two sensors, my MPU6050 stopped working. She started outputting single zeroes regardless of the movements. I found similar problems and it was suggested to conduct a search and if it is searched to try some other code.I tried and nothing helped. They also wrote about power supply problems, but the board I use has resistors between the microcircuit and the SCL/CLK terminals. I also heard about FIFO, but did not understand anything. I don't know what I did wrong because before that it was working fine. I will add the code I used.
/*
The contents of this code and instructions are the intellectual property of Carbon Aeronautics.
The text and figures in this code and instructions are licensed under a Creative Commons Attribution - Noncommercial - ShareAlike 4.0 International Public Licence.
This license lets you remix, adapt, and build upon your work non-commercially, as long as you credit Carbon Aeronautics
(but not in any way that suggests that we endorse you or your use of the work) and license your new creations under the identical terms.
This code and instruction is provided "As Is" without any further warranty. Neither Carbon Aeronautics or the author has any liability to any person or entity
with respect to any loss or damage caused or declared to be caused directly or indirectly by the instructions contained in this code or by
the software and hardware described in it. As Carbon Aeronautics has no control over the use, setup, assembly, modification or misuse of the hardware,
software and information described in this manual, no liability shall be assumed nor accepted for any resulting damage or injury.
By the act of copying, use, setup or assembly, the user accepts all resulting liability.
1.0 5 October 2022 - initial release
*/
#include <Wire.h>
float RateRoll, RatePitch, RateYaw;
void gyro_signals(void) {
Wire.beginTransmission(0x68);
Wire.write(0x1A);
Wire.write(0x05);
Wire.endTransmission();
Wire.beginTransmission(0x68);
Wire.write(0x1B);
Wire.write(0x8);
Wire.endTransmission();
Wire.beginTransmission(0x68);
Wire.write(0x43);
Wire.endTransmission();
Wire.requestFrom(0x68,6);
int16_t GyroX=Wire.read()<<8 | Wire.read();
int16_t GyroY=Wire.read()<<8 | Wire.read();
int16_t GyroZ=Wire.read()<<8 | Wire.read();
RateRoll=(float)GyroX/65.5;
RatePitch=(float)GyroY/65.5;
RateYaw=(float)GyroZ/65.5;
}
void setup() {
Serial.begin(57600);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
Wire.setClock(400000);
Wire.begin();
delay(250);
Wire.beginTransmission(0x68);
Wire.write(0x6B);
Wire.write(0x00);
Wire.endTransmission();
}
void loop() {
gyro_signals();
Serial.print("Roll rate [°/s]= ");
Serial.print(RateRoll);
Serial.print(" Pitch Rate [°/s]= ");
Serial.print(RatePitch);
Serial.print(" Yaw Rate [°/s]= ");
Serial.println(RateYaw);
delay(50);
}
enter image description here enter image description here
here is what it outputs now ("0"), although before it was perfectly responsive. At least it accurately displayed the + or - sign along with some values
The type of MPU6050 I used:enter image description here
-
1Can you restore the circuit and code to the previous state so the MPU6050 once again works? Have you considered I2C address conflicts between the various modules? Each module may have its own I2C pullup resistors and too many of these in parallel may be a problem.6v6gt– 6v6gt06/04/2023 03:43:44Commented Jun 4, 2023 at 3:43
-
1please do not post pictures of text ... post the text insteadjsotola– jsotola06/04/2023 04:03:05Commented Jun 4, 2023 at 4:03
-
I am responding to 6v6gt's comment. My circuit didn't change, I had all three sensors connected from the start. However, I just disconnected the BMP280 and HMC5883 from the I2C, leaving only the MPU6050 connected. It will continue to show only zeros.Roman– Roman06/04/2023 11:49:11Commented Jun 4, 2023 at 11:49
-
It sounds like something is broken. Assuming the MPU6050 accelerometer / gyroscope worked with the Arduino. Then, after adding the BMP208 pressure sensor and the HMC5883 magnetometer the MPU6050 stopped working. Finally, after physically removing the BMP208 and HMC5883 from the I2C bus AND REVERTING TO THE VERSION OF CODE which worked with the MPU6050 the MPU6050 continued to not work. Please read that carefully and confirm you did physically remove the 2 new sensors from the I2C but and you did revert back to the code which worked with the MPU6050.st2000– st200006/04/2023 13:16:09Commented Jun 4, 2023 at 13:16
-
I am responding to st2000's comment. Just picked up and connected the MPU6050 to another arduino Nano that has nothing else connected except this MPU6050. It shows zeros again. But I want to note that if you choose the wrong address (that is, not 0x68 or simply do not connect), then -0.02 is displayed instead of zero.Roman– Roman06/04/2023 13:35:32Commented Jun 4, 2023 at 13:35