<?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>nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47271/nrf52-battery-measurement-4-aa-batteries</link><description>Hello, 
 
 I need to measure battery on my nrf52 beacon. My input voltage is 4*AA batteries(each 1.2V so in total 4.8V). The schematic provided by the hardware developer is as follows 
 
 
 
 
 Now I read few posts about battery measurements and looks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 May 2019 07:29:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47271/nrf52-battery-measurement-4-aa-batteries" /><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187782?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 07:29:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93c8c82f-aa47-4d7d-8be1-ad79b4fdbbe0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Yes. After all, you are not measuring the supply voltage directly, only the voltage over one of the resistors in the voltage decider. You need to calculate the input voltage to the voltage divider. You can do it this way:&lt;/p&gt;
&lt;p&gt;Vin = ((Vout)*(R1+R2))/R2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187569?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 14:50:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:062f0a13-9c34-48de-9ee8-434515cd8fbb</guid><dc:creator>Bilal</dc:creator><description>&lt;p&gt;Yes, my measurements are close to what you said, now we need to map our voltage divider measurement to input voltage?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187565?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 14:14:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ed83555-c19a-4e36-9bad-54efed114270</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you try using the internal reference instead of VDD? I would expect that to be more stable, even though you &lt;em&gt;must&lt;/em&gt; have a regulator in your power supply circuit since the battery power is too high.&lt;/p&gt;
&lt;p&gt;Then there is also the point that depending on your circuitry and battery etc the voltage will probably drop a bit when you do ADC sampling compared to when you measure on the battery when the nRF does not draw much current (if that is what you are ding). Therefor you should have a capacitor in the circuit as well, as described &lt;a href="https://devzone.nordicsemi.com/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Depending on what I have mentioned above, your result might not be that far from expected.&lt;/p&gt;
&lt;p&gt;The voltage out of the voltage divider in your case is&amp;nbsp;5.2 V / (470+110)*110 = 0.986 V.&lt;/p&gt;
&lt;p&gt;Then you put that into&lt;/p&gt;
&lt;p&gt;RESULT = [V(P) – V(N) ] * GAIN/REFERENCE * 2^(RESOLUTION - m)&lt;/p&gt;
&lt;p&gt;So for single ended it is:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;RESULT = V * GAIN/REFERENCE * 2^RESOLUTION&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And get something like:&lt;/p&gt;
&lt;p&gt;RESULT = 0.986 * 1 / 5 * 2^12 = 808.&lt;/p&gt;
&lt;p&gt;Is that&amp;nbsp;roughly the sample value you get?&lt;/p&gt;
&lt;p&gt;Then you swap around so that you solve for V you get back the same result:&lt;/p&gt;
&lt;p&gt;V = RESULT / (&lt;span&gt;GAIN/REFERENCE * 2^RESOLUTION&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;V =&amp;nbsp;808/(1 / 5 * 2^12) =&amp;nbsp;0.986&lt;/p&gt;
&lt;p&gt;Then you have to remember that this is the voltage you measure over R2 in the voltage divider, so you have to account for that as well, and find that the voltage you measure is 5.2 V in this example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187475?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 09:41:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd95258a-3417-4c0f-b2c5-6bada8cde46f</guid><dc:creator>Bilal</dc:creator><description>&lt;p&gt;So I took reference voltage , vdd/4 (my vdd is 3.3V), gain = 1/5 and resolution 12 bit, here is my initialization for it&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;err_code = nrf_drv_saadc_init(nullptr,saadc_callback);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN7);&lt;br /&gt; channel_config.gain = NRF_SAADC_GAIN1_5;&lt;br /&gt; channel_config.reference = NRF_SAADC_REFERENCE_VDD4;&lt;/p&gt;
&lt;p&gt;err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_12BIT);&lt;br /&gt; err_code = nrf_drv_saadc_buffer_convert(m_buffer, 1);&lt;/p&gt;
&lt;p&gt;while I convert it as follows:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;constexpr double REF_VOLTAGE_IN_VOLTS = 0.825; // Maximum Internal Reference Voltage&lt;br /&gt;constexpr double VOLTAGE_DIVIDER_IN_VOLTS = 0.2; //Internal voltage divider&lt;br /&gt;constexpr double ADC_RESOLUTION_12BIT = 4095;&lt;br /&gt;#define RESULT_IN_VOLTS(ADC_VALUE) (ADC_VALUE*REF_VOLTAGE_IN_VOLTS)/(VOLTAGE_DIVIDER_IN_VOLTS*ADC_RESOLUTION_12BIT)&lt;/p&gt;
&lt;p&gt;The measurement from my voltage divider is feeded to AIN7 but it measures 0.9V on the battery while my input is 5.2V and 0.7V when my input 4.5V. Can you suggest what am doing wrong in here&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187053?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 15:15:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:576de0a6-d4e2-431f-adfc-3974f7c8c3a6</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;nRF52832 &lt;strong&gt;Product Specification&lt;/strong&gt;, then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187052?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 15:14:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6108751c-df3c-448e-88fa-e7a97dafdecc</guid><dc:creator>Bilal</dc:creator><description>&lt;p&gt;nrf52832&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187051?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 15:09:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f803c62-2a29-4b09-baf8-c45cbf4bed18</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;You haven&amp;#39;t said what specific chip you are using.&lt;/p&gt;
&lt;p&gt;Whatever it is,&amp;nbsp;study the ADC chapter in its &lt;strong&gt;Product Specification&lt;/strong&gt; - that will tell you the options for gain, reference, etc - and you choose whatever is appropriate to the signal you&amp;#39;re measuring.&lt;/p&gt;
&lt;p&gt;You may also want to look at the ADC example in the SDK ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187049?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 15:05:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d37bf636-5a68-485c-a4b5-b638caacd443</guid><dc:creator>Bilal</dc:creator><description>&lt;p&gt;Thank You @cbd and @awneil.&amp;nbsp; So i just checked, apparently we have a voltage divider having R1 = 470k, R2 = 110k and capacitor = 1nf, we also feed the output to AIN7. So do we need to just start the adc pin and start sampling with configuration&amp;nbsp;NRF_ADC_CONFIG_REF_VBG&amp;nbsp; &amp;nbsp;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187044?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 14:49:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a12e45f-c731-4e53-ab6c-2396c3e924dd</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;I agree with awneil.&lt;/p&gt;
&lt;p&gt;I see on your circuit diagram that you are running your nRF52 at 3.3V.&lt;/p&gt;
&lt;p&gt;Although you can run the nRF52 on more than 3.3V, you can only allow an input to be 0.3V above that.&lt;/p&gt;
&lt;p&gt;If you wish to detect the battery voltage directly then you will need a divider of sorts to step down the voltage, but these tend to impose their own problems due to leakage currents.&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;These are all points that your hardware engineer should take into account&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;So you may look at measuring a voltage that has a maximum of 2.4V say and then internally calculate that as 4.8V&lt;/p&gt;
&lt;p&gt;Alternatively you may wish to just measure the voltage on the MCU supply line using one of your Analogue Inputs (AIN#), but that will limit your maximum value to 3.3V.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187032?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 14:29:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2aa8acaf-cbe0-417c-823e-867673cc4909</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Of course - the whole thing involves both!&lt;/p&gt;
&lt;p&gt;But it should be the hardware designer&amp;#39;s job to feed an appropriate signal to a pin on the chip.&lt;/p&gt;
&lt;p&gt;You need a voltage &lt;em&gt;divider&lt;/em&gt; - not a regulator.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187028?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 14:24:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a9eb633-ca9a-4aba-a4a4-ae439a6b809c</guid><dc:creator>Bilal</dc:creator><description>&lt;p&gt;I think it involves both, hardware and software. As far as I know , there must be some kind of voltage regulator used to bring down voltage to 3V. Can we use that to do our battery measurements?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 Battery Measurement 4*AA batteries</title><link>https://devzone.nordicsemi.com/thread/187012?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 14:02:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbb785e5-8ff4-4cd2-a88e-842d22e2ee20</guid><dc:creator>awneil</dc:creator><description>[quote userid="71338" url="~/f/nordic-q-a/47271/nrf52-battery-measurement-4-aa-batteries"] I read few posts about battery measurements and looks like I need to add some additional hardware[/quote]
&lt;p&gt;Yes - that should be clear from those posts!&lt;/p&gt;
&lt;p&gt;Surely, this is something that your hardware developer should be doing? It is a hardware question!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>