nvapi gpu thermal info

Hi everyone,
I wrote a code, using the library nvapi, in order to monitor the temperature of my graphics card (tesla k40m) when executing a kernel.

NvPhysicalGpuHandle phys[NVAPI_MAX_PHYSICAL_GPUS*2];

    ret = NvAPI_EnumTCCPhysicalGPUs(phys, &cnt);

    if (ret != NVAPI_OK){
        NvAPI_ShortString string;
        NvAPI_GetErrorMessage(ret, string);
	}

    NvAPI_ShortString name;
	
    NV_GPU_THERMAL_SETTINGS thermal;

    ret = NvAPI_GPU_GetFullName(*phys, name);
    if (ret != NVAPI_OK){
        NvAPI_ShortString string;
        NvAPI_GetErrorMessage(ret, string);
        //printf("NVAPI NvAPI_GPU_GetFullName: %s\n", string);
    }

    //printf("Name: %s\n", name);
    thermal.version = NV_GPU_THERMAL_SETTINGS_VER;
    ret = NvAPI_GPU_GetThermalSettings(*phys,0, &thermal);

    if (ret != NVAPI_OK){
        NvAPI_ShortString string;
        NvAPI_GetErrorMessage(ret, string);
        //printf("NVAPI NvAPI_GPU_GetThermalSettings: %s\n", string);
    }

    return thermal.sensor[0].currentTemp;

My problem is that I get output values that are very different from those of other test software found online (like gpu-z).
What am I doing wrong?

Thanks in advance

Domenico

I use version 2 and this code works for the core temperature

NvAPI_Status nvapiStatus;
NV_GPU_THERMAL_SETTINGS result;
result.version = NV_GPU_THERMAL_SETTINGS_VER_2;
result.sensor[0].target = NVAPI_THERMAL_TARGET_GPU;
result.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_GPU_INTERNAL;

nvapiStatus = NvAPI_GPU_GetThermalSettings (<your handle>, NVAPI_THERMAL_TARGET_NONE, &result);

if (nvapiStatus != NVAPI_OK) return 0;

return result.sensor[0].currentTemp;