Thermometer Example with EFR32 Internal Temperature Sensor
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());
Create an SoC - Empty sample app for your chosen hardware.
Replace the existing app.c with the app.c attached to this article.
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).
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".
Press Save and Generate.
Build and flash.
Using the Blue Gecko app, you can now read the temperature sampled from the internal temperature sensor.
Open Blue Gecko app on your phone.
Select "Health Thermometer".
Connect to the device called "IntTemp".