This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Low power mode with nrf9160 and cat_tracker application

Hello,

we have developed a custom board using the nrf9160 SICA chip and are now modifying the bifravst cat tracker example to suite our needs.

Basicaly, it samples from ADC and sends the collected data every so often. Between the sampling periods, we would like for the device to consume as little power as possible. Using the low power psm example we get a consumption of around 4.5 μA. I would now like to achieve a similar result in our application.

What I already do is disconnect from lte using:

lte_lc_offline();

And also disable both uart lines in use (as seen here):

void uart_0_disable(void)
{
    NRF_UARTE0->TASKS_STOPTX = 1;
    NRF_UARTE0->TASKS_STOPRX = 1;
}

void uart_1_disable(void)
{
    NRF_UARTE1->TASKS_STOPTX = 1;
    NRF_UARTE1->TASKS_STOPRX = 1;
}

With this I managed to get around 28 μA during idle period (with k_sleep()).

I am now looking for ways to further be able to turn on/off parts of the chip during runtime. Looking at prj.conf (whole file attached) I see that networking, GPS, accelerometer, adc0, and watchdog are enabled:

# General config
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y
CONFIG_LOG=y
CONFIG_LOG_IMMEDIATE=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=n
CONFIG_POWER_OPTIMIZATION_ENABLE=y

# enables nb-iot and gps networks
CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y
CONFIG_LTE_LEGACY_PCO_MODE=y
CONFIG_LTE_PSM_REQ_RPTAU="00000110"
CONFIG_LTE_PSM_REQ_RAT="00000000"

# LTE connection timeout in seconds
CONFIG_LTE_NETWORK_TIMEOUT=60
# if nb-iot doesn't connect, try to connect to lte_m (with same timeout)
CONFIG_LTE_NETWORK_USE_FALLBACK=y

# Modem info
CONFIG_MODEM_INFO=y

# BSD library
CONFIG_BSD_LIBRARY=y
CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

# Bifravst Cloud
CONFIG_CLOUD_API=y
CONFIG_BIFRAVST_CLOUD=y
CONFIG_BIFRAVST_CLOUD_LOG_LEVEL_DBG=y
CONFIG_AWS_IOT_BROKER_HOST_NAME="XXXXXXXXXXXXXXXXXXXXXXXXXXX"

# GPS
CONFIG_NRF9160_GPS=y
CONFIG_GPS_SIM=n
CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
CONFIG_GPS_USE_EXTERNAL=y
CONFIG_GPS_DEV_NAME="NRF9160_GPS"

CONFIG_GPS_CONTROL=y
CONFIG_GPS_CONTROL_FIRST_FIX_CHECK_DELAY=10
CONFIG_GPS_CONTROL_FIX_CHECK_INTERVAL=30
CONFIG_GPS_CONTROL_FIX_TRY_TIME=360
CONFIG_GPS_CONTROL_PSM_ENABLE_ON_START=y
CONFIG_GPS_CONTROL_PSM_DISABLE_ON_STOP=n

# ADXL362
CONFIG_ADXL362=y
CONFIG_SPI=y
CONFIG_SENSOR=y
CONFIG_ADXL362_TRIGGER_GLOBAL_THREAD=y
CONFIG_ADXL362_INTERRUPT_MODE=1
CONFIG_ADXL362_ABS_REF_MODE=1
CONFIG_ADXL362_ACTIVITY_THRESHOLD=400
CONFIG_ADXL362_INACTIVITY_THRESHOLD=300

# Console
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_GETCHAR=y

# Main thread
CONFIG_MAIN_THREAD_PRIORITY=7

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_HW_STACK_PROTECTION=y

# Disable native network stack to save some memory
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=n
CONFIG_NET_UDP=n
CONFIG_NET_TCP=n

# Settings
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# App Version
CONFIG_CAT_TRACKER_APP_VERSION="0.0.2"

# MCUBOOT
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# AWS FOTA
CONFIG_AWS_FOTA=y
CONFIG_AWS_FOTA_LOG_LEVEL_DBG=y
CONFIG_AWS_JOBS_LOG_LEVEL_DBG=y
CONFIG_AWS_FOTA_VERSION_STRING_MAX_LEN=128
CONFIG_DFU_TARGET=y

# Download client (needed by AWS FOTA)
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096

# Time managing
CONFIG_NRF9160_TIMESTAMP=y
CONFIG_NRF9160_TIMESTAMP_LOG_LEVEL_DBG=y


# ADC
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_BUF_USER_DATA_SIZE=1
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_RAW_MODE=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_ADC=y
CONFIG_ADC_0=y
CONFIG_ADC_NRFX_SAADC=y

# enable c++ support
CONFIG_CPLUSPLUS=y

# base64 encode/decode
CONFIG_BASE64=y

# Watchdog configuration
CONFIG_WATCHDOG=y
CONFIG_WDT_LOG_LEVEL_DBG=y

# optimize program for speed
CONFIG_SPEED_OPTIMIZATIONS=y

# config uart 1
CONFIG_UART_1_NRF_UARTE=y
CONFIG_UART_1_NRF_FLOW_CONTROL=n

I am mainly looking for pointers on how I can programmatically check whether something is enabled and then to be able to turn it on and off at will. Any help is greatly appreciated.

Parents
  • Hi Tjaz,
    Before digging into your code, please state which SIM card you are using?
    And also which network you are connecting to can be interesting.

    I would like you to try to increase the PSM interval (RPTAU) to over 10 minutes to see if there is a restriction in the SIM card.

    Some SIM cards require that the modem needs to stay in PSM mode longer than 10 minutes so the SIM card can go in Shut down mode and draw around (~0,01µA).

    I may suspect that this could be the idle current from the SIM card.



    Best regards,
    martin L,

  • Hi,

    we are not actually using PSM - i.e. we do not request it from the network with lte_lc_psm_req. 
    We connect with lte_lc_init_and_connect(), send our data and then disconnect with lte_lc_offline(); 

    So you are suggesting that not using PSM mode, the modem and/or SIM card is still communicating with the network and thus using power?

    Best Regards,
    Tjaž V

Reply Children
  • Hi Tjaz, 
    No, I am not suggesting that at all. 

    If you have called the function lte_lc_offline(), the modem goes to offline mode. 
    Try to call the function lte_lc_power_off(), to put the modem in Power OFF mode and see if that changes the power consumption.

    I am not too familiar with the cat tracker application since it is not in the official NCS repository, but let me try to come with some suggestions.

    If you check the .config file in the build/zephyr folder you can check which peripherals and modules that are enabled in the application.

    To check e.g. peripherals in runtime you could either read directly the registers or utilize the driver APIs if they support that function.
    Please check out this pull request of the Serial LTE modem example on how it goes to sleep mode and turn OFF the UART in runtime.

  • Hi,

    we managed to figure it out. Setting only TASKS_STOPTX and TASKS_STOPRX does not turn UART off fully.
    If it helps anyone else, the following two functions do all we need to fully disable and enable UART 0, as well as prevent leaking of current out of the pins.

    void uart_0_disable(void)
    {
        // stop tx and rx
        NRF_UARTE0->TASKS_STOPTX = 1;
        NRF_UARTE0->TASKS_STOPRX = 1;
        // disable whole UART 0 interface
        NRF_UARTE0->ENABLE = 0;
    
        // deselect rx and tx pins and clear them
        NRF_UARTE0->PSEL.TXD = 0xFFFFFFFF;
        NRF_P0_NS->OUTCLR = (1 << UART0_TX_PIN);
    
        NRF_UARTE0->PSEL.RXD = 0xFFFFFFFF;
        NRF_P0_NS->OUTCLR = (1 << UART0_RX_PIN);
    
        // reconfigure them as GPIO pins and set them to output/0
        gpio_pin_configure(gpio_dev, UART0_RX_PIN, GPIO_DIR_OUT);
        gpio_pin_write(gpio_dev, UART0_RX_PIN, 0);
    
        gpio_pin_configure(gpio_dev, UART0_TX_PIN, GPIO_DIR_OUT);
        gpio_pin_write(gpio_dev, UART0_TX_PIN, 0);
    }
    
    void uart_0_enable(void)
    {
        // select pins
        NRF_UARTE0->PSEL.TXD = UART0_TX_PIN;
        NRF_UARTE0->PSEL.RXD = UART0_RX_PIN;
    
        // enable interface
        NRF_UARTE0->ENABLE = 8;
        NRF_UARTE0->TASKS_STARTRX = 1;
        NRF_UARTE0->TASKS_STARTTX = 1;
    }

    The same can be done for other UARTs, just replace NRF_UARTE0 with NRF_UARTE1, for example.

    It would be immensely helpful, if things like this were documented, instead of having to scour devzone, trying and merging different answers.

    Regards,
    Tjaž V

Related