<?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>Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75666/receive-data-to-nrf9160-from-the-server-using-mqtt</link><description>Hi, 
 I am developing the system where I am sending the data of three sensors to the server using MQTT. For the above development, I used two microcontrollers one to collect the data from the sensors and nrf9160 to handle MQTT Prorocol. 
 Also need to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Jun 2021 06:52:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75666/receive-data-to-nrf9160-from-the-server-using-mqtt" /><item><title>RE: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312744?ContentTypeID=1</link><pubDate>Tue, 01 Jun 2021 06:52:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f2cb3fc-3581-4193-91cd-94f587e93cae</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="Rkidechaa"]&lt;p&gt;I am using mqtt_simple sample code to subscribe to one topic and need to store the received data from that subscribe topic.&lt;/p&gt;
&lt;p&gt;So where exactly that data stores ?&lt;/p&gt;[/quote]
&lt;p&gt;The data is available when you get&amp;nbsp;the&amp;nbsp;&lt;span&gt;MQTT_EVT_PUBLISH event. I showed that specific sample, because the mqtt_simple did not really show fetching the data clearly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please see the same event in mqtt_simple for reference.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Håkon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312692?ContentTypeID=1</link><pubDate>Mon, 31 May 2021 15:01:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9a6979c-45ef-45d7-b217-bcb1178959c4</guid><dc:creator>Rkidechaa</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="2115" url="~/f/nordic-q-a/75666/receive-data-to-nrf9160-from-the-server-using-mqtt/312550#312550"]&lt;p&gt;The received data? That is available in the callback handler:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.5.1/samples/nrf9160/aws_fota/src/main.c#L196-L227"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v1.5.1/samples/nrf9160/aws_fota/src/main.c#L196-L227&lt;/a&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I am using mqtt_simple sample code to subscribe to one topic and need to store the received data from that subscribe topic.&lt;/p&gt;
&lt;p&gt;So where exactly that data stores ?&lt;/p&gt;
[quote userid="2115" url="~/f/nordic-q-a/75666/receive-data-to-nrf9160-from-the-server-using-mqtt/312550#312550"]&lt;p&gt;the mqtt library requires that mqtt_input() is called in between each operation.&lt;/p&gt;
&lt;p&gt;Note that sending data each 5 minutes will be power consuming for your application. If your application is battery powered, you should consider buffering up data, and sending over the network in larger chunks once per hour for instance. I fully understand that&amp;nbsp;buffering up packets isn&amp;#39;t always possible, as latency also plays in as a factor.&lt;/p&gt;[/quote]
&lt;p&gt;Thank you for advice. But we want to plot real time graph from those data. So that is why we chose to send after every 5 min as per battery consideration.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks you,&lt;/p&gt;
&lt;p&gt;Rahul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312550?ContentTypeID=1</link><pubDate>Mon, 31 May 2021 07:44:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cf3269e-b8b0-494d-a7e2-928fda1df7e6</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Rahul,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Rkidechaa"]Now I don&amp;#39;t know where exactly it storing the feedback data because I need to use that data to enable and disable the sensor.[/quote]
&lt;p&gt;The received data? That is available in the callback handler:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.5.1/samples/nrf9160/aws_fota/src/main.c#L196-L227"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v1.5.1/samples/nrf9160/aws_fota/src/main.c#L196-L227&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Rkidechaa"]publishing data to broker and receiving data from broker will work parallel ? Because I got the error (&lt;span&gt;#&lt;/span&gt;&lt;span&gt;define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;EBUSY&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;16&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;/* Mount device busy */ ) when&amp;nbsp;&lt;/span&gt;tried to receive the data from broker when nrf9160 publishing some other data to broker. (topic name is different)[/quote]
&lt;p&gt;Not sure which call returns EBUSY, but in general you need to invoke the mqtt state machine in between each transfer (ie: let the main loop run).&lt;/p&gt;
&lt;p&gt;Could you share where you get this error and what calls you queued up previous to this error?&lt;/p&gt;
[quote user="Rkidechaa"]If parallel is not possible then what could be fastest way to work in continues mode. like publishing and receiving works simultaneously. In our project we are sending the data over LTE in every 5 minute.&amp;nbsp;[/quote]
&lt;p&gt;the mqtt library requires that mqtt_input() is called in between each operation.&lt;/p&gt;
&lt;p&gt;Note that sending data each 5 minutes will be power consuming for your application. If your application is battery powered, you should consider buffering up data, and sending over the network in larger chunks once per hour for instance. I fully understand that&amp;nbsp;buffering up packets isn&amp;#39;t always possible, as latency also plays in as a factor.&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: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312476?ContentTypeID=1</link><pubDate>Fri, 28 May 2021 22:18:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a2c0a3a-56c1-486c-b551-7b3f37e9716c</guid><dc:creator>Rkidechaa</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;Thank you for your reply.&lt;/p&gt;
&lt;p&gt;1) To receive the data from server I used different topic and it worked.&lt;/p&gt;
&lt;p&gt;Now I don&amp;#39;t know where exactly it storing the feedback data because I need to use that data to enable and disable the sensor.&lt;/p&gt;
&lt;p&gt;2) publishing data to broker and receiving data from broker will work parallel ? Because I got the error (&lt;span&gt;#&lt;/span&gt;&lt;span class="pl-k"&gt;define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="pl-en"&gt;EBUSY&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="pl-c1"&gt;16&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="pl-c"&gt;/* Mount device busy */ ) when&amp;nbsp;&lt;/span&gt;tried to receive the data from broker when nrf9160 publishing some other data to broker. (topic name is different)&lt;/p&gt;
&lt;p&gt;3) If parallel is not possible then what could be fastest way to work in continues mode. like publishing and receiving works simultaneously. In our project we are sending the data over LTE in every 5 minute.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you in Advance.&lt;/p&gt;
&lt;p&gt;With Regards,&lt;br /&gt;Rahul&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312268?ContentTypeID=1</link><pubDate>Fri, 28 May 2021 07:02:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7db811e-0058-4ea6-b713-f50c8974b4ed</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Rahul,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Rkidechaa"]Just to make sure, So in this situation server would be the publisher and Nordic device will become subscriber. Right?[/quote]
&lt;p&gt;You subscribe to a topic, and when anyone publishes to that topic; you will be notified with the data.&lt;/p&gt;
&lt;p&gt;The publisher can be anyone&amp;nbsp;connected to the mqtt-broker.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Rkidechaa"]Can we use same topic which we used to send data or need to create different topic name ?[/quote]
&lt;p&gt;&amp;nbsp;Yes, that is possible. Usually you want to differentiate your subscribed and publish topics; but this shall work.&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: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312174?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 15:08:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21a5e361-9775-4ebc-ad8b-d82859beeddd</guid><dc:creator>Rkidechaa</dc:creator><description>[quote userid="2115" url="~/f/nordic-q-a/75666/receive-data-to-nrf9160-from-the-server-using-mqtt/312142#312142"]When your node should fetch data from the server, you subscribe to a specific topic.[/quote]
&lt;p&gt;Just to make sure, So in this situation server would be the publisher and Nordic device will become subscriber. Right?&lt;/p&gt;
&lt;p&gt;Can we use same topic which we used to send data or need to create different topic name ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Rahul Kidecha&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receive data to nrf9160 from the server using MQTT</title><link>https://devzone.nordicsemi.com/thread/312142?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 13:41:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c92d6181-d189-4743-bf3a-e904dd608a8b</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=""]&lt;p&gt;1) To receive the data from the server can I use the same channel which I am using to send data to a server?&lt;/p&gt;
&lt;p&gt;or do I need to create a different channel for it?&lt;/p&gt;[/quote]
&lt;p&gt;When you are pushing data from your nodes to the server, you are publishing data on a specific topic. Anyone that is subscribed to this topic, can then read the data.&lt;/p&gt;
&lt;p&gt;When your node should fetch data from the server, you subscribe to a specific topic.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can read more about mqtt in general here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.steves-internet-guide.com/mqtt-works/"&gt;http://www.steves-internet-guide.com/mqtt-works/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The mqtt_simple sample has setup for subscribe and publish.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>