<?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>How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102041/how-to-achieve-the-lowest-power-consumption-on-the-actinius-icarus-nrf9160-board</link><description>Hi, 
 I&amp;#39;m trying to lower the power consumption om an Actinius Icarus board which uses an nrf9160 chip. I&amp;#39;ve been able to achieve a sleep current of 1.33mA and I&amp;#39;m not able to lower this any further. Could you please let me know what else I could do to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Apr 2020 15:02:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102041/how-to-achieve-the-lowest-power-consumption-on-the-actinius-icarus-nrf9160-board" /><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437328?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 15:02:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2872108d-fd63-4dfa-9508-8ed91476d1cd</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try zephyr/samples/basic/blinky, with CONFIG_SERIAL=n &amp;amp; project configured with the secure region, and see if this goes&amp;nbsp;below 1 mA?&lt;/p&gt;
&lt;p&gt;Can it be that one of your LEDs is lit up? On the nRF9160-DK, LEDs are buffered, but I&amp;#39;m not sure how they&amp;#39;re connected on this board (couldn&amp;#39;t find a schematic)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437326?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 12:32:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ecdefdd-6356-4857-bc13-19ffc7edd233</guid><dc:creator>Nikil Rao</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry I keep enabling and disabling logs for testing and I forgot to disable those two configs. It doesn&amp;#39;t compile without disabling them, true. I have&amp;nbsp;&lt;span&gt;CONFIG_UART_INTERRUPT_DRIVEN=n and&amp;nbsp;&lt;/span&gt; &lt;span&gt;CONFIG_AT_HOST_LIBRARY=n&amp;nbsp;&lt;/span&gt;disabled and I still see&amp;nbsp;&lt;span&gt;~1 mA.&lt;br /&gt;&lt;br /&gt;&amp;quot;It might take around 1 minute before you have successfully entered sleep after entering PSM&amp;quot;. Yes, I have seen this in action by enabling and disabling PSM. When PSM is enabled, I see spikes in current for about a minute before it settles around&amp;nbsp;~1 mA while it does not settle when PSM is disabled.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437323?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 12:20:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6149242a-3096-4c52-b822-1bab606be482</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to disable everything related to UART, specifically the at_host?&lt;/p&gt;
&lt;p&gt;CONFIG_UART_INTERRUPT_DRIVEN=n&lt;br /&gt;CONFIG_AT_HOST_LIBRARY=n&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This one will setup a uart directly, but I&amp;#39;m a bit surprised that you get your current configuration to compile, as&amp;nbsp;at_host would have a dependency on SERIAL being enabled.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;PS: It might take around 1 minute before you have successfully entered sleep after entering PSM, as there is a RRC idle period (individually set by the network), in which could explain the fluctuation you have previously seen. If you still get ~1 mA even after the modem is disabled, then its still something in the application that causes this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437321?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 15:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80bfba2e-3caf-4d68-84e9-c308fae2664b</guid><dc:creator>Nikil Rao</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Logs
CONFIG_CONSOLE=n
CONFIG_STDOUT_CONSOLE=n
CONFIG_LOG=n
CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

# Peripherals
CONFIG_ADC=y
CONFIG_ADC_0=y
CONFIG_ADC_1=y
CONFIG_ADC_NRFX_SAADC=y
CONFIG_GPIO=y

# TEE
CONFIG_TRUSTED_EXECUTION_NONSECURE=y

# Bootloader - Application update support
CONFIG_BOOTLOADER_MCUBOOT=n

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y

# BSD library
CONFIG_BSD_LIBRARY=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_LTE_NETWORK_MODE_NBIOT=y
CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y

# AT Host
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_AT_HOST_LIBRARY=y

# external sim 
CONFIG_BOARD_SELECT_SIM_EXTERNAL=y

# power mgmt
CONFIG_SYS_POWER_MANAGEMENT=y
CONFIG_DEVICE_POWER_MANAGEMENT=y

#AWS
CONFIG_AWS_IOT=y
CONFIG_AWS_IOT_BROKER_HOST_NAME=&amp;quot;a26a1lpxwnwowb-ats.iot.eu-central-1.amazonaws.com&amp;quot;
CONFIG_AWS_IOT_SEC_TAG=75316842
CONFIG_AWS_IOT_LOG_LEVEL_DBG=y
CONFIG_AWS_IOT_CLIENT_ID_APP=y
CONFIG_MQTT_LOG_LEVEL_DBG=y

# Main thread
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_LTE_PSM_REQ_RPTAU=&amp;quot;11000001&amp;quot;
CONFIG_LTE_PSM_REQ_RAT=&amp;quot;00000010&amp;quot;
CONFIG_MQTT_KEEPALIVE=1200

CONFIG_HEAP_MEM_POOL_SIZE=16384
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * @file main.c
 * @author Nikil Rao (nikil.rao@nbt.ag)
 * @brief
 * @version 0.1
 * @date 2020-03-31
 *
 * @copyright Copyright (c) 2020
 *
 */

/*=============================================================================
 *                                 Includes
 *==============================================================================*/
#include &amp;quot;tempSensor.h&amp;quot;
#include &amp;lt;at_cmd.h&amp;gt;
#include &amp;lt;at_cmd_parser/at_cmd_parser.h&amp;gt;
#include &amp;lt;at_cmd_parser/at_params.h&amp;gt;
#include &amp;lt;at_notif.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;
#include &amp;lt;net/aws_iot.h&amp;gt;
#include &amp;lt;net/mqtt.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;nrf_socket.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;

/*=============================================================================
 *                             Defines
 *==============================================================================*/
#define BUFFER_SIZE                   10
#define IMEI_LEN                      20
#define DEV_ID_LEN                    20
#define RED_LED                       DT_ALIAS_LED0_GPIOS_PIN
#define LED_ON                        0
#define LED_OFF                       !LED_ON
#define DEVICE_SLEEP_INTERVAL         330 // 330 seconds works 333 doesn&amp;#39;t
#define DEVICE_AWAKE_INTERVAL         4 // 2 seconds works
#define AT_CESQ_RESPONSE_PREFIX       &amp;quot;+CESQ&amp;quot;
#define AT_CESQ_PARAMS_COUNT_MAX      7
#define AT_CESQ_RESPONSE_PREFIX_INDEX 0
#define AT_CESQ_RESPONSE_RSRQ_INDEX   5
#define AT_CESQ_RESPONSE_RSRP_INDEX   6
/*=============================================================================
 *                             Static Variables
 *==============================================================================*/
/* Connected flag */
static bool connected               = false;
static char dev_id[DEV_ID_LEN]      = {0};
static struct device *gpio_dev      = {0};
static struct aws_iot_config config = {0};
static struct pollfd fds            = {0};

/*=============================================================================
 *                             Private Functions
 *==============================================================================*/

/**
 * @brief Configures modem to provide LTE link. Blocks until link is
 * successfully established.
 *
 */
static void modem_configure(void)
{
    int err;
    // Use static IP as there was some problem resolving DNS
    struct nrf_in_addr dns;
    dns.s_addr = 134744072; // Google DNS, 8.8.8.8
    err        = nrf_setdnsaddr(2, &amp;amp;dns);
    printk(&amp;quot;Set DNS Address (%d)\r\n&amp;quot;, err);

#if defined(CONFIG_LTE_LINK_CONTROL)
    if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT))
    {
        /* Do nothing, modem is already turned on
         * and connected.
         */
    }
    else
    {
        int err;

        printk(&amp;quot;LTE Link Connecting ...\n&amp;quot;);
        err = lte_lc_init_and_connect();
        __ASSERT(err == 0, &amp;quot;LTE link could not be established.&amp;quot;);
        printk(&amp;quot;LTE Link Connected!\n&amp;quot;);
    }
#endif /* defined(CONFIG_LTE_LINK_CONTROL) */
}

/*=============================================================================*/

/**
 * @brief Set up Power Saving Mode for the modem
 *        Refer PSM.md for info on the values
 *
 */
void modem_setup_psm(void)
{
    /*
     * GPRS Timer 3 value (octet 3)
     *
     * Bits 5 to 1 represent the binary coded timer value.
     *
     * Bits 6 to 8 defines the timer value unit for the GPRS timer as follows:
     * Bits
     * 8 7 6
     * 0 0 0 value is incremented in multiples of 10 minutes
     * 0 0 1 value is incremented in multiples of 1 hour
     * 0 1 0 value is incremented in multiples of 10 hours
     * 0 1 1 value is incremented in multiples of 2 seconds
     * 1 0 0 value is incremented in multiples of 30 seconds
     * 1 0 1 value is incremented in multiples of 1 minute
     * 1 1 0 value is incremented in multiples of 320 hours (NOTE 1)
     * 1 1 1 value indicates that the timer is deactivated (NOTE 2).
     */
    char psm_settings[] = CONFIG_LTE_PSM_REQ_RPTAU;

    printk(&amp;quot;PSM bits: %c%c%c\n&amp;quot;, psm_settings[0], psm_settings[1],
           psm_settings[2]);
    printk(&amp;quot;PSM Interval: %c%c%c%c%c\n&amp;quot;, psm_settings[3], psm_settings[4],
           psm_settings[5], psm_settings[6], psm_settings[7]);

    int err = lte_lc_psm_req(true);
    if (err &amp;lt; 0)
    {
        printk(&amp;quot;Error setting PSM: %d Errno: %d\n&amp;quot;, err, errno);
    }
}

/*=============================================================================*/
/**
 * @brief 
 * &amp;lt;rsrq&amp;gt;
    0 rsrq &amp;lt; −19.5 dB
    1 – When −19.5 dB ≤ RSRQ &amp;lt; −19 dB
    2 – When −19 dB ≤ RSRQ &amp;lt; −18.5 dB
    ...
    32 – When −4 dB ≤ RSRQ &amp;lt; −3.5 dB
    33 – When −3.5 dB ≤ RSRQ &amp;lt; −3 dB
    34 – When −3 dB ≤ RSRQ
    255 – Not known or not detectable
    rsrq
    &amp;gt;= -10 dB	Excellent	Strong signal with maximum data speeds
    -10 dB to -15 dB	Good	Strong signal with good data speeds
    -15 dB to -20 dB	Fair to poor	Reliable data speeds may be attained, but marginal data with drop-outs is possible. When this value gets close to -20, performance will drop drastically
    &amp;lt;= -20 dB	No signal	Disconnection

    &amp;lt;rsrp&amp;gt;
    0 – RSRP &amp;lt; −140 dBm
    1 – When −140 dBm ≤ RSRP &amp;lt; −139 dBm
    2 – When −139 dBm ≤ RSRP &amp;lt; −138 dBm
    ...
    95 – When −46 dBm ≤ RSRP &amp;lt; −45 dBm
    96 – When −45 dBm ≤ RSRP &amp;lt; −44 dBm
    97 – When −44 dBm ≤ RSRP
    255 – Not known or not detectable
    rsrp
    &amp;gt;= -80 dBm	Excellent	Strong signal with maximum data speeds
    -80 dBm to -90 dBm	Good	Strong signal with good data speeds
    -90 dBm to -100 dBm	Fair to poor	Reliable data speeds may be attained, but marginal data with drop-outs is possible. When this value gets close to -100, performance will drop drastically
    &amp;lt;= -100 dBm	No signal	Disnonnection
 * @param rsrp 
 * @param rsrq 
 * @return int 
 */
int modem_getSignalStrength(s16_t *rsrp, s16_t *rsrq)
{
    int err;
    enum at_cmd_state at_state;
    char buf[32];
    uint32_t value;
    struct at_param_list resp_list = {0};

    char response_prefix[sizeof(AT_CESQ_RESPONSE_PREFIX)] = {0};
    size_t response_prefix_len = sizeof(response_prefix);

    if ((err = at_cmd_write(&amp;quot;AT+CESQ&amp;quot;, buf, sizeof(buf), &amp;amp;at_state)))
    {
        printk(&amp;quot;Error when trying to do at_cmd_write: %d, at_state: %d\n&amp;quot;, err,
               at_state);
        return err;
    }
    printf(&amp;quot;%s\n&amp;quot;, buf);

    if ((err = at_params_list_init(&amp;amp;resp_list, AT_CESQ_PARAMS_COUNT_MAX)))
    {
        printk(&amp;quot;Could not init AT params list, error: %d\n&amp;quot;, err);
        return err;
    }

    /* Parse CESQ response and populate AT parameter list */

    if ((err = at_parser_max_params_from_str(buf, NULL, &amp;amp;resp_list,
                                             AT_CESQ_PARAMS_COUNT_MAX)))
    {
        printk(&amp;quot;Could not parse AT+CESQ response, error: %d\n&amp;quot;, err);
        at_params_list_free(&amp;amp;resp_list);
        return err;
    }

    /* Check if AT command response starts with +CESQ */
    if ((err = at_params_string_get(&amp;amp;resp_list, AT_CESQ_RESPONSE_PREFIX_INDEX,
                                    response_prefix, &amp;amp;response_prefix_len)))
    {
        printk(&amp;quot;Could not get response prefix, error: %d\n&amp;quot;, err);
        at_params_list_free(&amp;amp;resp_list);
        return err;
    }

    if (strncmp(response_prefix, AT_CESQ_RESPONSE_PREFIX, response_prefix_len))
    {
        /* The unsolicited response is not a CESQ response, ignore it.
         */
        printk(&amp;quot;String not matching %s\n&amp;quot;, response_prefix);
        at_params_list_free(&amp;amp;resp_list);
        return err;
    }

    if ((err =
             at_params_int_get(&amp;amp;resp_list, AT_CESQ_RESPONSE_RSRQ_INDEX, &amp;amp;value)) != 0)
    {
        printk(&amp;quot;Could not get RSRQ: %d\n&amp;quot;, err);
        at_params_list_free(&amp;amp;resp_list);
        return err;
    }
    *rsrq = (s16_t)value;

    if ((err =
             at_params_int_get(&amp;amp;resp_list, AT_CESQ_RESPONSE_RSRP_INDEX, &amp;amp;value)) != 0)
    {
        printk(&amp;quot;Could not get RSRP, error: %d\n&amp;quot;, err);
        at_params_list_free(&amp;amp;resp_list);
        return err;
    }
    *rsrp = (s16_t)value;

    at_params_list_free(&amp;amp;resp_list);
    return err;
}

/*=============================================================================*/

int device_getDevID()
{
    int err;
    enum at_cmd_state at_state;
    char imei_buf[IMEI_LEN + 5];

    if ((err = at_cmd_write(&amp;quot;AT+CGSN&amp;quot;, imei_buf, IMEI_LEN + 5, &amp;amp;at_state)))
    {
        printk(&amp;quot;Error when trying to do at_cmd_write: %d, at_state: %d&amp;quot;, err,
               at_state);
        return err;
    }

    snprintf(dev_id, 20, &amp;quot;nrf-%s&amp;quot;, imei_buf);
    return err;
}

/*=============================================================================*/

/**
 * @brief Handle events sent from AWS MQTT server
 *
 * @param evt
 */
void aws_iot_evt_handler(const struct aws_iot_evt *evt)
{
    printk(&amp;quot;aws_iot_evt_handler %d\r\n&amp;quot;, evt-&amp;gt;type);

    if (evt-&amp;gt;type == AWS_IOT_EVT_READY)
    {
        connected = true;
        led_switchOff();
    }
}

/*=============================================================================*/

int aws_init(void)
{
    int err;

    device_getDevID();
    config.client_id     = dev_id;
    config.client_id_len = strlen(dev_id);

    if ((err = aws_iot_init(&amp;amp;config, aws_iot_evt_handler)) == 0)
    {
        printk(&amp;quot;aws_iot_initialized\r\n&amp;quot;);
    }
    else
    {
        printk(&amp;quot;aws_iot_init failed: %d\n&amp;quot;, err);
        return err;
    }
    return err;
}

/*=============================================================================*/

void aws_connect(void)
{
    int err;
    while ((err = aws_iot_connect(&amp;amp;config)) != 0)
    {
        printk(&amp;quot;aws_iot_connect failed: %d\n&amp;quot;, err);
        k_sleep(5000);
    }

    printk(&amp;quot;aws_iot_connected\n&amp;quot;);
    return;
}

/*=============================================================================*/

void aws_reconnect(void)
{
    int err;
    
    aws_iot_disconnect();
    aws_init();
    connected = false;
    led_switchOn();
    aws_connect();
    
    return;
}

/*=============================================================================*/

/**
 * @brief
 *
 * @return int
 */
static int aws_publish_data()
{
    int err                     = 0;
    static uint32_t msg_counter = 0;
    float temperature           = 0;
    u16_t battery_voltage       = 0;
    s16_t rsrp                  = 0;
    s16_t rsrq                  = 0;

    tempSensor_getTemperature(&amp;amp;temperature);
    tempSensor_getBatteryVoltage(&amp;amp;battery_voltage);
    modem_getSignalStrength(&amp;amp;rsrp, &amp;amp;rsrq);

    /* Send data to topic */
    char topic_msg[256];
    sprintf(topic_msg,
            &amp;quot;{\&amp;quot;state\&amp;quot;:{\&amp;quot;reported\&amp;quot;:{\&amp;quot;device\&amp;quot;:\&amp;quot;%s\&amp;quot;, &amp;quot;
            &amp;quot;\&amp;quot;message_count\&amp;quot;:\&amp;quot;%d\&amp;quot;, &amp;quot;
            &amp;quot;\&amp;quot;temperature\&amp;quot;:\&amp;quot;%.2f\&amp;quot;, \&amp;quot;battery_level\&amp;quot;:\&amp;quot;%d\&amp;quot;, &amp;quot;
            &amp;quot;\&amp;quot;RSRQ\&amp;quot;:\&amp;quot;%d\&amp;quot;, \&amp;quot;RSRP\&amp;quot;:\&amp;quot;%d\&amp;quot;}}}&amp;quot;,
            dev_id, ++msg_counter, temperature, battery_voltage, rsrq, rsrp);

    char *topic_name = &amp;quot;concr/temperature&amp;quot;;

    struct aws_iot_topic_data topic = {
        /** Type of shadow topic that will be published to. */
        // enum aws_iot_topic_type
        .type = AWS_IOT_SHADOW_TOPIC_UPDATE,
        /** Pointer to string of application specific topic. */
        // char *
        .str = topic_name,
        /** Length of application specific topic. */
        // size_t
        .len = strlen(topic_name),
    };

    const struct aws_iot_tx_data tx_data = {
        /** Topic that the message will be sent to. */
        // struct aws_iot_topic_data
        .topic = topic,
        /** Pointer to message to be sent to AWS IoT broker. */
        .str = topic_msg,
        /** Length of message. */
        .len = strlen(topic_msg),
        /** Quality of Service of the message. */
        .qos = 1,
    };

    if (aws_iot_send(&amp;amp;tx_data) != 0)
    {
        printk(&amp;quot;Failed to publish sensor data\r\n&amp;quot;);
    }
    else
    {
        printk(&amp;quot;Publish Sensor Data\r\n&amp;quot;);
        printk(&amp;quot;DATA: %s\r\n&amp;quot;, topic_msg);
    }

    return err;
}

/*=============================================================================*/

void fds_init(void)
{
    fds.fd     = config.socket;
    fds.events = POLLIN;
}

/*=============================================================================*/

int led_init(void)
{
    int err;
    gpio_dev = device_get_binding(DT_GPIO_P0_DEV_NAME);

    if (!gpio_dev)
    {
        printk(&amp;quot;Error getting &amp;quot; DT_GPIO_P0_DEV_NAME &amp;quot; device binding\r\n&amp;quot;);
        err = 1;
        return err;
    }

    gpio_pin_configure(gpio_dev, RED_LED, GPIO_DIR_OUT);
    return err;
}

/*=============================================================================*/

void led_switchOn(void) { gpio_pin_write(gpio_dev, RED_LED, LED_ON); }

/*=============================================================================*/

void led_switchOff(void) { gpio_pin_write(gpio_dev, RED_LED, LED_OFF); }


/*=============================================================================*/

/**
 * @brief
 *
 */
void main(void)
{
    printk(&amp;quot;NRF9160 Temperature Sensor Started...!!!\r\n&amp;quot;);
    int err;

    s64_t time_stamp     = k_uptime_get();
    s32_t delay_interval = K_SECONDS(DEVICE_SLEEP_INTERVAL);
    s32_t awake_interval = K_SECONDS(DEVICE_AWAKE_INTERVAL);

    led_init();
    led_switchOn();
    modem_configure();
    modem_setup_psm();
    tempSensor_init();
    aws_init();
    aws_connect();
    fds_init();

    printk(&amp;quot;Initialized successfully in %lldms\n&amp;quot;, k_uptime_delta(&amp;amp;time_stamp));

    while (true)
    {
        printk(&amp;quot;\n&amp;quot;);

        if(connected == false)
        {
            //Wait to be connected before publishing data
            delay_interval = 0;
            awake_interval = K_SECONDS(CONFIG_MQTT_KEEPALIVE);
        }
        else
        {
            //After connection publish data to thje AWS server
            delay_interval = K_SECONDS(DEVICE_SLEEP_INTERVAL);
            awake_interval = K_SECONDS(DEVICE_AWAKE_INTERVAL);
            aws_publish_data();
        }
        
        err = poll(&amp;amp;fds, 1, awake_interval);

        if (err &amp;lt; 0)
        {
            printk(&amp;quot;poll() returned an error: %d\n&amp;quot;, err);
            continue;
        }
        else if (err == 0)
        {
            if(aws_iot_keepalive_time_left() &amp;lt; 0)
            {
                aws_iot_ping();
                continue;
            }
        }        

        if ((fds.revents &amp;amp; POLLIN) == POLLIN)
        {
            aws_iot_input();
        }

        if ((fds.revents &amp;amp; POLLNVAL) == POLLNVAL)
        {
            printk(&amp;quot;Socket error: POLLNVAL\n&amp;quot;);
            printk(&amp;quot;The AWS IoT socket was unexpectedly closed.\n&amp;quot;);
            aws_reconnect();
            continue;
        }

        if ((fds.revents &amp;amp; POLLHUP) == POLLHUP)
        {
            printk(&amp;quot;Socket error: POLLHUP\n&amp;quot;);
            printk(&amp;quot;Connection was closed by the AWS IoT broker.\n&amp;quot;);
            aws_reconnect();
            continue;
        }

        if ((fds.revents &amp;amp; POLLERR) == POLLERR)
        {
            printk(&amp;quot;Socket error: POLLERR\n&amp;quot;);
            printk(&amp;quot;AWS IoT broker connection was unexpectedly closed.\n&amp;quot;);
            aws_reconnect();
            continue;
        }

        k_sleep(delay_interval);
    }   
}
/*=============================================================================
 *                             Public Functions
 *==============================================================================*/

/*=============================================================================
 *                             End of File
 *==============================================================================*/
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437318?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 15:45:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ae9d872-afba-4bb1-b51b-4e4a4a1071c7</guid><dc:creator>Nikil Rao</dc:creator><description>&lt;div&gt;
&lt;div&gt;&lt;span&gt;I tried enabling/disabling ADC with these two values - CONFIG_ADC&lt;/span&gt;&lt;span&gt;=n,&amp;nbsp;&lt;/span&gt;&lt;span&gt;CONFIG_ADC_NRFX_SAADC&lt;/span&gt;&lt;span&gt;=n,. Still no effect on the current consumption.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;#39;m following this example for ADC -&amp;nbsp;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437316?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 14:28:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49f875a4-51fb-4f17-93c2-b533a33ed3a5</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try commenting out / disabling the ADC to see if this has an impact.&lt;/p&gt;
&lt;p&gt;Are you using the nrfx_saadc driver or the zephyr ADC driver?&lt;/p&gt;
&lt;p&gt;Could you share your sources so I can look?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437315?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 13:12:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffb1a02d-5ca8-4e9f-a295-1f28407d74cd</guid><dc:creator>Nikil Rao</dc:creator><description>&lt;p&gt;Hi Håkon,&lt;/p&gt;
&lt;p&gt;Thanks for the quick reply. I have 2 ADCs running. One is an internal pin to measure the battery voltage and the other pin is an NTC voltage divider. Other than that I&amp;#39;m connected to AWS and sending data periodically over MQTT. I&amp;#39;m not using any other peripherals that I know of&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Nikil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to achieve the lowest power consumption on the Actinius Icarus (nrf9160) board?</title><link>https://devzone.nordicsemi.com/thread/437313?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 12:15:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96f23675-c135-4c3e-829b-c848f76b216e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]The sleep current with the modem switched off (with an AT+CFUN=0) command also shows me a sleep current of 1.3mA.[/quote]
&lt;p&gt;This indicates that there&amp;#39;s a peripheral running in the background causing the high sleep current.&lt;/p&gt;
&lt;p&gt;Instead of changing spm files directly, you can add this just below your application&amp;#39;s CMakeLists.txt, the cmake_minimum_required() line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if (EXISTS &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/spm.conf&amp;quot;)
  set(spm_CONF_FILE
    prj.conf
    ${CMAKE_CURRENT_LIST_DIR}/spm.conf
  )
endif()

 

if (EXISTS &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf&amp;quot;)
  set(mcuboot_CONF_FILE
    prj.conf
    ${CMAKE_CURRENT_LIST_DIR}/mcuboot.conf
  )
endif()

 

if (EXISTS &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/${BOARD}.overlay&amp;quot;)
  set(mcuboot_DTC_OVERLAY_FILE &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/${BOARD}.overlay&amp;quot;)
  set(spm_DTC_OVERLAY_FILE &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/${BOARD}.overlay&amp;quot;)
endif()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then you create a file, spm.conf, with the content &amp;quot;CONFIG_SERIAL=n&amp;quot;, and it should disable uart in spm.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What peripherals are you using in your application? TWIM/SPI/ADC?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>