mp-se / gravitymon

iSpindle replacement firmware for beer brewing/fermenting
MIT License
55 stars 12 forks source link

Discussion about adding new ICM support and FIFO support #195

Open Levi--G opened 6 days ago

Levi--G commented 6 days ago

Hi,

So i wanted to contact you about features i'd like to contribute and maybe discuss this in advance so its clear on how you might want these added. I have quite alot of experience with these IMU's over the years and since i started making my ispindels noticed some improvements that could be made.

First of all i'd like to add support for the ICM-42670-P chip, this is another recent invensense IMU that is very low power and has great accuracy and has some nice features that could really augment my readings while saving power. To do this i suggest I create an interface to abstract the IMU, and change the IMU field to be a pointer assigned on detection. If this is fine with you of course. If you want me to do it in some other way i'm all ears.

For the FIFO i'm surprised it isn't used yet. It would leave the IMU on and collecting data while the main IC sleeps and then when the ESP wakes up all the samples are already there, collected over the entire time it was sleeping thus being more accurate over time and shortening the time the esp is online. I've already ran some tests on this and it seems very promising for this scenario. With MPU6050 i get a very consistent 0.01° accuracy using FIFO. On the MPU6050 however it might use more power than sleeping (i will measure exactly how much soon). But maybe adding it as an alternative option could be beneficial? I can fork/change the code and add the option but i don't know how you make your front-end and might need some help on that side. But first i will do the power/accuracy measurement on both the new and old imu's so you can see the difference.

Regarding the accuracy/power consumption comparison i will do, do i just test the default settings (every 15m push), or is there other data you are interested in to know if you want to add it? Basically how longer the sleep time, the more fifo will use compared to all sleeping, but the larger the accuracy difference as well.

If you don't like these features and rather not have them pulled into the main, i can always maintain my own fork, thats fine for me too. ;)

Thank you for the already amazing project and hope to hear from you soon. Levi

mp-se commented 5 days ago

Hi, Thanks for reaching out. I welcome any improvements for the software. So far I have been focused on supporting the original iSpindel hardware but If there are ways to improve the hardware and improve on battery life lets try it out.

Adding additional gyro hardware is not a big issue, but there should be an easy way for users to build the hardware, i.e easy access to components, PCB and container they can use (of course it should be open source).

Currently I'm using another open source library for the MPU interaction (same as iSpindel) but I have not dug into the details on the FIFO feature and if that is used, I just base the gyro interaction on the examples.

I would expect that having the gyro running that would draw more power but also make the built in temp sensor unusable since that would not have time to cool down.

I'm planning to release the 2.0 version this week so if you use the dev branch as the base for your tests that should be a good start.

its hard to put some expectation on how to develop the features since I dont really see how much code it will be and how much that would differ from the current code. Start with making them work and we can discuss how to best refactor the code to make it easy to merge and also maintain / test it.

Levi--G commented 5 days ago

Ok will do :)

You are right, using FIFO would give the temp sensor an offset, but not more than you already have now, either way is the temp sensor of the MPU not really that good, i see a few degrees offset even with accel and gyro disabled. The gyro is bad for battery life but it gets duty cycled in fifo mode, so i will test how much impact it really has very soon. Ill use the dev branch and keep you updated.

mp-se commented 5 days ago

On the gyro temp sensor, i did quite a lot of tests before adding that feature and I agree that the accuracy is not that good, but comparable to having a DS18 on low resolution and you read it as soon as the chip started. After a while it will continue to increase and be way off and it requires at least 10 minutes to cool down again....

But do your own tests and we can compare notes later.