<?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>Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96407/cant-build-zephyr-battery-example</link><description>Hi, 
 I was trying to build the zephyr battery example Battery Voltage Measurement — Zephyr Project Documentation (nordicsemi.com) . But when I was building the project, it raises an error like this: 
 note: in expansion of macro &amp;#39;DEVICE_DT_GET&amp;#39; 
 78</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Feb 2023 15:23:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96407/cant-build-zephyr-battery-example" /><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408951?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 15:23:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a52649f-3dc4-48a4-979f-1973947cf4e0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/behicmv"&gt;BehicMV&lt;/a&gt;&amp;nbsp;, are there any spaces or special characters in your project path? If there is, then that may explain why the build is failing on your system and not the others.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408772?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 09:05:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:972fbb54-5827-4c32-88de-09142887dd39</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Ok, not sure what&amp;rsquo;s causing the issues for him, but it&amp;rsquo;s got something to do with how he&amp;rsquo;s set up his development environment.&lt;/p&gt;
&lt;p&gt;Try running a West update from within VSC via:&lt;/p&gt;
&lt;p&gt;View-&amp;gt;Command Palette-&amp;gt;nRF Connect:West Update and then try to build the code on his machine again via a pristine build&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408743?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 07:34:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7118cff9-21cb-4194-9eee-e9ac88515527</guid><dc:creator>sencery</dc:creator><description>&lt;p&gt;Hello Mike.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BehicMV is a very close friend of mine who I am currently co-working with in the project that he is trying to solve the problem which is connected to this ticket.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Because of the fact that you have mentioned the code builds for you OK, without any problems, we have tried to build it from my computer (we were trying to build the code from his computer until now). Everything worked fine, and I just wanted to ask the reason behind this weird issue.&lt;/p&gt;
&lt;p&gt;&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: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408737?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 07:02:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfabb563-964d-467c-8391-3ba22797c56f</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;I tried your advice. Here are the results:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/7206.Screenshot_5F00_13.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408735?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 06:21:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0d96005-36b7-42c7-af47-76c3deb9132b</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;OK, your code builds OK for me - no errors.&lt;/p&gt;
&lt;p&gt;Try deleting your build folder within Windows Explorer (just delete the &amp;#39;build&amp;quot; subfolder under your project directory), then doing a pristine build in VSC, via:&lt;/p&gt;
&lt;p&gt;View-&amp;gt;Command Palette-&amp;gt;nRF Connect:Pristine Build&lt;/p&gt;
&lt;p&gt;Let me know if that fixes things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408731?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 05:34:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60cdc3d2-df81-417b-875f-0291ce09575a</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;Thank you for your answer Mike. I changed my overlay file as you said. But the error occured again.(&lt;span&gt;note: in expansion of macro &amp;#39;DEVICE_DT_GET&amp;#39; undefined&lt;/span&gt;). Then, I downloaded the zip and tried to build again. But a cmake error occured(Configuration incomplete). I&amp;#39; ve attached to you my code as zip.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/battery_5F00_BehicMV.zip"&gt;devzone.nordicsemi.com/.../battery_5F00_BehicMV.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408701?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 21:19:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e6abcf1-7cc1-453d-9dc4-97f58976b1a3</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;No worries. I&amp;rsquo;m GMT+10, so I&amp;rsquo;ve got my whole day ahead of me :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;OK, so I grabbed the example code from ...v2.2.0/zephyr/samples/boards/nrf/battery and added the overlay file as described&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.2.0/zephyr/samples/boards/nrf/battery/README.html"&gt;here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is what my overlay file looks like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
    zephyr,user {
       io-channels = &amp;lt;&amp;amp;adc 4&amp;gt;;
    };
 };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That all builds without errors if I use the&amp;nbsp;nrf52dk_nrf52832 as my target (that&amp;#39;s the DK I am using)&lt;/p&gt;
&lt;p&gt;However, if I try and build it for the nrf52840dk_nrf52840, then I see the same error you are getting.&lt;/p&gt;
&lt;p&gt;However, if I add the voltage divider version of the vbatt node to my overlay file instead, like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {

    vbatt {
        compatible = &amp;quot;voltage-divider&amp;quot;;
        io-channels = &amp;lt;&amp;amp;adc 0&amp;gt;;
        output-ohms = &amp;lt;47000&amp;gt;;
        full-ohms = &amp;lt;(100000 + 47000)&amp;gt;;
        power-gpios = &amp;lt;&amp;amp;gpio0 30 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)&amp;gt;;
        };
    };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then I can get it to build without errors for the&amp;nbsp;&lt;span&gt;nrf52840dk_nrf52840.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In my application, I&amp;#39;m actually using a voltage divider to step the voltage down (so, I&amp;#39;m measuring the battery voltage across a 47K resistor, which is in series with a 100K resistor, hence the values above for ouput-ohms and full-ohm), and I&amp;#39;m also enabling the battery voltage to the relevant GPIO using an arrangement of MOSFETs (means I can keep quiescent current down).&amp;nbsp; I&amp;#39;m using P0.30 as my enable signal, hence the value for power-gpios above where I am setting this to Pin 30.&amp;nbsp; The flags indicate that I need to set it high to activate it, and that its normally pulled low when I&amp;#39;m not driving that GPIO via firmware.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve attached the code here as a .zip file so you can see what I&amp;#39;ve done&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hope that helps sort out your issue&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Mike&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/battery_5F00_nordic.zip"&gt;devzone.nordicsemi.com/.../battery_5F00_nordic.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408699?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 21:01:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc7b12d-eb62-48d8-8a7e-f02c9ea6cbc2</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;Okay thank you mike but my local time is 00:00. So I can reply to you aproximately 8.5 hours later. Standby...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408698?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 21:00:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0eba1592-40e9-4b18-a9c9-19acf90f3be3</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;I&amp;#39; get back to work aproximately 8 hours later due to the night comes in. :D But I&amp;#39; ll delete the .dts and try again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408697?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 20:59:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8cc32657-24e9-4247-8c28-0d0039399ee2</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Ok, give me a few hours. I&amp;rsquo;ll dig up my code and add it here.&lt;/p&gt;
&lt;p&gt;There were some significant changes I needed to make to my original code when I upgraded from V2.0.0 to V2.2.0, and I seem to recall this error popping up in that process.&lt;/p&gt;
&lt;p&gt;if you can, try zipping up all your files and add them here and I&amp;rsquo;ll see if I can build them on my setup. I&amp;rsquo;m using VSC and V2.2.0 of NCS, but am using the nRF52832, but that shouldn&amp;rsquo;t make any real difference&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408695?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 20:54:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de0cca4f-5c91-4994-8dc6-0eca4e70b531</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;It is v2.2.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408684?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 18:23:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0feb687-fd10-4fc0-8012-bfabd47c60d6</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;What version of the Nordic nRF Connect SDK are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408614?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 14:45:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f79625d6-fe07-49e8-9539-42ccf2f6ad30</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Delete the .dts. you are not expected to create it yourself as you can see here&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/topic/devicetree/"&gt;https://academy.nordicsemi.com/topic/devicetree/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408609?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 14:32:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd483e36-6be4-4cb3-b149-225029562ea1</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, I&amp;#39;ve created my .dts file myself. I have made the changes you&amp;#39;ve said but I still get the same error. I am sharing my overlay dts and overlay files and the error I am getting below. Thanks for your time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675780204407v1.png_2D00_640x480.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675780228665v2.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675780359055v3.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408602?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 14:25:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de0cdb1b-79d4-439e-945d-5df6e62f5415</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1. Did you create your nrf52840dk.dts yourself?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
   zephyr,user {
      io-channels = &amp;lt;&amp;amp;adc 4&amp;gt;;
   };
};&lt;/pre&gt;?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2. Rename the .overlay to nrf52840dk_nrf52840.overlay&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408591?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 14:05:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e7f02ca-b40d-4c71-8404-1d902f95531a</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;Also my file structure like this(dts file is empty):&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675778687124v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408567?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 13:27:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aba00bc7-a0b9-4be3-93f5-e2c561691570</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675776332342v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is the way which I have tried. I still can not build. This is the last step for my school project and I am extremely close to the end, however if I can not solve this step I won&amp;#39;t be able to finish before its due date. So, any help would be highly appreciated. Thanks a lot in advance!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408562?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 13:19:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b879419-d407-48ae-869f-fe62f2ef5196</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;Okay thank you&lt;/p&gt;
&lt;p&gt;But do you know the codes in necessary overlay or dts files? It must be static. But there is no open-source that built zephyr/battery.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408535?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 12:20:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6baf0847-277d-4480-af0f-406fd10a28a4</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;I would recommend going through our tutorial on decacadamy to learn more about it&lt;/p&gt;
&lt;p&gt;&lt;a href="https://academy.nordicsemi.com/lessons/lesson-3-elements-of-an-nrf-connect-sdk-application/"&gt;https://academy.nordicsemi.com/lessons/lesson-3-elements-of-an-nrf-connect-sdk-application/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408520?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 11:38:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae37ddf4-cf4b-446c-8636-73cb0a906299</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;Also, I couldnt find any &amp;quot;overlay files&amp;quot; what are they? they dont exist&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408495?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 10:31:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:812b214d-4cae-4b23-b7bf-15768f51a4f0</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;I tried to build relative to instructions, but unfortunately I have no such &amp;quot;west&amp;quot; command.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, I have an alternative code that measures the voltage. But this code also does not work (I couldnt build). What should I do?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;nrf.h&amp;gt;
#include &amp;lt;nrfx_saadc.h&amp;gt;
#include &amp;lt;nrfx.h&amp;gt;
int main(void)
{
    // Configure the ADC to use the 0.13 pin as the input channel
    NRF_SAADC-&amp;gt;CH[0].PSELP = 13; // Pin 0.13
    NRF_SAADC-&amp;gt;CH[0].PSELN = 0xFFFFFFFF; // Not using negative input

    // Configure the ADC&amp;#39;s reference voltage
    NRF_SAADC-&amp;gt;REF = SAADC_REF_INTERNAL;

    // Start the ADC conversion
    NRF_SAADC-&amp;gt;TASKS_START = 1;

    // Wait for the ADC conversion to complete
    while (NRF_SAADC-&amp;gt;EVENTS_END == 0) {}

    // Read the ADC result
    uint16_t result = NRF_SAADC-&amp;gt;RESULT.RESULT;

    // Convert the ADC result to a voltage value
    float voltage = (float)result / (1 &amp;lt;&amp;lt; 12) * 1.2;

    // Convert the voltage value to a battery level
    float battery_level = voltage / 4.0 * 100.0;

    // Print the battery level to the console
    printf(&amp;quot;Battery level: %.2f%%\n&amp;quot;, battery_level);

    return 0;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675766201471v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408482?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 09:33:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f177e2f-0d56-465d-b670-f3db13ef2379</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately yes, as the link you posted the dts of the nrf52840 does not contain the vbatt and therefor you have to do as the link you posted describes.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408471?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 08:55:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9c6f19c-9169-43fa-89bf-9ef105d8517a</guid><dc:creator>BehicMV</dc:creator><description>&lt;p&gt;I built the code in VS Code.&lt;/p&gt;
&lt;p&gt;I simply created a new application and searched the &amp;quot;battery&amp;quot;. Then I configurated the build for &amp;quot;nRF52840dk&amp;quot; and built the app. Was that wrong?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cant build zephyr battery example</title><link>https://devzone.nordicsemi.com/thread/408456?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 08:27:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb16709d-e334-479f-bae1-90b45832bbad</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you add the overlay file as described in&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.2.0/zephyr/samples/boards/nrf/battery/README.html#building-and-running"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.2.0/zephyr/samples/boards/nrf/battery/README.html#building-and-running&lt;/a&gt;&amp;nbsp;? My project builds if I add it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>