0

SHT31-D arduino library default acquisition mode
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SHT31-D arduino library default acquisition mode

by subdude5 on Sun Sep 26, 2021 7:21 pm

Referring to Sensirion's SHT31's data sheet, the single-shot mode allows the lowest idle consumption current. The Arduino library via File->Examples->Adafruit_SHT31->SHT31test gives no clue what acquisition mode is used as the default. Your Python library gives a choice, but the older Arduino library hides details.I would like to use the single shot mode for the lowest idle current. This "SHT31_MEAS_HIGHREP" in https://github.com/adafruit/Adafruit_SH ... it_SHT31.h is what I need to set, but I do not know how to do this properly for the simpleton that I am.
Perhaps a soft reset, easy enough with sht31.reset(), or a >1us long LOW driven line to the device's nRESET pin might put the SHT31 into the lowest current mode. I dunno. The data sheet does not tell us. A "well defined state" it is not quite. It's hard to write great datasheets!
I don't have the fancy Nordic nRF-PPK2 - Power Profiler Kit II, yet. Maybe Santa will help. Meanwhile, anyone know how to 1) get the lowest idle current (idle state typical 2uA in single shot mode) or 2) know what the consumption current is "typically" after either a soft reset or pulsing the nRESET line LOW for >1us? A complete removal of power and disconnecting all signal lines (there are protection diodes to the rails) ain't gonna be a real solution. I love simple. Elegant is even better. Hints, tutorials, guides all welcome and much appreciated.

subdude5
 
Posts: 1
Joined: Sun Sep 26, 2021 6:14 pm

Re: SHT31-D arduino library default acquisition mode

by mikeysklar on Tue Sep 28, 2021 6:46 pm

It looks like SHT31_MEAS_HIGHREP is getting set by readTempHum() using writeCommand().

https://github.com/adafruit/Adafruit_SH ... _SHT31.cpp

Code: Select all | TOGGLE FULL SIZE
/**
 * Internal function to perform a temp + humidity read.
 *
 * @return True if successful, otherwise false.
 */
bool Adafruit_SHT31::readTempHum(void) {
  uint8_t readbuffer[6];

  writeCommand(SHT31_MEAS_HIGHREP);

  delay(20);

  i2c_dev->read(readbuffer, sizeof(readbuffer));

  if (readbuffer[2] != crc8(readbuffer, 2) ||
      readbuffer[5] != crc8(readbuffer + 3, 2))
    return false;

  int32_t stemp = (int32_t)(((uint32_t)readbuffer[0] << 8) | readbuffer[1]);
  // simplified (65536 instead of 65535) integer version of:
  // temp = (stemp * 175.0f) / 65535.0f - 45.0f;
  stemp = ((4375 * stemp) >> 14) - 4500;
  temp = (float)stemp / 100.0f;

  uint32_t shum = ((uint32_t)readbuffer[3] << 8) | readbuffer[4];
  // simplified (65536 instead of 65535) integer version of:
  // humidity = (shum * 100.0f) / 65535.0f;
  shum = (625 * shum) >> 12;
  humidity = (float)shum / 100.0f;

  return true;
}

mikeysklar
 
Posts: 5808
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.