<?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>Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52464/battery-level-detect-in-nrf52832</link><description>Hi, 
 Does nRF52832 use normal ADC input to detect battery level (ex. AIN0, AIN1...)? or nRF52832 have other method to do this job? 
 Thank you, 
 Chianglin</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Sep 2019 14:40:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52464/battery-level-detect-in-nrf52832" /><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/212103?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 14:40:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d70f6e70-f7a4-4cde-bb31-7d6915630cce</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Thank you for your support.&lt;/p&gt;
&lt;p&gt;I will merge into my program and test it.&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/212021?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 11:08:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0cc77b7-72e0-40f6-94b8-89fbce7f918b</guid><dc:creator>awneil</dc:creator><description>[quote userid="34970" url="~/f/nordic-q-a/52464/battery-level-detect-in-nrf52832/211392"]I want to use two ADC at the same time[/quote]
&lt;p&gt;Hopefully it has become clear by now, but the nRF52832 only has &lt;em&gt;&lt;strong&gt;one&lt;/strong&gt; &lt;/em&gt;ADC.&lt;/p&gt;
&lt;p&gt;To measure multiple inputs, you have to multiplex them to the &lt;em&gt;&lt;strong&gt;one&lt;/strong&gt;&lt;/em&gt; ADC.&lt;/p&gt;
&lt;p&gt;See the block diagram in the Product Specification:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=3_1_0_36_1#saadc_overview"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=3_1_0_36_1#saadc_overview&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/212004?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 09:28:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d21a964-3725-4656-a22e-9d67022b7721</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you need a consistent sampling frequency for the sensor, then the simplest is to sample the battery also every time. This is demonstrated by this minimal modification to the SDK 15.3 SAADC example:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-060784e3f42d4b6e9b8f71f4b04bcda0/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Running the application () gives you this log output:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: SAADC HAL simple example started.
&amp;lt;info&amp;gt; app: ADC event number: 0
&amp;lt;info&amp;gt; app: Sensor reading: 6
&amp;lt;info&amp;gt; app: Battery reading: 626
&amp;lt;info&amp;gt; app: ADC event number: 1
&amp;lt;info&amp;gt; app: Sensor reading: 19
&amp;lt;info&amp;gt; app: Battery reading: 626
&amp;lt;info&amp;gt; app: ADC event number: 2
&amp;lt;info&amp;gt; app: Sensor reading: 22
&amp;lt;info&amp;gt; app: Battery reading: 627
&amp;lt;info&amp;gt; app: ADC event number: 3
...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that you can increase the sampling frequency by adjusting line 97, where you can also replace&amp;nbsp;nrf_drv_timer_ms_to_ticks() with&amp;nbsp;nrf_drv_timer_us_to_ticks() if you need to provide the sampling interval in microseconds.&lt;/p&gt;
&lt;p&gt;Alternatively, you can sample only the sensor most of the time, then us an app timer to reconfigure the saadc to sample the battery once in a while, before reverting to sampling only the sensor. This will probably be a more power-efficient way (at least if you don&amp;#39;t sample the battery often), but will potentially give you a short pause in the sensor sampling which may or may not be acceptable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211838?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 13:08:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:578caf2a-ec63-4cfb-a0b2-1936ddb30c35</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for your support.&lt;/p&gt;
&lt;p&gt;About your question.&lt;/p&gt;
&lt;p&gt;1. As your&amp;nbsp;description of previous mail, the sampling rate of battery don&amp;#39;t need very fast, but&amp;nbsp;糸he sampling frequency of the sensor is as fast as possible.&lt;/p&gt;
&lt;p&gt;2. Yes,&amp;nbsp;one/both should be sampled regularly.&lt;/p&gt;
&lt;p&gt;Thank you again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211807?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 12:19:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d5f15eb-96e5-4870-8f93-e82d695fc91e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, I can try to put together a simple example. But then it would be good if you can clarify a few things first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Should both the battery and sensor be sampled simultaneously all the time, or should one be sampled more often than the other?&lt;/li&gt;
&lt;li&gt;Should one/both be sampled regularly, or sampled by SW at arbitrary times?&lt;/li&gt;
&lt;li&gt;Any other info on what behavior you need?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211572?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 14:01:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6560d80-fcf0-4f15-bbd8-c1d1bc9554a5</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;According to your instructions, does follow source code is correct?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_init(void)
{
    ret_code_t err_code;

	// Modify ADC resolution
	nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
	saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;

	// Initialize ADC
	err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);

	// ---------- Initialize ADC for Pressure-Sensor ----------------
    nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
	channel_config.gain = NRF_SAADC_GAIN1_4;
	channel_config.reference = NRF_SAADC_REFERENCE_VDD4;

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

	// ---------- Initialize ADC for Battery detect ----------------
    nrf_saadc_channel_config_t config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);
    err_code = nrf_drv_saadc_channel_init(1, &amp;amp;config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_battery_adc_buf[0], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_battery_adc_buf[1], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;How can I modify&amp;nbsp;saadc_callback() function to read two different ADC channel?&lt;/p&gt;
&lt;p&gt;Would you please give me a &amp;ldquo;saadc_callback()&amp;quot; sample code?&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211538?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 12:28:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81ced291-ee7d-4657-a69a-7217446c44bd</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="chianglin"]System will crash when &amp;quot;second nrf_drv_saadc_init() execute&amp;quot;.[/quote]
&lt;p&gt;That is expected. You should only initialize the driver once unless you disable it in between (for instance to save power). So you should remove the second call to&amp;nbsp;nrf_drv_saadc_init(), and use a common event handler for both. If you sample either one or the other, you will know which it is based on what you just sampled. If you sample both at the same time, you will know based on the order. (sampling both at the same time may not be that useful since you probably don&amp;#39;t need battery information as often as you need sensor input).&lt;/p&gt;
[quote user="chianglin"]If I want to use two ADC at the same time, one for &amp;quot;ADC Sensor input&amp;quot;, and the other one for &amp;quot;Battery level detect&amp;quot;.&amp;nbsp; How can I modify following source code?[/quote]
&lt;p&gt;To sample both channels in consecutive order, just enable the second channel as well, and make sure the result buffer is a multiple of the number of channels. If you want to sample either one or the other, and both at a low rate, then it is most power-efficient to configure sampling of the first channel (sensor), do that, and then uninitialized the SAADC. Then do the same when it is time to sample the other channel (VDD).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211392?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 01:24:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4ca6ef6-3fec-4f35-88b8-530dd3a2c4e0</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If I want to use two ADC at the same time, one for &amp;quot;ADC Sensor input&amp;quot;, and the other one for &amp;quot;Battery level detect&amp;quot;.&amp;nbsp; How can I modify following source code?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_init(void)
{
    ret_code_t err_code;

	// ---------- Initialize ADC for Pressure-Sensor ----------------
	// 變更 ADC 的 bit 數
	nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
	saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;

    nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
    // 變更 ADC 倍率 &amp;amp; 參考電壓
	channel_config.gain = NRF_SAADC_GAIN1_4;
	channel_config.reference = NRF_SAADC_REFERENCE_VDD4;

	err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, saadc_Sensor_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

	// ---------- Initialize ADC for Battery detect ----------------
#if 1
    err_code = nrf_drv_saadc_init(NULL, saadc_Battery_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_saadc_channel_config_t config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);
    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_battery_adc_buf[0], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_battery_adc_buf[1], SAADC_SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
#endif
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;System will crash when &amp;quot;second nrf_drv_saadc_init() execute&amp;quot;.&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211313?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 13:57:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60881478-79bf-479c-bc8d-c5b6a8d8c40a</guid><dc:creator>Einar Thorsrud</dc:creator><description>[quote user="chianglin"]VDD is define in &amp;quot;H7&amp;quot; and &amp;quot;A7&amp;quot; pin of nRF52832, it is used as power input of MCU. Does it also can detect battery level?[/quote]
&lt;p&gt;Yes, but only if you have connected VDD directly to the battery, as mentionned in my initial reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211311?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 13:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88e0a008-660c-463d-a2da-bba920db6a20</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for your explain.&lt;/p&gt;
&lt;p&gt;VDD is define in &amp;quot;H7&amp;quot; and &amp;quot;A7&amp;quot; pin of nRF52832, it is used as power input of MCU. Does it also can detect battery level?&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211261?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 12:37:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:766d38e9-766e-4312-a68e-0de5505d380d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please refer to the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_proximity.html?cp=5_1_4_2_2_21"&gt;Proximity Application&lt;/a&gt;&amp;nbsp;example in SDK 15.3. There you can see how the SAADC driver is configured for VDD measurement in line 283-297 of&amp;nbsp; &amp;lt;SDK15.3&amp;gt;\examples\ble_peripheral\ble_app_proximity\main.c. You can refer to the other ADC related code in the file to see a complete example of battery measurement&amp;nbsp;(and even how to use the standard Bluetooth battery service if that is relevant).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211175?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 09:44:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fa67c4e-19f0-4cdb-b59d-6237566ce0d5</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If I don&amp;#39;t need get a&amp;nbsp;accurate battery level, then I can direct connect battery with Vcc pin. Does it correct?&lt;/p&gt;
&lt;p&gt;How to set PSEL register?&lt;/p&gt;
&lt;p&gt;Would you please give me a sample code?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Battery level detect in nRF52832</title><link>https://devzone.nordicsemi.com/thread/211120?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 07:48:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0165faf-2913-4fa8-8724-04c4437972a9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The SAADC on the nRF52 has a direct connection to VDD, so you do not need to use any of the external AIN pins if the battery is directly connected to VDD on the nRF. This is selected by setting the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=3_1_0_36_10_5#register.CH-0.PSELP"&gt;PSEL &lt;/a&gt;register to VDD.&lt;/p&gt;
&lt;p&gt;Note that measuring the battery voltage like this has a few disadvantages. For instance, the measurement operation will affect the measurement, since it is part of the circuit. You can minimize that effect by following &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52"&gt;these guidelines&lt;/a&gt;, but that requires you do use an external pin (AIN0,...) to do it. Even his approach gives quite course results though, so if you need very accurate battery data, the best option may be to use a dedicated battery gauge IC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>