MPU9250 Readings Erratic When Device is Not Moving

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
spreadsomejelly
Posts: 1
Joined: Wed Apr 01, 2020 5:41 pm

MPU9250 Readings Erratic When Device is Not Moving

Post by spreadsomejelly » Wed Apr 01, 2020 8:58 pm

I have done everything I could think to do to try to troubleshoot/diagnose this issue on my own, and I am humbly asking for some help from the MicroPython community.

(I've attached an image below with line charts consisting of 60 seconds of data from the MPU9250 below - sampled twice per second)

Data in a CSV file - https://drive.google.com/file/d/1U2Q6j8 ... sp=sharing


Intro: I am running a 30 pin ESP32 DEVKIT with MicroPython Firmware (build 20191130-v1.11-611), and having issues with seemingly erratic sensor readings from a MPU9250/GY9250 using the MPU9250 library from -https://github.com/micropython-IMU/micropython-mpu9x50. Both components are plugged into a breadboard, and remain stationary/not moving on my desk. I am currently powering the ESP32 via micro USB from my computer, and powering the MPU9250 from one of the 3.3V outputs from the ESP32 (measuring 3.279-3.283V at the MPU9250 with my multimeter).

Things I've tried

1.) I have tried to power the MPU9250 directly from a 5V LiPo battery (keeping the ESP32 powered from micro usb), and the readings were just as irregular.

2.) I am using hardware I2C, and have tried the default SCL and SDA pins (22 and 21 respectively), and other GPIO pins, however no dice.

3.) I have also tried another MPU9250 with another ESP32, same problem

4.) I have tried the MicroPython MPU9250 library from- https://github.com/tuupola/micropython-mpu9250 MPU9250, slightly different readings, still erratic

I have not calibrated the magnetometer yet, since I wanted to figure out why the readings are not stable/static. I just wonder if I am missing something (i.e. ESP32 or MPU9250's are known to have this problem, etc.)? On a somewhat related note, I have tried using a BMP180 with several different MicroPython libraries for the ESP32, and even on (gasp) an Arduino, and it seemed to have fairly inconsistent readings as well (even though the sensor was stationary).

Some other variables possibly worth mentioning;
I have a ceiling fan running in my office, I have wifi running on ESP32 (STA_IF), I have cats, and I like Cocoa Pebbles?!? :?


Image

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: MPU9250 Readings Erratic When Device is Not Moving

Post by tve » Thu Apr 02, 2020 1:10 am

What are the vertical axis units? Looks to me like there's a bit of noise, that's all, probably within the expected spec of the device. You have accel Z at -1 gravity, so that's good, accel Y has <0.01g of noise, is that out of spec? accel X is hard to tell 'cause you have that spike, probably bumped against the table :-). Seems to be working, congrats!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: MPU9250 Readings Erratic When Device is Not Moving

Post by jimmo » Thu Apr 02, 2020 2:21 am

To echo TvE's comment -- it would be good to know what you expect to see.... it doesn't seem that bad?

Some quick thoughts though:
- Have you tried experimenting with the sensitivity scale factor (which I think that first library calls gyro_range, accel_range, etc in imu.py).
- This chip has a whole raft of sensor fusion / "Digital Motion Processor" functionality. It's not clear how much of that these libraries enable.
- Kalman filter!!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MPU9250 Readings Erratic When Device is Not Moving

Post by pythoncoder » Thu Apr 02, 2020 6:57 am

jimmo wrote:
Thu Apr 02, 2020 2:21 am
...
- This chip has a whole raft of sensor fusion / "Digital Motion Processor" functionality. It's not clear how much of that these libraries enable.
- Kalman filter!!
As the author of the library it doesn't use the DMP because this is undocumented. I guess the details are only available to OEM's. I therefore ported a Madgwick sensor fusion library to MicroPython which may be found here.

The other approach to sensor fusion is to use the BNO055 which has hardware sensor fusion. An amazing IMU.

@spreadsomejelly You will find that the magnetometer is quite a tricky beast if you're using it as a compass or for sensor fusion. The Earth's magnetic field is small. The magnetometer definitely requires calibration as described in the library docs to get sensible results from fusion.
Peter Hinch
Index to my micropython libraries.

007
Posts: 1
Joined: Wed Apr 28, 2021 12:03 am

Re: MPU9250 Readings Erratic When Device is Not Moving

Post by 007 » Wed Jul 28, 2021 9:04 pm

Nice line chart !! thanks for the post, I am using a smartwatch that supports micropython however I am not sure how to go about creating
the linechart of the heart rate on the smartwatch display Any idea of how this can be achieve.

Code: Select all

Background Information: 
[/b]
Watch runs on a System on a Chip microcontroller (SoC) and these are so tiny that even though one can create lot of applications, including watch faces, weather, games etc. The SoC cannot be tax when it comes to processing power as they are tiny. So by default I can create the line chart using matplotlib library the smart watch matplotlib for micropython is not included in the file systems, SO Drawing on the small tiny touch screen display must be done using draw library https://wasp-os.readthedocs.io/en/lates ... ml#drawing
At this point I am not even sure if a line chart can be drawn using the draw library Any pointers or help is very much appreciated :)

Post Reply