Acces to nRF52840 temperature sensor

I have seen that the nRF52840 has a build-in temperature sensor. Is there an Arduino library to access it, or somebody has developed some function that I could reuse ?

I see also that there is a complex linearity function mechanisms, Is it mandatory to calibrate it ? and in this case what should be the calibration algorithm ?

Hi there,

So I used it in m|y sensor node code demo’s
it’s available without any schinanigans.. :grin: :+1:
You can access the nRF52840’s internal die temperature sensor quite easily in Arduino without needing a heavy external library. The Nordic core exposes the hardware registers directly, or you can use the built-in temperature_sensing functions if you are using the Adafruit nRF52 BSP.

Here is a short, clean example showing both the direct register method (which works universally on nRF52) and the standard API method.

#include <Arduino.h>

// If using the Adafruit nRF52 core, this built-in function is often available:
// extern "C" int32_t read_temperature(void); 

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10); // Wait for Serial Monitor
  
  Serial.println("nRF52840 Internal Temperature Sensor Test");

  // Initialize the internal TEMP peripheral registers directly
  NRF_TEMP->TASKS_START = 1; 
}

void loop() {
  // Trigger a new temperature measurement
  NRF_TEMP->TASKS_START = 1;
  
  // Wait for the measurement to complete (DATARDY event)
  while (NRF_TEMP->EVENTS_DATARDY == 0) {
    // Busy wait or yield
  }
  NRF_TEMP->EVENTS_DATARDY = 0; // Clear the event flag

  // Read the raw value (0.25°C steps)
  int32_t raw_temp = NRF_TEMP->TEMP;

  // Convert to actual Celsius (divide by 4.0 or multiply by 0.25)
  float celsius = raw_temp * 0.25;

  Serial.print("Internal Die Temp: ");
  Serial.print(celsius);
  Serial.println(" °C");

  delay(2000); // Read every 2 seconds
}

As far as the factory ca, short answer is NO.
" Do you need to implement a complex calibration algorithm?

No, it is not mandatory for standard applications. The “complex linearity function” you read about in the Nordic datasheets is actually already handled in the hardware factory calibration. "

HTH
GL :slight_smile: PJ :v: