3.12 Reading Temperature

Driver supports reading temperature in degrees Celsius of the SAM device.‌

The SAMD51 function for reading temperature of the SAM device is DSCSAM_TemperatureSensorRead.‌

Step-By-Step Instructions

The User need to call the function DSCSAM_TemperatureSensorRead() passing the address of an integer buffer as argument to store the temperature value read.

...

ERRPARAMS errparams;  // structure for returning error code and error string
int temperature;

...

// The temperature value read will be available in the variable temperature after the call to function DSCSAM_TemperatureSensorRead.
// Teperature value in degrees Celsius.

if( DSCSAM_TemperatureSensorRead(&temperature) != DE_NONE )
{
    DSCGetLastError ( &errparams );
    printf ( "DSCSAM_TemperatureSensorRead error: %s %s\n", DSCGetErrorString ( errparams.ErrCode ), errparams.errstring );		
    return 0;
}

...

Last updated