Powering sensor from digital pin

I'm working on ultralowpower outdoor temp/humidity sensor based on TH02. It uses Atmega328p for brains and powered by 3V coin cell. TH02 is drawing power even when MCU sleeps, so I need a way to turn it off when not in use. Sure I can use transistor, but why extra parts if I can power it from Atmega digital pin... It shouldnt cause any issues right? TH02 uses just 240uA during conversion..

This sensor ? http://www.hoperf.com/sensor/app/TH02.htm

Most sensors can be powered with a digital pin, but you have to be careful with I2C chips. When powered down, a current will flow through the pullup resistors, so you have to power the pullup resistors also with (the same) digital pins. If you use the internal pullup resistors (as set by default in the Wire library) you have to disable them.

When some current is flowing into a sensor via the signal pins, it might work half-half and it can do crazy things like shortcutting or something else. The sensor must either work with a normal voltage, or be fully unpowered.

Do you know this: http://www.gammon.com.au/power

Peter_n:
This sensor ? http://www.hoperf.com/sensor/app/TH02.htm

Most sensors can be powered with a digital pin, but you have to be careful with I2C chips.
When powered down, a current will flow through the pullup resistors, so you have to power the pullup resistors also with (the same) digital pins. If you use the internal pullup resistors (as set by default in the Wire library) you have to disable them.

When some current is flowing into a sensor via the signal pins, it might work half-half and it can do crazy things like shortcutting or something else. The sensor must either work with a normal voltage, or be fully unpowered.

Do you know this: Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

Thanks for the info an URL! I’ve read it before many times, just never realized there was more after first post (I thought those were just replies like in the forum) lol
Which internal pullup resistor are you talking about? In the AVR or TH02? Cause TH02 has built in pull-up resistors, but I think they are always active.
I actually found more info in the TH02 datasheet:

For ultra-low-power operation, such as in battery-powered applications. In this case, the TH02 is powered from
one of the MCU’s GPIOs. The GPIO can be driven high to powerup the TH02, once the measurement results are
obtained, the GPIO can be driven low to power-down the TH02, reducing its current consumption to zero. The GPIO
must be capable of sourcing 320 µA for the duration of the conversion time (<200 ms for relative humidity and
temperature conversions) and up to 40 mA for a period of
5 ms at power-up. The GPIO must also be capable of sinking up to 40 mA for a period of 5 ms at powerdown. If the
GPIO is not capable of sourcing/sinking 40 mA, then the TH02 will take longer to powerup and powerdown.

I’m a little confused what they mean by “power-down” and “powerup”, as there’s no power-down command for TH02…

They means the same thing as you, using an Arduino digital output pin to power the sensor. Set pin HIGH : sensor is powered up. Set pin LOW : powered down.

I think the sensor has no internal pullup resistors for the I2C bus, but the Arduino Wire library sets them. They are 50k.

They can be turned off, but you need pullup resistors to communicate with the sensor. The I2C bus relies on pullup resistors.

I'm not sure, but it was something like this:

Wire.begin();             // Start I2C, enable internal pullups
digitalWrite( SDA, LOW); // disable internal pullup
digitalWrite( SCL, LOW);  // disable internal pullup

Peter_n: They means the same thing as you, using an Arduino digital output pin to power the sensor. Set pin HIGH : sensor is powered up. Set pin LOW : powered down.

I think the sensor has no internal pullup resistors for the I2C bus, but the Arduino Wire library sets them. They are 50k.

They can be turned off, but you need pullup resistors to communicate with the sensor. The I2C bus relies on pullup resistors.

I'm not sure, but it was something like this:

Wire.begin();             // Start I2C, enable internal pullups
digitalWrite( SDA, LOW); // disable internal pullup
digitalWrite( SCL, LOW);  // disable internal pullup

TH02 actually has internal pullups:

SDA and SCL pins have an internal 75 kΩ pull-up resistor to VDD

I was more confused by power surge during shutdown. I mean how can it use power if I cut it off? Or maybe it goes thru SDA/SCL pins...

Update: It works great on breadboard! When powering TH02 from D8 pin it only consumes 0.32mA maximum. I'm not sure what they were talking about in datasheet(40mA), maybe it's for scenarios when internal heating element is active... I tested 8second watchdog sleep mode (configured to wake up every minute and take reading then go back to sleep) and on average power usage is 10uA.