Hi,
I am using the MPU9250 sensor (magnetometer, gyro, and accelerometer) with I2C. I have been having a few on/off problems which I was wondering if anyone would have any ideas on how to correct. The first problem is that the device is only picked up on I2C about half the time. I have to constantly re-download sketches and unplug/re-plug in the arduino to fix this. Could this problem be due to wiring or is there another possible reason? Secondly, my magnetometer only reads reasonable data for the first roughly five loops. After that, it shows only zeros as datapoints. Does anyone have any idea why?
Short wires, but SDA and SCL next to each other in a flat ribbon cable.
Own design pcb board without decoupling capacitors.
Arduino Due.
Counterfeit sensor.
Which Arduino board do you use ?
Can you give a link to the MPU-9250 module that you use ? (preferably a link to where you bought it).
Can you show a photo of the wiring ?
Please put a sketch between code-tags. You get code-tags with the </> button.
Without a a schematic I can only take a SWAG but it has the earmarks of a bad pull up resistor(s) on the I2C. Download one of the many I2C scanners and see if you get consistent results. If not disconnect everything and start with only one I2C device connected. Get it to work properly, validate the resistors, then add the second etc. You should have it up in a few minutes unless you have a faulty component which is not to likely. If the results are consistently good you probably have a software problem. Be sure your power is good, an Arduino is not a power supply.
The wires are not that long and I am using an Arduino/Elegoo Uno- a picture of the wiring is attached (I have VCC directly connected to 5V, GND directly connected to GND, SDA directly connected to A4, and SCL directly connected to SCL).
From looking down your lists, I think my problem is probably pull-up resistors, but I am not quite sure how to integrate them. How would I wire up the circuit with pull-up resistors?
Once again, thank you all so much, and any further help would be greatly appreciated!
The MPU-9250 can be powered by 5V because the module has an on board regulator. However, it is a 3.3V device and the inputs can never be exposed to 5 V.
The best option is to connect the MPU-9250 directly to a 3.3V Arduino.
The second best option is to use a two channel 5V to 3.3V level shifter to connect SDA and SCL to A4 and A5 on a 5V Arduino.
The third best (one that works ONLY with I2C connections) is to use pullup resistors (2.2K to 4.7K) connected from SDA and SCL to 3.3 V.
Hint on posting links: this is all you need.
All the rest is tracking your personal activities.