Thermometer Example with EFR32 Internal Temperature Sensor#

Description#

The attached example is an adaptation of the standard 'SOC - Thermometer' example. However, instead of accessing the Si7021 Temperature and Relative Humidity sensor through I2C, this example uses the EFR32's own internal temperature sensor. This sensor is measured during the production test. The temperature readout from the ADC at production temperature as well as the Celsius value are given in the device information page. Using these and the millivolts per degrees slope in the sensor data sheet, the current temperature can be calculated as follows:

T_Celsius = T_Calibration - (ADC_Calibration_Reading - ADC_Current_Reading) * V_Ref / (4096 * Slope)

For more information, see the ADC section of the reference manual of your chosen hardware, e.g., EFR32xG13.

These are the changes to the basic SoC-Thermometer example:

  • init_adc function to initialize ADC with correct voltage reference and prescaler, and so on, which is called after boot event.

  • read_adc function to get single sample readout from ADC, which has a busy-wait-loop for simplicity.

  • convert_to_millicelsius function takes the sample and uses the calibration values in the above formula to get the result as degrees Celsius. The returned value is given in millicelsius.

  • measure_temperature function is nearly identical to the one in the Thermometer example except for this line that uses the above functions:

temperature_data = convert_to_millicelsius(read_adc());

Setting up#

  1. Create an SoC - Empty sample app for your chosen hardware.

  2. Replace the existing app.c with the app.c attached to this article.

  3. Copy em_adc.c and em_adc.h from the SDK (e.g., C:\SiliconLabs\SimplicityStudio\v4\developer\sdks\gecko_sdk_suite\v2.6\platform\emlib) to the project folder (if they aren't already in the platform>emlib>inc/src folders).

  4. Import the attached gatt.xml file in the GATT Configurator sidebar (open .isc file, "Import GATT from .bgproj file"). This will add the Health Thermometer service and Temperature Measurement characteristic and change Device Name to "IntTemp".

  5. Press Save and Generate.

  6. Build and flash.

Usage#

Using the EFR Connect app, you can now read the temperature sampled from the internal temperature sensor.

  1. Open EFR Connect app on your phone.

  2. Select "Health Thermometer".

  3. Connect to the device called "IntTemp".

HTM ScanHTM Scan

HTM ReadingHTM Reading

Source#