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

Regular current spikes on modified MQTT simple

Hello!

H.W: nRF9160 DK v8.5
MWF: 1.1
NCS: tag 1.2
SIM: Telenor NB-IoT

I'm using a modified version of the MQTT simple example for an application that periodically uploads data to a privately hosted broker. The MQTT functionality have been moved to a separate file and modified so that the main loop of the original example is run as a separate thread, handling the MQTT operations.  

In addition I'm using PSM and an upload timing scheme similar to the one in the udp_with_psm example. The MQTT keepalive is set to the PSM TAU period (~300 seconds) in order to avoid unnecessary wake up during the sleep cycle. 

When looking at the power consumption of the example in a power analyser I see that the application consistently has power spikes of ~8mA every ~6 seconds. Do you have any suggestions to how I can avoid these? I have confirmed that it is related to the MQTT operation as the spikes aren't present otherwise, but I struggle to find out exactly what is causing them. 

EDIT: The intervals seems to be of increasing length between each TAU. From what I can see it starts with very short intervals (~600 ms), and then it increases gradually all the way up to ~12s. This seems to reset every time the modem wakes up and transmits. (it's a bit hard to make out the actual intervals during the transmission as it's cluttered with paging spikes)

Attached is a snapshot from the power analyser. The red graph is the MQTT current, the green one is the current of a CoAP application with the same configuration for comparison. 



Do tell if I should provide any more information or code. 

Thanks in advance.

-- Carl Richard

  • Ah, thanks! 

    I chose to remove the function as it did more harm than good. Initiating the disconnection, both with my function and the one you purposed, led to the device entering RRC connected mode thus consuming quite a lot of power. It could be that I did not close it properly, or that the MQTT application did not like the way I did it.

    I can experiment some more with that in the future.  

1 2 3 4 5