Author Topic: Measuring While Asleep  (Read 1429 times)

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Measuring While Asleep
« on: September 23, 2016, 08:38:28 AM »
I'm beginning to finalize an outdoor Temperature/Humidity reporting project and I'm trying to do what I can to maximize battery life (which is already obscene frankly, this tweak is just for fun/learning).  In reading the datasheet for both the Si7021 and the HTU21D that I have, it would appear that you can issue a command for the sensors to perform a no hold temperature or humidity measurement and then come back some time later and poll the sensor for the result.  This seems like a perfect opportunity to sleep and save some serious power.  However, when I resume from sleep the measurement is not ready even though I know I have slept long enough for the sensor to have done its work.  Do these sensors stop working if the I2C clock dies?

I should note that I have always done this with my DS18B20s which take a long time to get a temperature and will very happily make their measurement while the uC sleeps.
« Last Edit: September 23, 2016, 08:40:14 AM by ChemE »

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Measuring While Asleep
« Reply #1 on: September 23, 2016, 11:02:02 AM »
Figured out the problem.  It seems that you need to send a stop command on the I2C bus prior to entering sleep and cutting the I2C clock.  If you are not cutting the clock, these modules never need to receive stop commands so I had taken them all out of my code so as not to waste time.  Even with the stops back in, I'm only spending 2.7ms awake even though the measurements themselves take 10ms.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Measuring While Asleep
« Reply #2 on: September 23, 2016, 11:56:03 AM »
Good work  ;)

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Measuring While Asleep
« Reply #3 on: September 23, 2016, 03:49:28 PM »
And now I'm only awake for 300 microseconds and asleep for 30 milliseconds per loop.  Next up to optimize is cutting out some sync bytes and CRC bytes from the radio payload.  I'm only sending 3 bytes of data so cutting out some overhead is very significant.