Skip to content
Garrett Hawes edited this page Oct 29, 2017 · 10 revisions

Settings

Repeatability

  • SHT31D_CC::REPEATABILITY_HIGH
  • SHT31D_CC::REPEATABILITY_MEDIUM
  • SHT31D_CC::REPEATABILITY_LOW

Mode

  • SHT31D_CC::MODE_CLOCK_STRETCH
  • SHT31D_CC::MODE_POLLING

Frequency

  • SHT31D_CC::FREQUENCY_HZ5
  • SHT31D_CC::FREQUENCY_1HZ
  • SHT31D_CC::FREQUENCY_2HZ
  • SHT31D_CC::FREQUENCY_4HZ
  • SHT31D_CC::FREQUENCY_10HZ

Error Codes

  •  000 - NO ERROR (enum SHT31D_CC::SHT31D_ErrorCode)
  • -101 - CRC ERROR
  • -102 - TIMEOUT ERROR
  • -501 - PARAM WRONG MODE
  • -502 - PARAM WRONG REPEATABILITY
  • -503 - PARAM WRONG FREQUENCY
  • -504 - PARAM WRONG ALERT
  • -010 - I2C DATA TOO LOG
  • -020 - I2C RECEIVED NACK ON ADDRESS
  • -030 - I2C RECEIVED NACK ON DATA
  • -040 - I2C UNKNOWN ERROR

Datatype

SHT31D_CC::SHT31D

Container to hold sensor results with data members:

  • t - Temperature in ℃ (float)
  • rh- Relative Humidity in % (float)
  • error - Error Code (SHT31D_ErrorCode)

SHT31_CC::SHT31D_RegisterStatus

Container to hold SHT register status

  • WriteDataChecksumStatus - (uint8_t)
  • CommandStatus - (uint8_t)
  • Reserved0 - (uint8_t)
  • SystemResetDetected - (uint8_t)
  • Reserved1 - (uint8_t)
  • T_TrackingAlert - (uint8_t)
  • RH_TrackingAlert - (uint8_t)
  • Reserved2 - (uint8_t)
  • HeaterStatus - (uint8_t)
  • Reserved3 - (uint8_t)
  • AlertPending - (uint8_t)

Functions

begin(uint8_t address)

Parameters

  • address - 0x44 (default) or 0x45 on most breakout boards this can be switched from 0x44 to 0x45 by jumping the ADR pin to VDD/VIN, on the ClosedCube board there is a jumper you can solder.

Return

  • SHT31D_ErrorCode - See above

clearAll()

Clear all the status register bits

Return

  • SHT31D_ErrorCode - See above

readStatusRegister()

heaterEnable()

Enable the onboard heater for plausibility checking.

Return

SHT31D_ErrorCode - See above

heaterDisable()

Disable the onboard heater.

Return

SHT31D_ErrorCode - See above

softReset()

This forces the system into a well-defined state without removing the power supply. When the system is in idle state, the soft reset command can be sent to the SHT3xDIS. This triggers the sensor to reset its system controller and reloads calibration data from the memory.

Return

SHT31D_ErrorCode - See above

generalCallReset()

This will reset all of the devices on the I2C bus see softReset() for specifics relating to this sensor.

Return

SHT31D_ErrorCode - See above

artEnable()

Activate accelerated response time protocol to improve response time of the humidity sensor from 8 to 4 seconds

Return

SHT31D_ErrorCode - See above

readSerialNumber()

Return

uint32_t - Serial number for the sensor.

readTempAndHumidity(repeatability, mode, timeout)

Params

  • repeatability - SHT31D_Repeatability
    • SHT31D_CC::REPEATABILITY_HIGH
    • SHT31D_CC::REPEATABILITY_MEDIUM
    • SHT31D_CC::REPEATABILITY_LOW
  • mode - SHT31D_Mode
    • SHT31D_CC::MODE_CLOCK_STRETCH
    • SHT31D_CC::MODE_POLLING
  • timeout - uint8_t
    • Use 50

Return

SHT31D_31::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

readTempAndHumidityClockStretch(repeatability)

Called internally from readTempAndHumidity() but also can be called separately

Params

  • repeatability - SHT31D_Repeatability
    • SHT31D_CC::REPEATABILITY_HIGH
    • SHT31D_CC::REPEATABILITY_MEDIUM
    • SHT31D_CC::REPEATABILITY_LOW

Return

SHT31D_31::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

readTempAndHumidityPolling(repeatability, timeout)

Called internally from readTempAndHumidity() but also can be called separately

Params

  • repeatability - SHT31D_Repeatability
    • SHT31D_CC::REPEATABILITY_HIGH
    • SHT31D_CC::REPEATABILITY_MEDIUM
    • SHT31D_CC::REPEATABILITY_LOW
  • timeout - uint8_t

Return

SHT31D_31::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

periodicStart(repeatability, frequency)

Start periodic data acquisition mode

Params

  • repeatability - SHT31D_Repeatability
    • SHT31D_CC::REPEATABILITY_HIGH
    • SHT31D_CC::REPEATABILITY_MEDIUM
    • SHT31D_CC::REPEATABILITY_LOW
  • frequency - SHT31D_Frequency
    • SHT31D_CC::FREQUENCY_HZ5
    • SHT31D_CC::FREQUENCY_1HZ
    • SHT31D_CC::FREQUENCY_2HZ
    • SHT31D_CC::FREQUENCY_4HZ
    • SHT31D_CC::FREQUENCY_10HZ

Return

SHT31D_CC::SHT31D_ErrorCode - An error code, see above.

periodicFetchData()

Fetch peridic data aquisition mode results

Return

SHT31D_CC::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

periodicStop()

Stop periodic data acquisition mode

Return

SHT31D_CC::SHT31D_ErrorCode - An error code, see above.

writeAlertHigh(temperatureSet, temperatureClear, humiditySet, humidityClear)

Write the alert register values for maximum

Params

  • temperatureSet -float
    • Temperature value to start alert
  • temperatureClear - float
    • Temperature value to stop alert
  • humiditySet - flaot
    • Humidity value to start alert
  • humidityClear - float
    • Humidity value to stop alert

Return

SHT31D_CC::SHT31D_ErrorCode - An error code, see above.

readAlertHighSet()

Read the high alert start value.

Return

SHT31D_CC::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

readAlertHighClear()

Read the high alert clear value.

Return

SHT31D_CC::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

writeAlertLow(temperatureClear, temperatureSet, humidityClear, humiditySet)

Write the alert register values for minimum

Params

  • temperatureClear - float
    • Temperature value to stop alert
  • temperatureSet -float
    • Temperature value to start alert
  • humidityClear - float
    • Humidity value to stop alert
  • humiditySet - flaot
    • Humidity value to start alert

Return

SHT31D_CC::SHT31D_ErrorCode - An error code, see above.

readAlertLowSet()

Read the low alert start value.

Return

SHT31D_CC::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.

readAlertLowClear()

Read the high alert clear value.

Return

SHT31D_CC::SHT31D - A container with temperature (in degrees C), humidity (%) and an error code.