Hi all,
First post here so I hope I get the posting protocols right.
I am using an Arduino Uno, and an MPU9250 sensor with the idea to use them as a security system for a caravan. If any motion is detected, flash the lights, sound the siren, lock on the electric brakes etc.
I've downloaded the SparkFun MPU9250 library and with a bit of minor editing (addresses mainly) I've got meaningful output from the sensor and it sends it neatly to the serial monitor in the IDE. All good so far.
What I have noticed is that under normal operation (initialising the sensors, self testing, calibrating, and then data points being displayed on the serial monitor) I get what I would consider wildly eratic data. Even to the point where the "roll" data indicates that the sensor is being turned upside down and back again at random.
I should mention that the arduino and sensor are sitting stationary on my desk so there is no way it is flip flopping around as the data would suggest.
Interestingly, if I exclude the Magnetometer calibration from the code by commenting out the call to that library function, the data becomes a lot more stable.
Whilst I've looked at the yaw, pitch and roll numbers, I've also isolated the Quaternion data and had a good look at it. Same deal ... when the magnetometer calibration is used, the data fluctuates wildly ... otherwise it's not too bad.
I've cut and pasted some of the data into a spreadsheet and had a look at using a moving average system to smooth out the variations, but I was quite surprised at how far some of the outliers strayed from the average (again, the UNO and sensor are sitting quietly on my desk). I do plan on introducing a "noise" threshold so that I can eliminate false triggers but you also need to be mindful that the system is not too desensitised.
Has anyone out there experienced the same sort of data fluctations and overcome them?
As you can probably appreciate, for a security system, the sensors need to be fairly sensitive, but hopefully also not experience a wide range of variation ... otherwise the system will be subject to false positives ... that would be very bad!
I've attached a capture of the serial monitor output and ...
I tried to include the code but I've exceeded the 9000 character limit.
I hope someone has already experienced this and has a quick fix.
Thanks
Luke
