<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://pvlng.com/index.php?action=history&amp;feed=atom&amp;title=MQTT</id>
		<title>MQTT - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://pvlng.com/index.php?action=history&amp;feed=atom&amp;title=MQTT"/>
		<link rel="alternate" type="text/html" href="https://pvlng.com/index.php?title=MQTT&amp;action=history"/>
		<updated>2026-05-09T14:48:11Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://pvlng.com/index.php?title=MQTT&amp;diff=1598&amp;oldid=prev</id>
		<title>KKoPV: /* Terminal 1 - Start subscriber */</title>
		<link rel="alternate" type="text/html" href="https://pvlng.com/index.php?title=MQTT&amp;diff=1598&amp;oldid=prev"/>
				<updated>2017-05-17T20:07:08Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Terminal 1 - Start subscriber&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:07, 17 May 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l38&quot; &gt;Line 38:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 38:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Wait for 1 message, print verbose message and exit&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Wait for 1 message, print verbose message and exit&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; # mosquitto_sub -d -v -i test-subscriber -t test &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;-c &lt;/del&gt;-C 1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; # mosquitto_sub -d -v -i test-subscriber -t test -C 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; Client test-subscriber sending CONNECT&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; Client test-subscriber sending CONNECT&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; Client test-subscriber received CONNACK&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; Client test-subscriber received CONNACK&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key knut_pvlng:diff:version:1.11a:oldid:1597:newid:1598 --&gt;
&lt;/table&gt;</summary>
		<author><name>KKoPV</name></author>	</entry>

	<entry>
		<id>https://pvlng.com/index.php?title=MQTT&amp;diff=1597&amp;oldid=prev</id>
		<title>KKoPV: Created page with &quot;{{TOCright}}PVLng can listen to a MQTT broker running on any server.  &lt;blockquote&gt;MQTT is a machine-to-machine (M2M)/&quot;Internet of Things&quot; connectivity protocol. It was designe...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pvlng.com/index.php?title=MQTT&amp;diff=1597&amp;oldid=prev"/>
				<updated>2017-05-17T20:06:23Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{TOCright}}PVLng can listen to a MQTT broker running on any server.  &amp;lt;blockquote&amp;gt;MQTT is a machine-to-machine (M2M)/&amp;quot;Internet of Things&amp;quot; connectivity protocol. It was designe...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{TOCright}}PVLng can listen to a MQTT broker running on any server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;MQTT is a machine-to-machine (M2M)/&amp;quot;Internet of Things&amp;quot; connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. -- [http://mqtt.org/ MQTT]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PVLng scripts can send to any MQTT broker.&lt;br /&gt;
&lt;br /&gt;
== Setup your own mosquitto broker ==&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install mosquitto&lt;br /&gt;
&lt;br /&gt;
If you run the PVLng scripts also on this host or on remote equipment running the scripts only you need only the clients scripts&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get update&lt;br /&gt;
 sudo apt-get install mosquitto-clients&lt;br /&gt;
&lt;br /&gt;
== Configure MQTT broker ==&lt;br /&gt;
&lt;br /&gt;
Put the following into &amp;lt;tt&amp;gt;/etc/mosquitto/conf.d/local.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOT | sudo tee /etc/mosquitto/conf.d/local.conf&lt;br /&gt;
 log_type error&lt;br /&gt;
 log_type warning&lt;br /&gt;
 log_type notice&lt;br /&gt;
 log_type information&lt;br /&gt;
 connection_messages true&lt;br /&gt;
 log_timestamp true&lt;br /&gt;
 EOT&lt;br /&gt;
&lt;br /&gt;
And restart&lt;br /&gt;
&lt;br /&gt;
 sudo /etc/init.d/mosquitto restart&lt;br /&gt;
&lt;br /&gt;
Test your broker best with 2 terminals&lt;br /&gt;
&lt;br /&gt;
=== Terminal 1 - Start subscriber ===&lt;br /&gt;
&lt;br /&gt;
Wait for 1 message, print verbose message and exit&lt;br /&gt;
&lt;br /&gt;
 # mosquitto_sub -d -v -i test-subscriber -t test -c -C 1&lt;br /&gt;
 Client test-subscriber sending CONNECT&lt;br /&gt;
 Client test-subscriber received CONNACK&lt;br /&gt;
 Client test-subscriber sending SUBSCRIBE (Mid: 1, Topic: test, QoS: 0)&lt;br /&gt;
 Client test-subscriber received SUBACK&lt;br /&gt;
 Subscribed (mid: 1): 0&lt;br /&gt;
&lt;br /&gt;
=== Terminal 2 - Publish a zero length test message ===&lt;br /&gt;
&lt;br /&gt;
 # mosquitto_pub -d -n -i test-publisher -h localhost -t test&lt;br /&gt;
 Client test-publisher sending CONNECT&lt;br /&gt;
 Client test-publisher received CONNACK&lt;br /&gt;
 Client test-publisher sending PUBLISH (d0, q0, r0, m1, 'test', ... (0 bytes))&lt;br /&gt;
 Client test-publisher sending DISCONNECT&lt;br /&gt;
&lt;br /&gt;
=== Terminal 1 - Received the message? ===&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 Client test-subscriber received PUBLISH (d0, q0, r0, m0, 'test', ... (0 bytes))&lt;br /&gt;
 test (null)&lt;br /&gt;
 Client test-subscriber sending DISCONNECT&lt;br /&gt;
&lt;br /&gt;
== Run PVLng MQTT subscriber ==&lt;br /&gt;
&lt;br /&gt;
The script is &amp;lt;tt&amp;gt;tools/mqtt-subscribe.sh&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start it at reboot via cron&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOT | sudo tee /etc/cron.d/mqtt-subscribe&lt;br /&gt;
 # MQTT listener, wait for mosquitto broker&lt;br /&gt;
 @reboot root sleep 60 &amp;amp;&amp;amp; /path/to/PVLng/tools/mqtt-subscribe.sh start &amp;gt;/dev/null&lt;br /&gt;
 # And check at least each hour&lt;br /&gt;
 0 * * * * root /path/to/PVLng/tools/mqtt-subscribe.sh start &amp;gt;/dev/null&lt;br /&gt;
 EOT&lt;br /&gt;
&lt;br /&gt;
Check for safety reasons each hour.&lt;br /&gt;
&lt;br /&gt;
To store data into PVLng database send a message to topic&lt;br /&gt;
&lt;br /&gt;
 pvlng/&amp;lt;API key&amp;gt;/data/&amp;lt;Channel GUID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure PVLng scripts ==&lt;br /&gt;
&lt;br /&gt;
The scripts check for configured MQTT broker and use it, otherwise the default curl method is used as before.&lt;br /&gt;
&lt;br /&gt;
You need only set the MQTT broker in &amp;lt;tt&amp;gt;PVLng.conf&amp;lt;/tt&amp;gt; and uncomment the line.&lt;br /&gt;
&lt;br /&gt;
 ##############################################################################&lt;br /&gt;
 ### Send to mosquitto broker running on $mosquittoServer&lt;br /&gt;
 ##############################################################################&lt;br /&gt;
 ### &amp;lt;Sever&amp;gt;[:&amp;lt;port&amp;gt;]&lt;br /&gt;
 #mosquittoServer=$PVLngDomain:1883&lt;br /&gt;
&lt;br /&gt;
If you test your scripts and send data, you can watch the stream in a terminal with&lt;br /&gt;
&lt;br /&gt;
 mosquitto_sub -v -t pvlng/+/data/#&lt;br /&gt;
&lt;br /&gt;
This will give you something like this (2 temperature sensors)&lt;br /&gt;
&lt;br /&gt;
 pvlng/df9adc61-e81b-1e12-8fc7-8a1f000a3025/data/72f9-9c42-36c5-c2af-3c01-cd95-67a1-98d1 {&amp;quot;data&amp;quot;:&amp;quot;29.5&amp;quot;,&amp;quot;timestamp&amp;quot;:&amp;quot;1495051260&amp;quot;}&lt;br /&gt;
 pvlng/df9adc61-e81b-1e12-8fc7-8a1f000a3025/data/bef9-6e8b-29a1-15a3-4100-58d2-69b8-3bdb {&amp;quot;data&amp;quot;:&amp;quot;24.1875&amp;quot;,&amp;quot;timestamp&amp;quot;:&amp;quot;1495051260&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>KKoPV</name></author>	</entry>

	</feed>