<?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>Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87387/reading-battery-level-nrf52840</link><description>Hi 
 I want to measure the battery lithium, this battery is the principal source (3.7v 300mh), the maximum voltage is 4.2 when the charge is full, 
 i&amp;#39;m using this code for to read the analog input y calculate the battery level 
 this is for to init </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 05 May 2022 11:13:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87387/reading-battery-level-nrf52840" /><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/366422?ContentTypeID=1</link><pubDate>Thu, 05 May 2022 11:13:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2945157b-ff97-48ff-8596-f4172a9d8e93</guid><dc:creator>John12</dc:creator><description>&lt;p&gt;Thanks for your kind reply. I got it :D&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/366318?ContentTypeID=1</link><pubDate>Wed, 04 May 2022 16:31:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43a6ff4f-0f48-4fab-8752-6c048f2e6576</guid><dc:creator>Marcos Tadeo</dc:creator><description>&lt;p&gt;Hi john12&lt;/p&gt;
&lt;p&gt;in this line read and covert the analog input to bits , and pass the data to varaible &amp;quot;adc_val&amp;quot; i am using 10bits resolution&lt;/p&gt;
&lt;p&gt;nrfx_saadc_sample_convert(0,&amp;amp;adc_val);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;this is the equation to get the voltage value, multiplicate the adc_value * Vdd( The Vdd 3.3v), devide by 1024(10 bits resolution) *&amp;nbsp; your deviser voltage for example if you have R1=800k and R2=2M&lt;/p&gt;
&lt;p&gt;devide R2/R1 = 2M/800k = 2.5&amp;nbsp; this is the porpotion, you can see this&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52"&gt;https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;this line is wrong,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;valueVoltaje = (adc_val * 4.2f / 1024)*0.91;&lt;/p&gt;
&lt;p&gt;the power supply for micro nrf52 is 1.8v to 3.6v i am using 3.6v aprox, then your maximun voltage analog input is 3.3v&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;valueVoltaje = (adc_val * 3.6f / 1024)*2.5;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and this part&lt;/p&gt;
&lt;p&gt;porcentaje = (valueVoltaje/3.6f)*100;&lt;/p&gt;
&lt;p&gt;its for voltage battery percent&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;here I little tutorial about this example&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://youtu.be/HfuIPiBgTfg"&gt;https://youtu.be/HfuIPiBgTfg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;sorry , my English is not good xd&amp;nbsp;&lt;/p&gt;
&lt;p&gt;but&amp;nbsp;I hope to help you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/366087?ContentTypeID=1</link><pubDate>Wed, 04 May 2022 02:42:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:faf14adc-4162-4be0-91de-0104e655af41</guid><dc:creator>John12</dc:creator><description>&lt;p&gt;Hi Marcos,&lt;br /&gt;I&amp;#39;m buiding this application on nRF52833 as well. &lt;br /&gt;I started with this topic 1 days ago&lt;br /&gt;So Can you explain for me this piece of code ? Thanh you very much&lt;pre class="ui-code" data-mode="c_cpp"&gt;    while (1)
    {
      nrfx_saadc_sample_convert(0,&amp;amp;adc_val);
			
			valueVoltaje = (adc_val * 4.2f / 1024)*0.91;// 1.07  calculo del parametro a utilizar para captura de voltaje de la bateria
			porcentaje = (valueVoltaje/4.2f)*100;
	}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/365829?ContentTypeID=1</link><pubDate>Mon, 02 May 2022 15:13:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a821b980-7b18-4435-b3f8-17a4c7cf2414</guid><dc:creator>Marcos Tadeo</dc:creator><description>&lt;p&gt;oohh ok, nice!&lt;/p&gt;
&lt;p&gt;thank you very much&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/ketiljo"&gt;ketiljo&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;best reagrds&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/365753?ContentTypeID=1</link><pubDate>Mon, 02 May 2022 12:02:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5dfa097-2c9c-46b8-93dd-ab77dd1d7f23</guid><dc:creator>ketiljo</dc:creator><description>&lt;p&gt;You can only have VDD or the internal 0.6 V as a reference, there are no external references available, see&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to measure the battery voltage, you need to measure single ended.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/365623?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 15:03:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19c45105-a283-4cb8-8e2d-c8af26236c9a</guid><dc:creator>Marcos Tadeo</dc:creator><description>&lt;p&gt;Hi Ketiljo&lt;/p&gt;
&lt;p&gt;thank you for to response&lt;/p&gt;
&lt;p&gt;I have a question about external refence voltage, how can i do that?,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_init(void)
{
	ret_code_t err_code;
	nrf_saadc_channel_config_t channel_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);
	
  
	
	err_code = nrf_drv_saadc_init(NULL, saadc_callback_handler);
	APP_ERROR_CHECK(err_code);
	
	err_code = nrfx_saadc_channel_init(0,&amp;amp;channel_config);
	APP_ERROR_CHECK(err_code);
	
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;my reference voltage now is 3.3 but I need to change to 1.8 in vdd , I want to do a test with 1.8v&amp;nbsp;&lt;/p&gt;
&lt;p&gt;is single ended or diferential with ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);&lt;/p&gt;
&lt;p&gt;nrf_saadc_channel_config_t channel_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_VDD,NRF_SAADC_INPUT_AIN1);&lt;/p&gt;
&lt;p&gt;thank you and regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading Battery Level nrf52840</title><link>https://devzone.nordicsemi.com/thread/365310?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2022 07:35:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41fc18ae-7d09-40e1-b1d8-7f7283fcdf3d</guid><dc:creator>ketiljo</dc:creator><description>&lt;p&gt;Resistors this small will draw too much current. Take a look at this:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52"&gt;https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>