How to get die temperature on NRF52832 using Zephyr

I'm trying to get a temperature reading from the on-chip temperature sensor on the NRF52832 - I know it is not a very accurate sensor but I still want to use it. I found a very cohesive example of how to do this using the nRF SDK:


But I'd now like to implement this in Zephyr - has anyone got any examples of this working? I guess it'd be as simple as referencing the nrf_temp.h library that the example uses in order to get the necessary functions?

Any pointers would be greatly appreciated


  • Hi
    Nordic contributes device support to the Zephyr open source project and can recommend it as a solution, though we do not offer technical support for Zephyr RTOS on nRF52 today. I am sorry, but we don't offer technical support for the Zephyr RTOS on nRF52 as of yet.
    Best regards,
  • Are there any news on this topic? I would be interested in the answer to the original question


  • Hi mate, I struggled with this one so I'll help you out - this is how I did it in the end:

    static int read_temperature(struct device *temp_dev,

        struct sensor_value *float_val) {

      const char *name = temp_dev->name;

      struct sensor_value temp_val;

      int ret;

      ret = sensor_sample_fetch(temp_dev);

      if (ret) {

        printk("%s: I/O error: %d", name, ret);

        return ret;


      ret = sensor_channel_get(temp_dev, SENSOR_CHAN_DIE_TEMP, &temp_val);

      if (ret) {

        printk("%s: can't get data: %d", name, ret);

        return ret;


      //printk("%s: read %d.%d C\n", name, temp_val.val1, temp_val.val2);

      float_val->val1 = temp_val.val1;

      float_val->val2 = temp_val.val2;

      generic_data[3] = temp_val.val1;

      return 0;


  • Hi Christian,

    Thank you for the fast reply. Could you please tell me how to populate struct device* in your function call?

    I found another example (installed with nRF Connect SDK in \ncs\v1.5.0\zephyr\samples\sensor\thermometer) that is quite similar to your code. Unfortunately, the following initialisation returns an error

    temp_dev = device_get_binding("TEMP_0");

    Best regards


  • I assign temp_dev by using the CONFIG_TEMP_NRF5_NAME macro:

    temp_dev = device_get_binding(CONFIG_TEMP_NRF5_NAME);