<?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>Zephyr NRF battery example on nrf52840dk</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109601/zephyr-nrf-battery-example-on-nrf52840dk</link><description>Hello 
 I try to adjust the example from the ncs 2.6.0 SDK to work on the nrf52840 dk. For this I created nrf52840dk_nrf52840.overlay: 
 I use P0.30 to power the voltage divider (not yet connected) and P0.31 as vbatt input with 100kOhms to GND on the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Mar 2024 18:15:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109601/zephyr-nrf-battery-example-on-nrf52840dk" /><item><title>RE: Zephyr NRF battery example on nrf52840dk</title><link>https://devzone.nordicsemi.com/thread/476010?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2024 18:15:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7585e646-5911-461a-8e1a-72feaace3a55</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi BarneyH,&lt;/p&gt;
&lt;p&gt;Good to know you figured it all out. I assume the 1199mV saturation comes from&amp;nbsp;a modified battery point level struct in that sample&amp;#39;s &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.5.99-ncs1/samples/boards/nrf/battery/src/main.c#L16-L32"&gt;main.c,&lt;/a&gt;&amp;nbsp;then.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please feel free to close this ticket at your convenience. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NRF battery example on nrf52840dk</title><link>https://devzone.nordicsemi.com/thread/475845?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2024 09:35:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:370942b2-bcbe-42e3-a9a0-f8c5c19914aa</guid><dc:creator>BarneyH</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;Thank you for your detailed reply.&lt;/p&gt;
&lt;p&gt;I copied the sample from zephyr/samples/boards/nrf/battery when creating a new application within vscode and can confirm now for the next person, that it works with the nrf52840 dk with the above overlay file and a simple voltage divider hooked up to AIN7.&lt;/p&gt;
&lt;p&gt;To solve the &amp;quot;saturation issue above&amp;quot; the key was to set the gain to 1/6 with #define BATTERY_ADC_GAIN ADC_GAIN_1_6 which I think it is by default but I might have messed it up in some initial testing, so sorry to bother you for this.&lt;/p&gt;
&lt;p&gt;Thank you again and have a great day&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NRF battery example on nrf52840dk</title><link>https://devzone.nordicsemi.com/thread/475756?ContentTypeID=1</link><pubDate>Mon, 25 Mar 2024 20:57:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a71e84ec-f6a2-4b31-a927-69dfb8585519</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi BarneyH,&lt;/p&gt;
&lt;p&gt;The SAADC on the nRF52840 can only measure voltage within a range, from 0 to an upper limit. The upper limit can be configured by adjusting gain setting or choose a different reference voltage. I am guessing this is why you see the saturating kind of behavior.&lt;/p&gt;
&lt;p&gt;You can find more details about the SAADC range in the documentation:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html?cp=5_0_0_5_22_1#unique_926836493"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html?cp=5_0_0_5_22_1#unique_926836493&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What doesn&amp;#39;t make sense to me is why you read 1199mV when you meet the threshold,&amp;nbsp;why that exact value. If we dived into the driver implementation, I think&amp;nbsp;we will find out.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t remember the Zephyr ADC driver implementation by heart, and there are a few different battery samples around. If you want me to dive further with you, could you please give me the full path to the sample, and I can try to&amp;nbsp;see what could be wrong.&lt;/p&gt;
&lt;p&gt;By the way, the nRF52840 doesn&amp;#39;t have a voltage divider. Did you&amp;nbsp;make your own physical divider and connect it to AIN7?&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>