MPU6050 Motion Detection Reset
Posted: Thu Jan 28, 2021 1:20 pm
Hi!
I'm building a dodecahedron time tracker, similar to a TimeFlip.
For this I'm using a Wemos D1 mini running micropython and a GY521/MPU6050.
I've managed to get most of the code working, but now I would like to optimize for battery life by implementing a sleep state and waking by receiving an interrupt from the MPU6050 when it's moved. I have got the motion interrupt to a semi-working state, when I supply power and initialize the motion detection it will react and send an interrupt when I rotate to a new side of the dodecahedron. I got it to latch the interrupt and set it to clear only after reading the interrupt status.
The problem is that I would now like it to take this new side as the side from which when moved should send an interrupt, I can make it so by disconnecting the power and restarting everything, but I can't seam to do it using code.
In the Product Specification, Revision 3.3, there's a diagram that talks about setting up motion detection, I've tried to implement this, which works for the initial orientation. It talks about how the device should be in the expected orientation when the sample is being held, I assume ACCEL_HPF is what is referenced here. But running this setup again on the new side does not seam to set it as the value which it compares against.
So now I wonder if any one has any idea on how I can get it to reset the value that it compares to the threshold, because I tried to reset the ACCEL_HPF by setting it to 0 and then again to 7, that does not seam to help. Tried to reset the whole MPU6050 by setting [0x6B] PWR_MGMT_1, DEVICE_RESET [7] to 1 and the running everything again without success.
The code for the MPU6050 that I have cobbled together from many sources, IMU code, where line 242 is my implementation of the diagram from the product specification.
I'm building a dodecahedron time tracker, similar to a TimeFlip.
For this I'm using a Wemos D1 mini running micropython and a GY521/MPU6050.
I've managed to get most of the code working, but now I would like to optimize for battery life by implementing a sleep state and waking by receiving an interrupt from the MPU6050 when it's moved. I have got the motion interrupt to a semi-working state, when I supply power and initialize the motion detection it will react and send an interrupt when I rotate to a new side of the dodecahedron. I got it to latch the interrupt and set it to clear only after reading the interrupt status.
The problem is that I would now like it to take this new side as the side from which when moved should send an interrupt, I can make it so by disconnecting the power and restarting everything, but I can't seam to do it using code.
In the Product Specification, Revision 3.3, there's a diagram that talks about setting up motion detection, I've tried to implement this, which works for the initial orientation. It talks about how the device should be in the expected orientation when the sample is being held, I assume ACCEL_HPF is what is referenced here. But running this setup again on the new side does not seam to set it as the value which it compares against.
So now I wonder if any one has any idea on how I can get it to reset the value that it compares to the threshold, because I tried to reset the ACCEL_HPF by setting it to 0 and then again to 7, that does not seam to help. Tried to reset the whole MPU6050 by setting [0x6B] PWR_MGMT_1, DEVICE_RESET [7] to 1 and the running everything again without success.
The code for the MPU6050 that I have cobbled together from many sources, IMU code, where line 242 is my implementation of the diagram from the product specification.