Reference

Last revision 2026/01/21

Library

Communication Protocol Description

The sensor uses I2C communication with a maximum rate of 1MHz. The I2C address is selectable via the ADDR pin: pull low for 0x4A, pull high (default) for 0x4B.

API Description

    void setRepeat(eCode_t code);

    /*!
     *@brief Set clock stretching. After enabling clock stretching, the sensor won't send NAK if the measurement is not done; it will send data to implement the unfinished measurement command after the measurement is done.
     *@param clockStretch: Whether to turn on clock stretching, true for on, false for off
     */
    void setStretch(bool clockStretch);

    /*!
     *@brief Set measurement frequency, enable sensor period measurement mode (set the period measurement frequency, equivalent to sending a command to enable the period measurement mode)
     *@param freq: Select e2S, e1Hz, e2Hz, e4Hz and e10Hz modes in the enum variable eFreq_t
     */
    void setFreq(eFreq_t freq);

    /*!
     *@brief Turn on the heater
     */
    void setHeaterOn();

    /*!
     *@brief Turn off the heater
     */
    void setHeaterOff();

    /*!
     *@brief Interrupt the ongoing work of the sensor and force it into idle mode
     */
    void breakSensor();

    /*!
     *@brief Set the parameters to the default value
     */
    void resetSensor();

    /*!
     *@brief Get and save all the current statuses of the sensor
     *@n But after a while, you have to call the interface before obtaining the current sensor status through other api functions
     */
    void getStatus();

    /*!
     *@brief Get checksum status
     *@return true: checksum of last write transfer was correct
     *@n      false: checksum of last write transfer failed
     */
    bool checkSumStatus();

    /*!
     *@brief Get command status
     *@return true: last command executed successfully
     *@n      false: last command not processed.
     */
    bool commandStatus();

    /*!
     *@brief Check if the system is reset
     *@return true: no reset detected since last 'clear status register' command
     *@n      false: reset detected (hard reset, soft reset command or supply fail)
     */
    bool systemResetDetected();

    /*!
     *@brief Temp tracking alert
     *@return true: no alert
     *@n      false: alert
     */
    bool temTrackingAlert();

    /*!
     *@brief Get heater status
     *@return true: Heater OFF
     *@n      false: Heater ON
     */
    bool heaterStatus();

    /*!
     *@brief Get alert pending status
     *@return true: no pending alerts
     *@n      false: at least one pending alert
     */
    bool alertPendingStatus();

    /*!
     *@brief Get the current temp in single measurement mode, note: ensure the sensor is in idle status, you can call the relevant api: breakSensor()
     *@return Unit: ℃
     */
    float  getTemperatureSingleC();

    /*!
     *@brief Get the current temp in period measurement mode, note: set the sampling frequency in advance, you can call the relevant api: setFreq(eFreq_t freq)
     *@return Unit: ℃
     */
    float  getTemperaturePeriodC();

Other Supplementary Information

Note:
Self-heating may occur when the measurement rate is at a maximum of 10Hz.

Precaution:

  • Avoid long-term use in environments with excessive humidity (the environment is considered dry when its humidity reference is below 40% RH, and the moisture generated by the temperature difference between day and night can be removed by the self-heating function).
  • Please do not use 10Hz mode to transmit data for a long time, it will cause self-heating and then reduce the accuracy.

Was this article helpful?

TOP