nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

Asset Tracker v2 - How to monitor the On/Off state of the sliding switches: sw1 and sw2 reported every minute from the nRF9160DK device to a topic of the AWS IoT Core?

I have built and run the application: Asset Tracker v2 using Segger IDE with nRF Connect SDK 1.8.0 , and my nRF9160DK device communicates with the  AWS IoT Core topics.

I can see the battery voltage data (with its time stamp) reported every minute from my nRF9160DK device to the shadow topics of the AWS IoT Core and I can also see the button-pressed data reported (when a button is pressed) from my nRF9160DK device to the AWS IoT Core topic: <IMEI>/messages.

As a next step, I would like to see the On/Off state of the sliding switches: sw1 and sw2 reported every minute from my nRF9160DK device to a topic on the AWS IoT Core.

How can this be done? 

  • Hi,

     

    The asset tracker v2 uses the event manager to handle events, as shown here in the documentation:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/applications/asset_tracker_v2/doc/asset_tracker_v2_description.html#configuration

     

    Button 1 and 2 is implemented, as you mention, but switches 1 and 2 is not:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/applications/asset_tracker_v2/doc/asset_tracker_v2_description.html#user-interface

     

    The buttons already implemented is shown in this module:

    https://github.com/nrfconnect/sdk-nrf/blob/v1.8.0/applications/asset_tracker_v2/src/modules/ui_module.c#L185

     

    But they are all event based, meaning that it does not do anything without an action being triggered (ie. a user presses the button). For a polling scheme for switch1/2, the above ui_module has to be expanded to handle this.

     

    Kind regards,

    Håkon

  • Hi,

    When I tried to introduce some changes to the "Asset Tracker v2" application's src files, I saw the following error message on the LTE Link Monitor, when I tried to run this application:

    "[1,31m<err> aws-iot: Cloud MQTT input error: -16", shown line after line, as can be seen on the attached LTE Link Monitor log file: "LTE Link Monitor log 2022-01-27".

    I then removed from the src files for "Asset Tracker v2" app all changes that I introduced recently but the problem still persisted and the above mentioned error message kept coming on the LTE Link Monitor when I tried to run this application.

    I then tried to build and run the sample "aws_iot" and it seemed to work OK as per the attached LTE Link Monitor log file: "log_file_for_aws_iot_sample_27_01_2022".

    How can I rectify the error "aws-iot: Cloud MQTT input error: -16" that keeps coming on the LTE Link Monitor when I try to run the "Asset Tracker v2" app ?

    Regards,

    JM

  • Hi, 

    In addition to the info that I sent to DevZone a few minutes ago, I attach a section of the log file: "LTE Link Monitor log 2022-01-27" - that I sent already to DevZone a few minutes ago - that shows in line 14 the following: "aws_iot: Incoming MQTT message too large for payload buffer [0m".   This may indicate the nature of the problem reported by me to DevZone a few minutes ago.

    How can this problem be resolved?

    Regards,

    JM

  • Hi,

     

    Jacekma said:

    How can I rectify the error "aws-iot: Cloud MQTT input error: -16" that keeps coming on the LTE Link Monitor when I try to run the "Asset Tracker v2" app ?

    -16 is EBUSY:

    mqtt_input -> client_read, which returns EBUSY when the socket is still writing (ie. uploading) data:

    https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/net/lib/mqtt/mqtt.c#L117

     

    Before the above error is printed, you are seeing:

    2022-01-27T08:06:19.469Z DEBUG modem << [00:00:29.372,650] [1;31m<err> aws_iot: Incoming MQTT message too large for payload buffer[0m
    2022-01-27T08:06:19.495Z DEBUG modem << [00:00:29.381,072] [1;31m<err> aws_iot: publish_get_payload, error: -122

    How large is the payload you're sending?

     

    Kind regards,

    Håkon

  • Hi,

    I retained in the payload sent from my nRF9160DK device to the AWS IoT Core all items that were originally a part of that payload for this application, including:

    1. the modem battery voltage value and its time stamp, reported every 2 min by the modem_module.

    2. the button1 and buton2 press messages, reported by the button handler in the ui_module upon pressing of each button.

    In addition, I added two items - sw1 and sw2, representing the state of the sliding switches sw1 and sw2 - to the data reported by the modem_module as a part of the info related to the modem battery voltage "bat", that showed in the Device Shadow State as follows:

    {

    "state":{

         "reported": {

               "bat": {

                   "v": 5070,

                   "ts": 16428634511720,

                   "sw1":  99'

                   "sw2":  77,

    And this data, including my newly added items: sw1 and sw2 used to be successfully transmitted from my nRF9160DK device to the AWS IoT Core only a few days ago.

    However, the problem started when I tried to add yet another two items to the data that was to be sent by the modem_module as a part of the modem battery voltage "bat".

    When I saw that my attempt to add yet another two items to the payload already reported by the modem_module was unsuccessful, I removed all changes that I introduced to the src files for this application in order to add yet another two items of data to the payload already reported by the modem_module. (I retained the items sw1 and sw2 in the payload, as they used to be transmitted to ASW IoT Core without a problem in the past).

    However, despite me removing all recent changes that I made to the src files for this application, the problem still persist.

    Regards,

    JM

Related