Spark Logic

Reading internal temperature sensor

Pito Mon Aug 15, 2016 6:12 pm

When reading the ADC channel 16 (temperature sensor) I get constant readings like 1880 even I change temperature of the package by say 15degrees.
The sensor is enabled (from Read Vcc post):
void setup_vcc_sensor() {
adc_reg_map *regs = ADC1->regs;
regs->CR2 |= ADC_CR2_TSEREFE; // enable VREFINT and temp sensor
regs->SMPR1 = ADC_SMPR1_SMP17; // sample rate for VREFINT ADC channel
}

Replies

simonf Thu Aug 18, 2016 11:06 pm

RogerClark wrote:
Good point.

However the 32khz crystal side of the device is still running, so some heat will be generated.. Just , a small fraction as much as when its running at full speed.

ahull Sat Nov 26, 2016 8:36 pm

I thought I’d have a quick play with the internal temperature sensor, so I grabbed the example from

../hardware/STM32F1/2016.11.18/libraries/A_STM32_Examples/examples/General/InternalTempSensor/InternalTempSensor.ino

.. but it fails to compile for the generic stm2f103 board with the following error

/home/ahull/.arduino15/packages/stm32duino/hardware/STM32F1/2016.11.18/libraries/A_STM32_Examples/examples/General/InternalTempSensor/InternalTempSensor.ino: In function 'void setup_temperature_sensor()':
InternalTempSensor:22: error: 'ADC_CR2_TSEREFE' was not declared in this scope
regs->CR2 |= ADC_CR2_TSEREFE;
^
exit status 1
'ADC_CR2_TSEREFE' was not declared in this scope

RogerClark Sat Nov 26, 2016 8:38 pm

Andy

I recall there was a PR / Fix for incorrect definitions in that area. That ADC_CR2_TSEREFE may have been one of them

ahull Sat Nov 26, 2016 9:46 pm

OK If I change to

regs->CR2 |= ADC_CR2_TSVREFE;

RogerClark Sat Nov 26, 2016 10:16 pm

Hi Andy

OK.

I’ll try to update it later.

Unfortunately my local copy of the repo has a load of other changes for various things I was hacking about with, so I’ll need to get rid of those (or save them etc) before I can update the example

RogerClark Sat Nov 26, 2016 11:11 pm

Andy

I’ve edited the sketch file online in github, and committed the change. Can you download it again and test for me as my local repo isnt working at the moment

Sign in to reply