BLE Mesh Deep Sleep and RTC Setup

Hi,

I am using Mesh of 30 nodes with avg Current Consumption 6mA and 2mA in sleep mode(by calling k_sleeps) , timer is 1s timer is running to keep Real Time incremented.

Want to achieve Deep Sleep current in micro amps, while in deep sleep time needs to be incremented.

I thought RTC would consume less power than timer(if i am correct?) but not able to get RTC working , also no sample code available.

I also tried to reduce the Tx power assuming it will save power(need 6 to 7 mtr range only) but that also doesn't seem to working

Please help to get RTC working and reduce TX power to save energy and other available configs for low power in deep sleep.

Thanks in advance!

Edit:

Using SDK and Toolchain v2.9.0

Parents
  • Hello AP,

    You might be confused. The RTC is on by default when using the nRF Connect SDK and the nRF5340.

    There are two states of sleeps:

    System ON Idle - This is automatically entered when all threads go idle.
    System OFF - This has to be entered manually. The consumption is even lower in this state.

    For more information about the state, please refer to the Power and clock management section of the Product Specification.

    Since you are asking about RTC, you might want to know that in System OFF, the deepest sleep state, RTC is stopped, and the system can only be woken up by GPIO. The system will also have to reinitialize from the beginning like after a reset.

    Hieu

  • Hi Hieu,

    Thank you, This information is helpful!

    However , I am not able to use RTC using "const struct device *rtc = DEVICE_DT_GET(DT_NODELABEL(rtc1));"

    Please suggest some samples code or tutorial for this.

    Also I am successfully able to enter in LPN Mode but seems not able to come out of LPN mode is that possible or not to dynamically changing states?

    Additionally when tried to use Power management configurations and API. its gives error. below config not supported.

    CONFIG_PM=y
    CONFIG_PM_DEVICE=y
    When I tried to use Sample code device_pm , I am not getting option for nrf5340 board target in build config.
    Waiting for your response!
    Edit:
    I tried Using RTC with
    nrfx_rtc_t sti_period_rtc_1 = NRFX_RTC_INSTANCE(0);
    and
    nrfx_rtc_t sti_period_rtc_1 = NRFX_RTC_INSTANCE(1);
    but getting error-
    error: NRFX_RTC (defined at C:/ncs/v2.9.0/zephyr/modules/hal_nordic\nrfx/Kconfig:443,
    modules\hal_nordic\nrfx/Kconfig:443) is assigned in a configuration file, but is not directly user-
    configurable (has no prompt). It gets its value indirectly from other symbols. See
    docs.zephyrproject.org/.../kconfig.html and/or look up NRFX_RTC in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    Edit2:
    1.Regarding PM (CONFIG_PM=y) I tried with nrf52832dk and Its working.
    2.in some discussion I found that in latest versions(after v2.5.0) PM is deprecated and not supported anymore for nrf5340
    3.Then I tried with v2.3.0 and its working.
    So how to achieve it with v2.9.0?
    4.Regarding RTC I tried rtc0 and rtc1 both but seems like its not available for user. I need something that can increment clock time every second. while MCU is in sleep mode.
    In Summary I have 3 points.
    1.how Come Out of LPN Mode.
    2.PM(power management) for nrf5340, v2.9.0
    3.RTC or similar timer active in sleep mode.
  • AP said:
    1.Regarding PM (CONFIG_PM=y) I tried with nrf52832dk and Its working.
    2.in some discussion I found that in latest versions(after v2.5.0) PM is deprecated and not supported anymore for nrf5340
    3.Then I tried with v2.3.0 and its working.
    So how to achieve it with v2.9.0?
    AP said:
    1.how Come Out of LPN Mode.
    2.PM(power management) for nrf5340, v2.9.0

    Your investigation is correct. CONFIG_PM is no longer supported for the nRF5340.
    The rationale is that the PM subsystem is intended to be used to switch the system over different power states.

    However, the nRF5340 only have two power state, System ON and System OFF, so PM doesn't fit.

    As for sleep states, as mentioned, there are two: System ON Idle and System OFF.

    System ON Idle is automatically entered when all threads go idle, and is automatically exited when any thread resume activity.

    To enter System OFF, you will want to use the Power Off API instead. On the nRF5340, System OFF can only be exited with specific GPIO, NFC, or LPCOMP events or reset. |
    Further information about System OFF: Power and clock management.
    SDK API Documentation: Zephyr API: System power off
    SDK Sample: System Off

    AP said:
    3.RTC or similar timer active in sleep mode.
    AP said:
    4.Regarding RTC I tried rtc0 and rtc1 both but seems like its not available for user. I need something that can increment clock time every second. while MCU is in sleep mode.

    The RTC is available with the correct configuration. One RTC is always reserved for System timekeeping.

    For something like tracking passing seconds, I recommend taking advantage of System time services instead. You can calculate current time from system uptime and a reference point. Refer this documentation: Time Utilities.

    Please experiment with them a little.

Reply
  • AP said:
    1.Regarding PM (CONFIG_PM=y) I tried with nrf52832dk and Its working.
    2.in some discussion I found that in latest versions(after v2.5.0) PM is deprecated and not supported anymore for nrf5340
    3.Then I tried with v2.3.0 and its working.
    So how to achieve it with v2.9.0?
    AP said:
    1.how Come Out of LPN Mode.
    2.PM(power management) for nrf5340, v2.9.0

    Your investigation is correct. CONFIG_PM is no longer supported for the nRF5340.
    The rationale is that the PM subsystem is intended to be used to switch the system over different power states.

    However, the nRF5340 only have two power state, System ON and System OFF, so PM doesn't fit.

    As for sleep states, as mentioned, there are two: System ON Idle and System OFF.

    System ON Idle is automatically entered when all threads go idle, and is automatically exited when any thread resume activity.

    To enter System OFF, you will want to use the Power Off API instead. On the nRF5340, System OFF can only be exited with specific GPIO, NFC, or LPCOMP events or reset. |
    Further information about System OFF: Power and clock management.
    SDK API Documentation: Zephyr API: System power off
    SDK Sample: System Off

    AP said:
    3.RTC or similar timer active in sleep mode.
    AP said:
    4.Regarding RTC I tried rtc0 and rtc1 both but seems like its not available for user. I need something that can increment clock time every second. while MCU is in sleep mode.

    The RTC is available with the correct configuration. One RTC is always reserved for System timekeeping.

    For something like tracking passing seconds, I recommend taking advantage of System time services instead. You can calculate current time from system uptime and a reference point. Refer this documentation: Time Utilities.

    Please experiment with them a little.

Children
  • Hi Hieu,

    Thanks now I am able to used PM.

    But still waiting response on "Also I am successfully able to enter in LPN Mode but seems not able to come out of LPN mode is that possible or not to dynamically changing states?"

    When low power mode active it by default(as well as using function in below code) goes in to LPN after 16 sec and Current reduces from 5mA to 1.6mA.

    but not able to bring back to normal mode.

    void SCHNEE_lpn_enable(void)

    {

        int err;

        // //Disable sending of the Secure Network Beacon.

        bt_mesh_beacon_set(0);

        // //Disable the GATT Proxy feature.

        bt_mesh_gatt_proxy_set(0);

        //Set LPN

        // Enable Low Power Node mode

        err = bt_mesh_lpn_set(true);  // Passing true enables LPN mode

        if (err) {

            printk("Failed to enable Low Power Node (err %d)\n", err);

        } else {

            printk("Low Power Node mode enabled.\n");

        }

        k_sleep(K_SECONDS(1));

     

        // bt_mesh_lpn_set_cb(lpn_cb);

        // printk("LPN mode set. Waiting for Friend Node...\n");

        // while (1) {

        //  k_sleep(K_SECONDS(10)); // Device sleeps while waiting for messages

        // }

     

        // Start periodic polling loop

        //SCHNEE_lpn_poll_periodically();

    }

     

    void SCHNEE_lpn_disable(void)

    {

        int err;

        // //Enable the GATT Proxy feature.

        bt_mesh_gatt_proxy_set(1);

        // //Enable sending of the Secure Network Beacon.

        bt_mesh_beacon_set(1);

        //Reset LPN

        // Disable Low Power Node mode

        err = bt_mesh_lpn_set(false);  // Passing true enables LPN mode

        if (err) {

            printk("Failed to disable Low Power Node (err %d)\n", err);

        } else {

            printk("Low Power Node mode disabled.\n");

        }

     

        //bt_mesh_lpn_disable(1);

        //bt_mesh_lpn_friendship_end();

        // err = bt_le_adv_start(BT_LE_ADV_CONN, NULL, 0, NULL, 0);

        // if (err) {

        //     printk("Failed to bt_le_adv_start(err %d)\n", err);

        // } else {

        //     printk("bt_le_adv_start.\n");

        // }

    }

  • Hello AP,

    AP said:
    Thanks now I am able to used PM.

    To be sure, are you using Power Management, pm, or Device Power Management, pm_device? Or are you using the Power Off API?

    As I said, PM is not supported in NCS v2.9.0, so if you are somehow using it, we need to be sure you are getting what you expect.

    The naming of those Zephyr APIs are a little confusing, but it's important to know what you are running.

    AP said:
    But still waiting response on "Also I am successfully able to enter in LPN Mode but seems not able to come out of LPN mode is that possible or not to dynamically changing states?"

    What is the problem when you run bt_mesh_lpn_set()?

  • To be sure, are you using Power Management, pm, or Device Power Management, pm_device?

    I should have been more specific, Using  pm_device  as well as Power Off API. Currently I have two mode , Normal Mesh(5mA), PowerOff(200uA). But need one more mode Low Power(1.5mA to 2.5mA) if Possible?

    What is the problem when you run bt_mesh_lpn_set()?

    By Setting LPN, Current Reduces(1.7mA, when no other node in proximity) but if any node available it seems to consider that node as friend(even if i don't set that as friend) when clearing LPN , I am not able to come back to normal.

    Note: Friend Feature is not needed for now, setting LPN only to achieve lower Power.

    So if without LPN, there are ways to reduce power consumption from 5mA Please suggest?

    I am also tried reducing tx power (CONFIG_BT_CTLR_TX_PWR_MINUS_40=y) to -20,-40 and other values but its not working(warning says got value "n").

  • AP said:
    I should have been more specific, Using  pm_device  as well as Power Off API. Currently I have two mode , Normal Mesh(5mA), PowerOff(200uA). But need one more mode Low Power(1.5mA to 2.5mA) if Possible?

    Is 200uA the entire board, or just the nRF SoC? If it's just the nRF chip, then that's really high. You will want to check and make sure every peripherals is disabled. That's unless you need to keep something running, of course.

    AP said:

    By Setting LPN, Current Reduces(1.7mA, when no other node in proximity) but if any node available it seems to consider that node as friend(even if i don't set that as friend) when clearing LPN , I am not able to come back to normal.

    Note: Friend Feature is not needed for now, setting LPN only to achieve lower Power.

    So if without LPN, there are ways to reduce power consumption from 5mA Please suggest?

    You seem to misunderstand the LPN feature. LPN is a BT Mesh feature that needs a Friend Node to work, always.

    If a node does not support and enable LPN, it's really hard to get good power consumption with it, because by default, the radio would be running almost 100% of the time to minimize packet losses.

    If you don't want to use the LPN feature, the best you can do is suspend all peripherals and ensure all threads go to idle to achieve System ON Idle.

    Also 1.7mA in LPN mode is really high. Is this average current over some time?
    Please look into the current measurement in details and see what the actual current when the LPN node is sleeping is.
    You will also want to try measuring the LPN configuration with the Bluetooth Mesh: Light switch sample to have a reference point.

    Please also keep in mind that a node spends a lot of time in scanning. You can find the expected current for scanning listed here: Technical Documentation.

    AP said:
    I am also tried reducing tx power (CONFIG_BT_CTLR_TX_PWR_MINUS_40=y) to -20,-40 and other values but its not working(warning says got value "n").

    This is an option but note that it will significantly reduce your range. It also doesn't have as much effect on Mesh devices, because a significant part of the power consumption comes from radio RX, and lowering TX Power only helps with TX.

    As for configuration, you need to check which TX Power your device support and only use the supported power level. Also try using CONFIG_BT_CTLR_TX_PWR_ANTENNA. Bot the TX_PWR_ANTENNA and the TX_PWR_X configurations work, but the TX_PWR_ANTENNA configuration takes priority.

    Note that both of them changes the TX Power statically/permanently. If you want dynamic TX Power, you will need to look into the HCI Power Control sample.

  • Hi,

    Using system off mode currently for sleep and external RTC via UART to wake mcu up via alarm.

    I have gone through the suggested sdk fundamental course for I2C and using provided example only, I2c  works with cpuapp but not with cpuapp_ns, Please help to resolve.

Related