Re: How to use TEMP sensor on nRF5x boards ? #nrf52840 #sensor

Felipe Gabardo Gonçalves

Hi Yorick,

This TEMP sensor are defined within zephyr sensors pattern. You should use it by binding the device to a struct and using the default functions from sensor.h
You should use this to bind:
struct device *my_sensor_name = device_get_binding(CONFIG_TEMP_NRF5_NAME);
This to fetch a measurement:
And this to return to you the measurement:
sensor_channel_get(my_sensor_name, SENSOR_CHAN_DIE_TEMP, &value);

Follows the zephyr documentation for sensor implementation:

Em qui, 7 de mar de 2019 às 11:50, Yorick Brunet <yorick.brunet@...> escreveu:


I have recently started to use Zephyr. Up to now, I have been able to set up some tasks and ESS (with Temperature characteristic (dummy value for the moment)) and BAS Bluetooth profiles. The BAS profile comes from the samples. I have been able to compile and flash my nRF52840 DK (or pca10056) board. It works well.

I'd like now to get the processor temperature using the TEMP sensor. I have seen that Zephyr provides it:
I added
to my prf.conf and the driver seems to have been compiled.

However, I haven't found any doc to use this sensor except

Do you know I how should use the sensor in my application ?

I haven't found any function in temp_nrf5.c that I can call. All functions are static and takes a "struct device* " as parameter that I don't have. I don't think that my question is only related to this sensor, it must be a generic question valid also for other sensors.


Best regards,

Eng. Eletrônico
+55 41 3020-2400 
+55 41 99899-6691

Join { to automatically receive all group messages.