Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Read Internal Temperature of STM32F4xx

Read Internal Temperature of STM32F4xx

JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Step 1. Alter board specific platform.c so that ADC1 utilizes ADC_Channel_16.

pastedImage_5.png

 

Step 2. Copy the following code snip into your application and execute.

 

wiced_adc_t adc = WICED_ADC_1;

uint16_t mV;

float celsius;

uint32_t sample_cycle = 10;

 

/*init proper channel*/

wiced_adc_init(adc, sample_cycle);

 

/*this in combination with switching to proper ADC channel is what allows temp sensor to be read*/    

ADC_TempSensorVrefintCmd(1);

 

/*sample channel*/

wiced_adc_take_sample(adc, &mV);

 

/*conversion of mV to celsius--see datasheet*/

celsius = (float)mV;

celsius *= 3300;

celsius /= 0xfff;

celsius /= 1000.0;

celsius -= 0.760;

celsius /= .0025;

celsius += 25.0;

 

WPRINT_BT_APP_INFO(("***** Temperature in deg C =  %f ***** \n\r", celsius));

 

 

Specifics of conversion formula can be found in the datasheet. For more info on the implementation of conversion see: ARM Processors (Discovering the STM32F4): Working with STM32F4 Temperature Sensor

 

Jacob

1524 Views