Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing battery usage with accelerometer permanently asleep #5

Open
johnheenan opened this issue Apr 16, 2020 · 14 comments
Open

Testing battery usage with accelerometer permanently asleep #5

johnheenan opened this issue Apr 16, 2020 · 14 comments

Comments

@johnheenan
Copy link
Contributor

johnheenan commented Apr 16, 2020

I have been testing the wristband with the accelerometer permanently asleep and skipped with button press.

The results are very encouraging and makes the wristband much more practical for me.

These are the steps I have taken so far:

Added to build_flags in plarform.ini:
-DIMU_SKIP

After initMPU() in setup() in main.cpp

#ifdef IMU_SKIP
    mpuSleep();
#endif

In showPage() in pages.cpp

  case 3:
#ifndef IMU_SKIP
    max_time_out = 60000;
    pageBearing(initialLoad);
    break;
#else
    page++;
#endif
  case 4:
#ifndef IMU_SKIP
    max_time_out = 30000;
    pageTemperature(initialLoad);
    break;
#else
    page++;
#endif

In handleSleep() of hardware/sleep.cpp

#ifndef IMU_SKIP
  mpuSleep();
#endif

also:

#ifndef IMU_SKIP
  esp_sleep_enable_ext1_wakeup(GPIO_SEL_33 | GPIO_SEL_39, ESP_EXT1_WAKEUP_ANY_HIGH);
#else
  // 39 is from IMU but has label IO38. 33 is from touch capacitor
  esp_sleep_enable_ext1_wakeup(GPIO_SEL_33, ESP_EXT1_WAKEUP_ANY_HIGH);
#endif

For completeness but not required: in handleAction() in pages/pages.cpp:

  case 3:
#ifndef IMU_SKIP
    actionBearing();
#endif
    break;

John Heenan

@johnheenan
Copy link
Contributor Author

If someone could provide code to put the MPU9250 accelerometer in its lowest power state I will give it a try.

Using the current mpuSleep() code is not ideal to test power saving but it at least leaves the MPU9250 in a known low power state. We cannot assume the MPU9250 will power up in a low power state and even if it does, a wake-up of the watch from a state in which the MPU9250 was not in a low power state will not alter this state unless some initialisation of the MPU9250 is done.

John

@TioRuben
Copy link
Owner

I've been trying to make sleep power consumption low, but at the time was absolutely impossible. Seems that MPU9250 was giving some problems for LilyGo and have changed the IMU chip: https://github.com/Xinyuan-LilyGO/LilyGO-T-Wristband Maybe it's not the best IMU for this kind of projects.

@johnheenan
Copy link
Contributor Author

Thanks for your response.

There is a comparison links between MPU9250 and LSM9DS1 at
kriswiner/MPU6050#6
but there is no clear cut 'winner'.

However I guess the LSM9DS1, being an ST iNEMO model, might be more geared to making it easier to use wake-up gestures while keeping power usage down.

Using the following as a reference:
kriswiner/MPU9250#162 (comment)
I have altered my shut down code above to try and draw lower power

Above setup() in main.cpp

#ifdef IMU_SKIP
extern MPU9250 IMU;
#endif

In setup() in main.cpp

#ifndef IMU_SKIP
  initMPU();
#else
//mpuSleep();
//set sleep mode bit(6), disable all sensors
  IMU.writeByte(MPU9250_ADDRESS, PWR_MGMT_1, IMU.readByte(MPU9250_ADDRESS, PWR_MGMT_1) | 0x40); 
  delay(100); // wait for all registers to reset
//clear bits 0 to 3 to power down magnetometer
  IMU.writeByte(AK8963_ADDRESS, AK8963_CNTL, IMU.readByte(AK8963_ADDRESS, AK8963_CNTL) & ~(0x0F) ); 
//write bit 4 to enable gyro standby
  IMU.writeByte(MPU9250_ADDRESS, PWR_MGMT_1, IMU.readByte(MPU9250_ADDRESS, PWR_MGMT_1) | 0x10); 
  delay(10); // wait for all registers to reset
#endif

@wilksy
Copy link

wilksy commented Apr 19, 2020

To be honest, I think the ESP32 is not the best choice for a wrist device unless the whole board is designed for battery life.

@TioRuben
Copy link
Owner

TioRuben commented Apr 19, 2020

To be honest, I think the ESP32 is not the best choice for a wrist device unless the whole board is designed for battery life.

@wilksy you're right: ESP32 low power mode needs a board to be carefully designed, even with a PMU. For example, I also got a TTGO T-Beam and I could keep current consumption somewhere around uA by interfacing the built-in AXP192. First versions of the T-Wristband seems not to be very optimized for LP.

Let's see what LilyGo does with their new T-Watch-2020

@johnheenan
Copy link
Contributor Author

johnheenan commented Apr 20, 2020

Here are some measurements.

As a result of these measurements I agree with the above.

In a sleep state with IMU_SKIP (as per above ) turned on constant 609uA at 3.9V.

In a sleep state with IMU_SKIP off (code now same as repository code) the observed current varied between 834uA and 925uA also at 3.9V.

So the MPU9250 is adding between about 220uA and 320uA to a constant current lowest of about 610uA with the accelerometer powered down as much as possible (if the code I used is correct for this). The idle mode current of the MPU9250 is 8uA (see next comment)

Measurements were made by connecting to battery input terminal:

image

John Heenan

@johnheenan
Copy link
Contributor Author

I have just checked the dastasheet for the MPU9250. The idle mode current is 8uA. There is an low power accelerometer mode with DMP, gyrometer and magnetometer disabled of 19.8uA at 31.25Hz. I don't know if the DMP is required to set interrupt triggering at certain thresholds.

Comparing with datasheet of LSM9DS1, they do not provide a current for an idle or power down mode or for an accelerometer only mode. However other acceleromters in the series, such as the LSM6DSL do, which may be just the LSM9DS1 without the magetometer. The LSM6DSL has a power down current of 3uA and an accelerometer only low power current of 9uA at 12.5Hz. I don't know if this will include interrupt triggering at set thresholds. I have the impression it does.

John Heenan

@johnheenan
Copy link
Contributor Author

johnheenan commented Apr 21, 2020

I am getting far better results with another T-Wristband using SKIP_IMU above. My guess is that it is currently drawing power at 10uA or under. I am reluctant to open it up. Will report again in the next few days

@johnheenan
Copy link
Contributor Author

Progress report after nearly four days with MPU9250 accelerometer permanently powered down with IMU_SKIP (as per above) and checking time several times each day:
battery voltage at 3.68V (53%).

It looks like the watch is going to last over a week without a charge!

@johnheenan
Copy link
Contributor Author

Unlike the first few days, at day 6 there has been a rapid decline in voltage during the day from around 20%? (unrecorded voltage) to 0% (3.09V down to 2.86V recorded) as the battery rapidly approached discharge.

If we assume the 80mAh battery optimistically gave back 100% of its rated capacity this means over about six days or about 150 hours the average current was close to 80*1000/150= 533uA. This is close enough, for practical purposes, to the 609uA measured before. The watch display was turned on several times each day so this affects the result.

So unless there is something wrong with the way the way the accelerometer was powered down with IMU _SKIP, there appears to be little practical that can be done. For example dropping average current use of the accelerometer from say 270uA to say 10uA is not going to make a great difference on top of 500uA or more. 50% extra time on an already short time is sill a short time.

@TioRuben
Copy link
Owner

TioRuben commented May 1, 2020

@johnheenan Thanks for the research. Unfortunately, my wristband is not powering up again since I've been trying to solder a MS412FE battery that wasn't populated in my unit. My soldering iron tip wasn't small enough :(. The china post in my country is not working because of the coronavirus outage, I'll try to order a new one to continue the development. If you want, you can send a PR to include your changes. I think Lilygo will send the new one with the new IMU chip so my code will need to support both IMUs.

@johnheenan
Copy link
Contributor Author

I have put up a PR but I am going to withdraw it and resubmit it with the following changes with regard to time zones.

  • Although the code works, use AEST and AEDT not as regions but as UTC offsets
  • Make a start to moving time zone parameters (including changeover dates) to platformio.ini (and later elsewhere) to keep source code decluttered from using C precprocessor directives

johnheenan referenced this issue in johnheenan/TTGO-T-Wristband May 4, 2020
Allow use of daylight savings anywhere or not at all

Use of variables to allow firmware default timezones that that can be changed by users without affecting underlying code
@johnheenan
Copy link
Contributor Author

Removed a line from the current PR and timezones branch preventing the IMU from remaining in deep sleep.

@wide-area-devices
Copy link

I have resorted to hot airing the LSM9DS1 off, ESP deep sleep with timer now at 0.518ma down from 1.67ma with the IMU in place, why they didnt hang it off an I/O pin is beyond me or give us a library that makes it sleep efficiently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants