0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

nRF52840のDie Temperatureを読み出してみた。

Posted at

要約

Nordic Semiconductor社製SoC nRF52840に内蔵されている温度計の値を読み出す。

コード

prj.conf

CONFIG_SENSOR=y
CONFIG_TEMP_NRF5=y

C

#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>

static const struct device* kDevDieTemp = DEVICE_DT_GET_ANY(nordic_nrf_temp);

float die_temperature(void) {
  struct sensor_value temp_val;
  if (true == device_is_ready(kDevDieTemp)) {
    sensor_sample_fetch(kDevDieTemp);
    sensor_channel_get(kDevDieTemp, SENSOR_CHAN_DIE_TEMP, &temp_val);
  }
  return ((float)temp_val.val1 + ((float)temp_val.val2 / 1000000.0f));
}

動作確認環境

  • toolchains v2.6.2
  • nRF Connect SDK v2.6.2
  • MDBT50Q-DB-40 (raytac_mdbt50q_db_40_nrf52840)

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?