<?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 do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8010/how-do-i-measure-battery-level-on-an-nrf51422-without-external-components</link><description>I have a custom PCB with an nrf51422 powered by a coin cell battery. The EE who designed the board assured me that the battery voltage could be measured internally through the ADC. That EE is now tied up and cannot help. 
 What is the proper method for</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 May 2017 13:50:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8010/how-do-i-measure-battery-level-on-an-nrf51422-without-external-components" /><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28693?ContentTypeID=1</link><pubDate>Tue, 30 May 2017 13:50:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec0655d0-4b2e-4b6f-bc87-03bc19abf7c0</guid><dc:creator>Nero</dc:creator><description>&lt;p&gt;Hello ,How Can I use this program with SDK 12&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28692?ContentTypeID=1</link><pubDate>Sun, 27 Sep 2015 00:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f65b36b5-d9f6-4fb5-86db-ef3a5bc57671</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;pre&gt;&lt;code&gt;#define VBAT_MAX_IN_MV                  3000

uint8_t battery_level_get(void)
{
// Configure ADC
NRF_ADC-&amp;gt;CONFIG     = (ADC_CONFIG_RES_8bit                        &amp;lt;&amp;lt; ADC_CONFIG_RES_Pos)     |
                      (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling &amp;lt;&amp;lt; ADC_CONFIG_INPSEL_Pos)  |
                      (ADC_CONFIG_REFSEL_VBG                      &amp;lt;&amp;lt; ADC_CONFIG_REFSEL_Pos)  |
                      (ADC_CONFIG_PSEL_Disabled                   &amp;lt;&amp;lt; ADC_CONFIG_PSEL_Pos)    |
                      (ADC_CONFIG_EXTREFSEL_None                  &amp;lt;&amp;lt; ADC_CONFIG_EXTREFSEL_Pos);
NRF_ADC-&amp;gt;EVENTS_END = 0;
NRF_ADC-&amp;gt;ENABLE     = ADC_ENABLE_ENABLE_Enabled;

NRF_ADC-&amp;gt;EVENTS_END  = 0;    // Stop any running conversions.
NRF_ADC-&amp;gt;TASKS_START = 1;

while (!NRF_ADC-&amp;gt;EVENTS_END)
{
}

uint16_t vbg_in_mv = 1200;
uint8_t adc_max = 255;
uint16_t vbat_current_in_mv = (NRF_ADC-&amp;gt;RESULT * 3 * vbg_in_mv) / adc_max;

NRF_ADC-&amp;gt;EVENTS_END     = 0;
NRF_ADC-&amp;gt;TASKS_STOP     = 1;

return (uint8_t) ((vbat_current_in_mv * 100) / VBAT_MAX_IN_MV);
       }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the only thing you will change is VBAT_MAX_IN_MV   as it depends on the battery max voltage level, it uses the bandgap voltage as it will be a constant ref whatever the value of vcc &amp;amp; scale vcc down to be withen 0 to bandgap voltage then it measure the battery level &amp;amp; refer it as percentage of the maximum voltage&lt;/p&gt;
&lt;p&gt;try it, I tried it &amp;amp; it works fine with me&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28691?ContentTypeID=1</link><pubDate>Sat, 26 Sep 2015 22:24:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0d3f20f-69b4-40f4-8e69-93b9f6c18909</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;I found how to use the adc to measure the vcc but I face some problems, when I finish I&amp;#39;ll put the code in an answer comment
thanks for your great advice&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28690?ContentTypeID=1</link><pubDate>Sat, 19 Sep 2015 01:17:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89dc3faf-aa23-4ce5-b9b4-42be2c7cb2c9</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;sure there are 8 add channels and about 30 i/o you can use.  I have applications that 3 adc at the same time, other 20 i/o at the same time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28689?ContentTypeID=1</link><pubDate>Fri, 18 Sep 2015 23:18:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd7b0af5-1ba9-4503-911d-f72a8b26f457</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;can I use the ADC to sense the battery &amp;amp; to wake up the system on the same application ? ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28687?ContentTypeID=1</link><pubDate>Sun, 05 Jul 2015 18:46:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:373c98dc-0e2f-4822-9d8a-3207041c2b77</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;look at the adc_simple example in peripheral folder.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I measure battery level on an Nrf51422 without external components?</title><link>https://devzone.nordicsemi.com/thread/28688?ContentTypeID=1</link><pubDate>Sun, 05 Jul 2015 03:04:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c028dba6-07ae-492e-84aa-a6f497232d53</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;There is no addition hardware require.  You need to use the ADC and configure it to sense the VCC.  This all done pragmatically.  There are example code in the SDK.  I don&amp;#39;t recall which one.  Browse through all the examples, you&amp;#39;ll find it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>