AD15 is not an actual pin but is connected to a temperature sensor.
and
The temperature sensor is connected to Channel 15 of the ADC.
The temperature sensor provides an output voltage VT that is proportional to absolute temperature (PTAT). To activate the temperature sensor, TSON bit (ADC_ACR) needs to be set.
So analogRead(15) will only work if the TSON bit in ADC_ACR is set by the looks of it. So it's up to the Arduino guys to do that or I guess you can do it yourself.
Yes but on the normal arduino they masked out the upper part of the channel select byte so you could not access the things like the sensor, zero volts 5V and internal Vref. It would have been so much more flexible if they had not done this. You need to look at the C code for the analogue read on a Due to see what they have done this time.
I put in a request to enable the ADC15/temperature sensor. However - it is the temperature on the die - which does warm up.
To make it be close to the ambient temperature is going to require implementing a power down mode - no power no die warmup - and then on wakeup reading the temperature straight away.
Graynomad:
So analogRead(15) will only work if the TSON bit in ADC_ACR is set by the looks of it. So it's up to the Arduino guys to do that or I guess you can do it yourself.
Rob
in hardware/arduino/sam/system/libsam/source/adc.c there is an adc_enable_ts() that sets ADC_ACR_TSON, and the temperature calculation is described in Chapter 46.8 of reference pdf, 2.65mv/deg and 0.8v at 27C
neil12:
I put in a request to enable the ADC15/temperature sensor. However - it is the temperature on the die - which does warm up.
To make it be close to the ambient temperature is going to require implementing a power down mode - no power no die warmup - and then on wakeup reading the temperature straight away.
That seems like a very longwinded way to get a rather inaccurate measurement of the ambient temperature. If you want to measure air temperature, use a temperature sensor that is in the air, not embedded inside a heat-generating device and thermally insulated from the air.
On the other hand, if you need to monitor the on-chip temperature for some reason (like, to raise an alarm if it gets too hot) then that would be a good use of this sensor.
There is the same in the god ol' AtmEga328 (ie all Arduino boards). I fixed a little bit mask in the core libraries and now I can read the corechip temperature as analog 8. It is not very accurate, but has a large range -40 C .. +80 C. Mine returns value 340 for -15C (fresh out of the freezer), 375 for 20C
So, without having a Due at hand, I cant see how to enable it there.
neil12:
I put in a request to enable the ADC15/temperature sensor. However - it is the temperature on the die - which does warm up.
To make it be close to the ambient temperature is going to require implementing a power down mode - no power no die warmup - and then on wakeup reading the temperature straight away.
That seems like a very longwinded way to get a rather inaccurate measurement of the ambient temperature. If you want to measure air temperature, use a temperature sensor that is in the air, not embedded inside a heat-generating device and thermally insulated from the air.
On the other hand, if you need to monitor the on-chip temperature for some reason (like, to raise an alarm if it gets too hot) then that would be a good use of this sensor.
In my opinion it's an good exercise to get "warm" with the new Controller/Board it was similar my first move with the Leonardo figure out how warm is the Controller, for fun not for use...
A note for posterity...
Markus_L811's code works great because he is reading the temperature every 10ms. If you wait longer between reads (say 1sec), you start to get garbage readings after 10 or so readings. But, if you make the raw measurement (the temperatur function) twice in a row when needed, it works fine. It takes about 90usec total for each temperature reading (with the double read).