<?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>nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55431/nrf-9160-serial-mqtt</link><description>Hello All, 
 I am trying to send data on serial port of nrf9160 to be published on a topic using MQTT protocol. So far using the mqtt example and UART example, I have successfully run both code independently not with each other . I am not sure how to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Dec 2019 09:35:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55431/nrf-9160-serial-mqtt" /><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224869?ContentTypeID=1</link><pubDate>Wed, 11 Dec 2019 09:35:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81b8ed91-1d6b-40a8-ba7c-5908c059d61f</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;&lt;span&gt;Every time you change prj.conf you have to rebuild your project.&amp;nbsp;If using SEGGER, you have to open it again (File--&amp;gt;Open nRF Connect SDK Project) for the changes in prj.conf to take effect.&amp;nbsp;In west I think it is enough to rebuild your project (west build -b nrf9160_pca10090ns). &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can also change it using&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial#h171sjwm57amqljixlgj8fsbkhn3627"&gt;menuconfig&lt;/a&gt;&lt;span&gt;, but then it will get deleted when you rebuild your project, and I would not recommend doing this for permanent changes (only temporary changes for testing).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224807?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 18:21:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24440536-b88e-450d-8627-efe0bf7288d1</guid><dc:creator>nordicuser91</dc:creator><description>&lt;p&gt;&lt;span&gt;I&amp;nbsp;&lt;/span&gt;tried to do some debugging and went to the&amp;nbsp;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/mqtt_simple"&gt;first example&lt;/a&gt;&amp;nbsp;through which I wanted to check whether my sim has some data or not, Actually it had. It has now more than 10MB of data. Then I tried the following&lt;/p&gt;
&lt;p&gt;So I just noticed that when you make changes to the topic in prj.conf or prj_quemo_x86 files it doesn&amp;#39;t reflect to the change. I tried to publish and subscribe on the new chnaged topic name and it doesn&amp;#39;t work. It works on the old topic. To confirm that, I did a clean build and restarted the segger studio also and downloaded the new firmware to nrf9160 but still seems to use the old topic. That might be one of the problems too.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224578?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 00:04:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f65b07c2-6eb0-4f54-9b7a-88cdb91c297d</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;It seems like you haven&amp;#39;t&amp;nbsp;configured Tera Term correctly, do the following:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/pastedimage1575936008478v1.png" alt=" " /&gt;&amp;#39;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/pastedimage1575936061742v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;This will generate a 13 (CR) + 10 (LF)&amp;nbsp; when enter is pressed, and the message will get published.&lt;/p&gt;
&lt;p&gt;Another way of solving it is to edit the code to look for both &lt;span&gt;13 (CR) and 10 (LF):&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//Check if last char is &amp;#39;LF&amp;#39; or &amp;#39;CR&amp;#39;
                if(uart_buf[data_length-1] == 10 || uart_buf[data_length-1] == 13){
                      printk(&amp;quot;last char is &amp;#39;LF&amp;#39;, call k_work_submit(), word number %d \n&amp;quot;, serial_in_count);
                      w_data[serial_in_count].data_len = tot_len - 1;
                      k_work_submit(&amp;amp;w_data[serial_in_count].work);
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224577?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 22:24:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:034add2f-a497-439d-b872-dc27d0a5158b</guid><dc:creator>nordicuser91</dc:creator><description>&lt;p&gt;I did the exact the same steps but it doesn&amp;#39;t seem to to show up on my terminal&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/960x720/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/Capture.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;I did press enter after typing&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/960x720/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/Capture1.PNG" /&gt;If its not a problem could we have a zoom conference where I could share my screen with you and you could help me out with this.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224576?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 10:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3fb00d3-f4f2-4758-b06b-87e522d05609</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;The sample works in the following manner&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Several work items are initialized:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;for(int i=0; i &amp;lt; SERIAL_Q_SIZE; i++){
    k_work_init(&amp;amp;w_data[i].work, pub_uart_mqtt);
}&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Serial data is sent from the computer to nRF9160 through a micro USB and&amp;nbsp;&lt;em&gt;uart_cb()&amp;nbsp;&lt;/em&gt;gets called&lt;/li&gt;
&lt;li&gt;In&amp;nbsp;&lt;em&gt;uart_cb()&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/em&gt;the incoming serial data is processed and put into the queue (at the top of main.c I have created an array of&amp;nbsp;&lt;em&gt;static struct work_data&lt;/em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;of size 5)&lt;/li&gt;
&lt;li&gt;Each incoming element (separated by 10 (=LF)) is submitted to the work queue through&amp;nbsp;&lt;em&gt;k_work_submit()&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;When the work queue Thread gets scheduled to run, it will call&amp;nbsp;&lt;em&gt;pub_uart_mqtt()&amp;nbsp;&lt;/em&gt;for each element, where the elements will be published to the topic&amp;nbsp;&lt;span&gt;CONFIG_MQTT_PUB_TOPIC through&amp;nbsp;&lt;em&gt;data_publish()&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;Try following these steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Put the sample into NCS of version 1.1.0 in the following folder:&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;ncs\nrf\samples\nrf9160&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Download and install Mosquitto on your computer:&amp;nbsp;&lt;a href="https://mosquitto.org/download/"&gt;https://mosquitto.org/download/&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/"&gt;Add the Mosquitto folder to the System Variables path&lt;/a&gt;:&amp;nbsp;&lt;em&gt;C:\Program Files\Mosquitto&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Make sure the following are set in prj.conf:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_MQTT_PUB_TOPIC=&amp;quot;/my/publish/topic&amp;quot;
CONFIG_MQTT_SUB_TOPIC=&amp;quot;/my/subscribe/topic&amp;quot;
CONFIG_MQTT_CLIENT_ID=&amp;quot;my-client-id&amp;quot;
CONFIG_MQTT_BROKER_HOSTNAME=&amp;quot;mqtt.eclipse.org&amp;quot;
CONFIG_MQTT_BROKER_PORT=1883&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Build and run the sample&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;west build -b nrf9160_pca10090ns&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;nrfjprog --eraseall&lt;/li&gt;
&lt;li&gt;west flash&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Subscribe to the topic&amp;nbsp;&lt;em&gt;/my/publish/topic -v&amp;nbsp;&lt;/em&gt;from the mosquitto broker, by typing the following in a command line (cmd, git bash etc..)&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;mosquitto_sub&amp;nbsp;-h mqtt.eclipse.org -t /my/publish/topic -v&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Open&amp;nbsp;&lt;a href="https://download.cnet.com/Tera-Term/3000-2094_4-75766675.html"&gt;Tera Term&lt;/a&gt;&amp;nbsp;with the following setup:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/pastedimage1575885996843v3.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/pastedimage1575885996843v4.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Then, in Tera Term, type in e.g. &amp;quot;Hey&amp;quot;, followed by enter and you should see the following response in the command line where&amp;nbsp;&lt;em&gt;mosquitto_sub&amp;nbsp;-h&amp;nbsp;&lt;/em&gt;were called&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;C:\Users\Simon&amp;gt;mosquitto_sub -h mqtt.eclipse.org -t /my/publish/topic -v
/my/publish/topic Hey&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="left:606px;top:193.333px;"&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224575?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 05:36:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de3c843d-392a-4342-a0ca-07d2aa6abd16</guid><dc:creator>nordicuser91</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;The example seems great, but its not working on my board. I get some data on serial port which is the loopback but it doesn&amp;#39;t seem to publish. I seems the configuration for the topic is same as before with some little changes on yours. I double checked the publish, subscribe topic with port and server name, but still doesn&amp;#39;t seem to work. Could you please help me out with.Also feel free to make the topic public.&lt;/p&gt;
&lt;p&gt;Thanks a lot again I really appreciate your help and follow up.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Nordic User&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224574?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 01:51:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55532928-63eb-4d2e-b805-52302811c978</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I quickly put together a sample that publishes serial input to&amp;nbsp;CONFIG_MQTT_PUB_TOPIC using &lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/threads/workqueue.html"&gt;Workqueue Threads&lt;/a&gt;. I have not tested the program extensively and it may contain bugs/errors.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-fb2e1c53912c43ccb23d394510c6ec53/mqtt_5F00_w_5F00_uart.zip"&gt;devzone.nordicsemi.com/.../mqtt_5F00_w_5F00_uart.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The program will not publish until you press&amp;nbsp;&lt;a href="https://www.google.com/imgres?imgurl=https%3A%2F%2Fcdn1.iconfinder.com%2Fdata%2Ficons%2Foffice-and-internet-2%2F49%2F130-512.png&amp;amp;imgrefurl=https%3A%2F%2Fwww.iconfinder.com%2Ficons%2F3040587%2Fenter_button_enter_key_enter_tab_keyboard_enter_keyboard_enter_tab_icon&amp;amp;docid=mY8FDsPfoqf8-M&amp;amp;tbnid=ubfd-Dnt8dStdM%3A&amp;amp;vet=10ahUKEwj155mnuafmAhUr0aYKHa_XCAIQMwhSKAwwDA..i&amp;amp;w=512&amp;amp;h=512&amp;amp;bih=642&amp;amp;biw=1422&amp;amp;q=enter%20keyboard&amp;amp;ved=0ahUKEwj155mnuafmAhUr0aYKHa_XCAIQMwhSKAwwDA&amp;amp;iact=mrc&amp;amp;uact=8"&gt;enter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Should we make this ticket public? Then other people can benefit from the solution.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224573?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 18:46:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c7ce8ac-5935-4e25-81ba-69dfc84b8e92</guid><dc:creator>nordicuser91</dc:creator><description>&lt;p&gt;Thanks Simon, Looking forward to it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;
&lt;p&gt;Nordic User&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224572?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 14:39:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d6b1318-931c-44ac-8af4-adcfea66bce9</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I will try to have an example ready by Monday.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224571?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 02:32:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:027487f6-afb5-40b0-a974-4131e9c2a2ee</guid><dc:creator>nordicuser91</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
&lt;p&gt;It would be a great help if you could write me a simple example. That way I can understand much better on how the mqtt is being used. I would really appreciate your help.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks a lot&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Nordic User&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf 9160 Serial MQTT</title><link>https://devzone.nordicsemi.com/thread/224570?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 00:15:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dca6dc85-20f9-4aea-9c9a-21319196faa9</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Why are you putting&amp;nbsp;&lt;em&gt;data_publish()&lt;/em&gt; inside&amp;nbsp;&lt;em&gt;case MQTT_EVT_PUBLISH&lt;/em&gt;? Then you have to wait for a message to be published to a topic you are subscribed to (I understand that the naming conventions may confuse you), check the&amp;nbsp;definition of&amp;nbsp;&lt;em&gt;MQTT_EVT_PUBLISH:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/** Publish event received when message is published on a topic client
 *  is subscribed to.
 *
 * @note PUBLISH event structure only contains payload size, the payload
 *       data parameter should be ignored. Payload content has to be
 *       read manually with @ref mqtt_read_publish_payload function.
 */
MQTT_EVT_PUBLISH,&lt;/pre&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The reason it is done this way in the MQTT Simple example is to provide a loopback. First, the device receives a message on&amp;nbsp;CONFIG_MQTT_SUB_TOPIC, then it sends the same data to&amp;nbsp;CONFIG_MQTT_PUB_TOPIC. You are not interested in this loopback, you just want to send data that is received from UART.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should just call&amp;nbsp;&lt;em&gt;data_publish(&amp;amp;client, MQTT_QOS_1_AT_LEAST_ONCE, uart_buf, strlen(uart_buf))&amp;nbsp;&lt;/em&gt;in response to&amp;nbsp;&lt;em&gt;uart_cb().&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If anything is unclear, or if you want me to write a simple example demonstrating this, please tell me.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>