<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56171/how-to-get-die-temperature-on-nrf52832-using-zephyr</link><description>I&amp;#39;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: 
 nRF5_SDK_15.0.0_a53641a</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Jul 2021 21:20:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56171/how-to-get-die-temperature-on-nrf52832-using-zephyr" /><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/320783?ContentTypeID=1</link><pubDate>Mon, 19 Jul 2021 21:20:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be7f933c-4316-4633-b915-9f939db64eb0</guid><dc:creator>zciwor</dc:creator><description>&lt;p&gt;I ended up finding this example which solved the problem for me:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/bluetooth/peripheral_ht/src/hts.c"&gt;github.com/.../hts.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/320782?ContentTypeID=1</link><pubDate>Mon, 19 Jul 2021 20:54:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b1a6528-c13a-42df-80b9-f695ef25deed</guid><dc:creator>zciwor</dc:creator><description>&lt;p&gt;Hey David, did you&amp;nbsp;find a solution here? I&amp;#39;m running into the same issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302858?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 13:27:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bc33f1e-87b4-4196-9c4d-123456bac8c6</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Yes, the header file is included. I&amp;#39;ll see if I can get some help on Slack&lt;/p&gt;
&lt;p&gt;Thanks for your help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302856?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 13:19:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20c07931-7848-4ac5-95ca-050824eafdbc</guid><dc:creator>Christian Holland</dc:creator><description>&lt;p&gt;Are you sure to include the sensor header file too?&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;#include &lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;drivers/sensor.h&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s2"&gt;If not I&amp;#39;m not sure what else, there&amp;#39;s nothing else relevant in my prj.conf. Are you in the Zephyr Slack channel? They&amp;#39;re normally quite helpful there.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302854?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 13:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d649913-03c3-4de1-961d-b3f9af315fcd</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Thank you for the hint. Unfortunately, CONFIG_TEMP_NRF5_NAME is still undefined. &lt;/p&gt;
&lt;p&gt;However, CONFIG_HAS_HW_NRF_TEMP is set to 1, which means the hardware exists, but I can&amp;#39;t figure out its name.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302851?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 12:52:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3e46802-7a7b-4557-acf7-fb290cafc9ca</guid><dc:creator>Christian Holland</dc:creator><description>&lt;p&gt;We&amp;#39;ve only been testing and using NRF52832 so i guess the binding could be different for the 528340 (although i wouldn&amp;#39;t imagine so).&lt;/p&gt;
&lt;p&gt;Try adding this to you prj.conf&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s1"&gt;CONFIG_TEMP_NRF5=y&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302850?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 12:49:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56241215-84b3-4a12-bac5-fa9bc999c2dc</guid><dc:creator>David</dc:creator><description>&lt;p&gt;According to Zephyr documentation, the default value for&amp;nbsp;&lt;span class="s1"&gt;CONFIG_TEMP_NRF5_NAME&lt;/span&gt; should be &amp;quot;TEMP_0&amp;quot;, but that doesn&amp;#39;t work for me. Could you check how it&amp;#39;s expanded in your example?&lt;/p&gt;
&lt;p&gt;Which chip / board do you use? I have an nRF52840-DK&lt;/p&gt;
&lt;p&gt;What are the contents of your prj.conf file? Do I have to enable something more than CONFIG_SENSOR=y&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302849?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 12:30:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fb58f78-7832-4214-aafb-0186260fcc66</guid><dc:creator>Christian Holland</dc:creator><description>&lt;p&gt;I&amp;nbsp;assign&amp;nbsp;temp_dev by using the&amp;nbsp;&lt;span&gt;CONFIG_TEMP_NRF5_NAME&amp;nbsp;&lt;/span&gt;macro:&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;temp_dev = device_get_binding(CONFIG_TEMP_NRF5_NAME);&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302848?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 12:28:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04e19c7a-cb0f-4984-8181-211dac166be7</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Hi Christian,&lt;/p&gt;
&lt;p&gt;Thank you for the fast reply. Could you please tell me how to populate &lt;code&gt;struct device&lt;/code&gt;* in your function call?&lt;/p&gt;
&lt;p&gt;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&lt;/p&gt;
&lt;p&gt;&lt;code&gt;temp_dev = device_get_binding(&amp;quot;TEMP_0&amp;quot;);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;David&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302842?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 10:13:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f040b75-52ba-4e5b-a383-4ab1ab0935e4</guid><dc:creator>Christian Holland</dc:creator><description>&lt;p&gt;Hi mate, I struggled with this one so I&amp;#39;ll help you out - this is how I did it in the end:&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s1"&gt;static&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="s1"&gt;int&lt;/span&gt;&lt;span class="s2"&gt; read_temperature(&lt;/span&gt;&lt;span class="s1"&gt;struct&lt;/span&gt;&lt;span class="s2"&gt; device *temp_dev,&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;struct&lt;/span&gt;&lt;span class="s2"&gt; sensor_value *float_val) {&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;const&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="s1"&gt;char&lt;/span&gt;&lt;span class="s2"&gt; *name = temp_dev-&amp;gt;name;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;struct&lt;/span&gt;&lt;span class="s2"&gt; sensor_value temp_val;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;int&lt;/span&gt;&lt;span class="s2"&gt; ret;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;ret = sensor_sample_fetch(temp_dev);&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s3"&gt;if&lt;/span&gt;&lt;span class="s2"&gt; (ret) {&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;printk(&lt;/span&gt;&lt;span class="s4"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s5"&gt;%s&lt;/span&gt;&lt;span class="s4"&gt;: I/O error: &lt;/span&gt;&lt;span class="s5"&gt;%d&lt;/span&gt;&lt;span class="s4"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s2"&gt;, name, ret);&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s3"&gt;return&lt;/span&gt;&lt;span class="s2"&gt; ret;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;ret = sensor_channel_get(temp_dev, SENSOR_CHAN_DIE_TEMP, &amp;amp;temp_val);&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s3"&gt;if&lt;/span&gt;&lt;span class="s2"&gt; (ret) {&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;printk(&lt;/span&gt;&lt;span class="s4"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s5"&gt;%s&lt;/span&gt;&lt;span class="s4"&gt;: can&amp;#39;t get data: &lt;/span&gt;&lt;span class="s5"&gt;%d&lt;/span&gt;&lt;span class="s4"&gt;&amp;quot;&lt;/span&gt;&lt;span class="s2"&gt;, name, ret);&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s3"&gt;return&lt;/span&gt;&lt;span class="s2"&gt; ret;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;code&gt;&lt;span class="s6"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s2"&gt;//printk(&amp;quot;%s: read %d.%d C\n&amp;quot;, name, temp_val.val1, temp_val.val2);&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;float_val-&amp;gt;val1 = temp_val.val1;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;float_val-&amp;gt;val2 = temp_val.val2;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;generic_data[&lt;/span&gt;&lt;span class="s4"&gt;3&lt;/span&gt;&lt;span class="s2"&gt;] = temp_val.val1;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;code&gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;code&gt;&lt;span class="s6"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="s2"&gt;return&lt;/span&gt;&lt;span class="s6"&gt; &lt;/span&gt;&lt;span class="s4"&gt;0&lt;/span&gt;&lt;span class="s6"&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;code&gt;&lt;span class="s2"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/302841?ContentTypeID=1</link><pubDate>Thu, 01 Apr 2021 09:47:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b63061f-4c76-49fb-bc1c-7038e89252e1</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Are there any news on this topic? I would be interested in the answer to the original question&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get die temperature on NRF52832 using Zephyr</title><link>https://devzone.nordicsemi.com/thread/227586?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2020 08:18:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b29eb44f-8978-489a-b1c7-b3af0470f859</guid><dc:creator>Simonr</dc:creator><description>&lt;div&gt;Hi&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;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&amp;#39;t offer technical support for the Zephyr RTOS on nRF52 as of yet.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Simon&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>