[solved] In sleep mode SparkFunHTU21D library draws six times normal current

I'm using SparkFunHTU21D library to access HTU21d sensor.
I'm using a ProMini clone to access it. However, the phenomenon occurs even if no HTU21d sensor is connected. It must be a software issue.

Here is the whole sketch to test it:

#include "LowPower.h"
#include <Wire.h>
#include <SparkFunHTU21D.h>

HTU21D myHumidity;

void setup() {
// no begin-statement -> apprpx. 20 µA while sleeping
// uncommenting begin-statement -> approx 180 µA current while sleeping
//myHumidity.begin();
}

void loop() {
LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
}

I looked into SparkFunHTU21D.cpp but I don't see anything suspicious. I guess it has to do with pin configuration but I've no clue how to fix it.
Maybe someone has an idea and solution, respectively, how to stop the current loss.

Thanks & best

You compare the power consumption to which state? I understand that you run above sketch and measure the consumption. What sketch did you run when you measured the comparison value? Was the hardware setup exactly the same?

Thanks for your reply.
Yes indeed, the hardware did not change in any regard--perfectly the same! Just hit the flash button between measurements.
And sorry, I thought the comment in the sketch was self-explanatory:

terraduino:

// no begin-statement -> apprpx. 20 µA while sleeping

// uncommenting begin-statement -> approx 180 µA current while sleeping
 //myHumidity.begin();

Firstly, run the sketch as is. Measure current. Here, 20uA.
Secondly, uncomment myHumidity.begin(); and flash the sketch. Measure current. Here, 180uA.

I de-soldered on-board LED and voltage regulator to get into uA range, just in case you don't get that low.

Thanks & best

The call to myHumidity.begin() activates the I2C interface and even in power down mode the I2C address match circuitry stays active which uses some power. If you change your loop to

void loop() {
  Wire.end(); // deactivate I2C address matching
  LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
  myHumdity.begin();
}

your consumption should be low again.

@pylon
Thank you very much, that's it. I misinterpreted "endTransmission()" as "deactivate all I2C activity".
Now I'm down to 20uA again :slight_smile:

Best