<?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>BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91720/ble-mesh-device-entering-sleep-low-power-mode-in-nrf-connect-sdk</link><description>Hi. 
 I am working on a low power BLE mesh device, based on the nRF52832, that uses vendor models. By default it consumes about 7mA. 
 Aside from that, I have been able to get the power consumption down to 3uA in a low power mode, in another (non BLE</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 May 2023 06:51:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91720/ble-mesh-device-entering-sleep-low-power-mode-in-nrf-connect-sdk" /><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/428049?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 06:51:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a95d102-ead3-4585-ad65-6e5a71b11a20</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;You can have a time based wake-up or a GPIO based wake-up. There can be more but these two are the only ones I have tested.&lt;/p&gt;
&lt;p&gt;To setup the controller for sleep, you can have something like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void set_pm_state()
{
    struct pm_state_info info =
    {
        .exit_latency_us  = 0,
        .min_residency_us = 0,
        .state            = PM_STATE_SUSPEND_TO_RAM,
        .substate_id      = 0,
    };
    pm_state_force(CPU_ID, &amp;amp;info);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then whenever you have to put it to sleep, you can have this code in a function&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void pre_sleep()
{
    const struct device *cons = device_get_binding(CONSOLE_LABEL); // get UART device
    pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);          // turn off UART
    bt_mesh_prov_disable(BT_MESH_PROV_GATT | BT_MESH_PROV_ADV);    // disabling provisioning bearer
    bt_mesh_suspend();                                             // turn off mesh
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For sleep, use&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;k_sleep(milliseconds) // for specified time
k_sleep(K_FOREVER)    // for sleeping without a timeout&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And then after waking up&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void post_sleep()
{
    bt_mesh_resume();                                              // turn on mesh
    bt_mesh_prov_enable(BT_MESH_PROV_GATT | BT_MESH_PROV_ADV);     // enabling provisioning bearer
    const struct device *cons = device_get_binding(CONSOLE_LABEL); // get UART device
    pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);           // turn off UART
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps.&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/428047?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 06:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b7138f4-f1fd-46c6-91bd-8aa8051f7612</guid><dc:creator>Dker19</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/usmanmehmood55"&gt;usmanmehmood55&lt;/a&gt;&amp;nbsp;Okay, So how will it will be wakeup from that state? any specific code is required for that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/428044?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 06:33:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a15ff822-5c80-4bd8-a597-41a12aa5f1ff</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;The code that I provided in the question is in fact using &lt;strong&gt;PM_STATE_SUSPEND_TO_RAM&lt;/strong&gt;, so just copy-paste it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/428030?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 05:39:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a62c7c89-ebe7-4a15-a3b1-1afda7179072</guid><dc:creator>Dker19</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/usmanmehmood55"&gt;usmanmehmood55&lt;/a&gt;&amp;nbsp;Thanks for reply!!&lt;/p&gt;
&lt;p&gt;Do you have some sample code by using &lt;strong&gt;PM_STATE_SUSPEND_TO_RAM&lt;/strong&gt;, &lt;strong&gt;PM_STATE_SUSPEND_TO_DISK&lt;/strong&gt;? I don&amp;#39;t want to use&amp;nbsp; PM_STATE_STANDBY.&lt;/p&gt;
&lt;p&gt;Can you please guide me here? I am working on the nrf5340dk board.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/428007?ContentTypeID=1</link><pubDate>Mon, 29 May 2023 17:25:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc19d826-117a-40e8-948e-f3877c835831</guid><dc:creator>usmanmehmood55</dc:creator><description>[quote userid="125979" url="~/f/nordic-q-a/91720/ble-mesh-device-entering-sleep-low-power-mode-in-nrf-connect-sdk/428005"]Can you please enlighten why there are different modes and When to use them? like,&amp;nbsp;PM_STATE_RUNTIME_IDLE,&amp;nbsp;PM_STATE_SUSPEND_TO_IDLE,&amp;nbsp;PM_STATE_STANDBY and&amp;nbsp;[/quote]
&lt;p&gt;I&amp;#39;m not really sure about the other states. From what I remember,&amp;nbsp;&lt;span&gt;PM_STATE_SUSPEND_TO_RAM,&amp;nbsp;PM_STATE_SUSPEND_TO_DISK, and&amp;nbsp;PM_STATE_SOFT_OFF had the same power consumption during sleep mode for the nRF52832. For other controllers I don&amp;#39;t know.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Not to mention I measured these&amp;nbsp;9 months ago, so any updates in the SDK might have changed the power consumption or the three modes might not be the same anymore.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="125979" url="~/f/nordic-q-a/91720/ble-mesh-device-entering-sleep-low-power-mode-in-nrf-connect-sdk/428005"]Also is there any best state other than PM_STATE_SOFT_OFF which help my device to save more power without losing its context?[/quote]
&lt;p&gt;I don&amp;#39;t think so.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="125979" url="~/f/nordic-q-a/91720/ble-mesh-device-entering-sleep-low-power-mode-in-nrf-connect-sdk/428005"]Do I just need to disable/suspend the resources that are taking more power,&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;this will save the power consumption of the battery&lt;/strong&gt;. CPU will automatically go into sleep mode?[/quote]
&lt;p&gt;Not a 100% sure about this either, but from what I noticed, if no active thread is running (or if every thread is performing `k_sleep(...)` and the appropriate power management mode is selected, the CPU will be in sleep mode.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/428005?ContentTypeID=1</link><pubDate>Mon, 29 May 2023 16:44:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc10027c-f836-4571-a9dd-8ceea17ae4b7</guid><dc:creator>Dker19</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/usmanmehmood55"&gt;usmanmehmood55&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I required the device should be run in low power mode when there is no work to do. so I gone through the state.h and found that there are different states. So I choose&amp;nbsp;&amp;nbsp;PM_STATE_RUNTIME_IDLE or PM_STATE_SUSPEND_TO_IDLE so just curious like if I select one of them then on some event how to wakeup the device to a normal state.&lt;/p&gt;
&lt;p&gt;Also is there any best state other than PM_STATE_SOFT_OFF which help my device to save more power without losing its context?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Do I just need to disable/suspend the resources that are taking more power,&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;this will save the power consumption of the battery&lt;/strong&gt;. CPU will automatically go into sleep mode?&lt;/p&gt;
&lt;p&gt;Can you please enlighten why there are different modes and When to use them? like,&amp;nbsp;PM_STATE_RUNTIME_IDLE,&amp;nbsp;PM_STATE_SUSPEND_TO_IDLE,&amp;nbsp;PM_STATE_STANDBY and&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;PM_STATE_SUSPEND_TO_RAM.&lt;br /&gt;Also how to use them?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Do&amp;nbsp;I&amp;nbsp;need any power state to set other than&amp;nbsp;&lt;span&gt;PM_STATE_SOFT_OFF?&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/389200?ContentTypeID=1</link><pubDate>Tue, 04 Oct 2022 12:23:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43b461a5-6680-4855-ae85-ffd9b93352e9</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thank you for sharing the solution.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Br,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/389195?ContentTypeID=1</link><pubDate>Tue, 04 Oct 2022 12:12:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0bb4b4a-11a9-4ded-a37a-ba871e7c425e</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/joakim_2d00_jakobsen"&gt;Joakim Jakobsen&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I actually did find the solution to this. I achieved it by first turning off the UART, then provisioning bearers, and then mesh.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;const struct device *cons = device_get_binding(CONSOLE_LABEL); // get UART device
pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);          // turn off UART
bt_mesh_prov_disable(BT_MESH_PROV_GATT | BT_MESH_PROV_ADV);    // disabling provisioning bearer
bt_mesh_suspend();                                             // turn off mesh&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And then turn it back on using the opposite statements to these. Works like a charm.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE mesh device entering sleep / low power mode in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/388636?ContentTypeID=1</link><pubDate>Thu, 29 Sep 2022 18:50:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3db5fcaf-3055-492a-bb65-ab3e84e479bc</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I apologize that this was left unanswered.&lt;/p&gt;
&lt;p&gt;Do you still need assistance on this? Or did you find the answer to your questions?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Br, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>