<?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>Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12794/redbear-ble-nano-cr2450-battery-level</link><description>Hello, 
 I&amp;#39;m powering a Readbear BLE nano using a CR2450 coin cell battery. The firmware application is written using mbed. How can I measure the battery level of the CR2450 over time using the Nordic mbed API and libraries? 
 Thanks,
Chris</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 30 Mar 2016 08:33:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12794/redbear-ble-nano-cr2450-battery-level" /><item><title>RE: Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/thread/48630?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2016 08:33:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43c389ed-0580-4188-ae6c-b6c6a1d7541b</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;The first one is more or less the same, the second one also except for that it does the initialization (adc_init) every time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/thread/48629?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2016 01:57:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ee01f48-da23-4864-bf26-c9f070535af9</guid><dc:creator>Chris Bick</dc:creator><description>&lt;p&gt;I found a couple examples that are similar to yours.  Your version seems simpler. I&amp;#39;m not sure which one to use.  They are all very similar. Which one do you think would work the best?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.mbed.org/users/MarceloSalazar/notebook/measuring-battery-voltage-with-nordic-nrf51x/"&gt;developer.mbed.org/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.mbed.org/users/kenjiArai/code/nRF51_Vdd/"&gt;developer.mbed.org/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/thread/48628?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 14:29:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7add586-ae92-4b3d-b721-ac965966fa18</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;It looks from &lt;a href="https://devzone.nordicsemi.com/question/70065/mbed-what-exactly-does-the-return-value-of-analoginread_u16-means/"&gt;here&lt;/a&gt; and &lt;a href="https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/analogin_api.c"&gt;here&lt;/a&gt; that the analogIn API can only be configured to use the ADC input pins and reference VDD 1/3 prescaler. I would recommend to make your own init and read function with VBG reference and VDD/3 input:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void adc_init()
{
    NRF_ADC-&amp;gt;ENABLE = ADC_ENABLE_ENABLE_Enabled;
    NRF_ADC-&amp;gt;CONFIG = (ADC_CONFIG_RES_10bit &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);
}

uint16_t adc_read()
{
    NRF_ADC-&amp;gt;EVENTS_END  = 0;
    NRF_ADC-&amp;gt;TASKS_START = 1;

    while (!NRF_ADC-&amp;gt;EVENTS_END) {
    }

    return (uint16_t)NRF_ADC-&amp;gt;RESULT; // 10 bit
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Correct me if some of this is wrong as I did not test it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/thread/48627?ContentTypeID=1</link><pubDate>Fri, 25 Mar 2016 19:20:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6530cca3-96ea-4b42-b444-bec70df40f95</guid><dc:creator>wlgrd</dc:creator><description>&lt;p&gt;I guess there should be API calls for using the ADC in mbed as well (I&amp;#39;ve never used it though). Using a divider that yields below 2.5V when battery is at 3V should be sufficient. So by just using the ADC on the divided battery voltage every now and then should suffice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/thread/48626?ContentTypeID=1</link><pubDate>Fri, 25 Mar 2016 19:16:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec6b5e92-bcf8-4edf-b46c-846075074a9b</guid><dc:creator>Chris Bick</dc:creator><description>&lt;p&gt;There&amp;#39;s a API in the Nordic SDK to measure battery voltage.  See &lt;a href="https://devzone.nordicsemi.com/question/990/how-to-measure-lithium-battery-voltage/"&gt;here&lt;/a&gt; using a voltage divider, but how would I do this using the mbed APIs?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Redbear BLE nano / CR2450 / Battery level</title><link>https://devzone.nordicsemi.com/thread/48625?ContentTypeID=1</link><pubDate>Fri, 25 Mar 2016 18:55:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da7175b6-101d-40ce-8731-4e2290b30c85</guid><dc:creator>wlgrd</dc:creator><description>&lt;p&gt;I&amp;#39;ve never heard of any API capable of providing such features. I firmly believe you have to measure the hardware using an amp meter/scope or current analyzer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>