<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=MQTT%3A_Arduino_Light_Sensor</id>
	<title>MQTT: Arduino Light Sensor - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=MQTT%3A_Arduino_Light_Sensor"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;action=history"/>
	<updated>2026-04-22T21:57:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;diff=49603&amp;oldid=prev</id>
		<title>Onnowpurbo at 11:56, 19 October 2017</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;diff=49603&amp;oldid=prev"/>
		<updated>2017-10-19T11:56:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&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 class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:56, 19 October 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-l12&quot;&gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #define MQTT_SERVER &amp;quot;192.168.0.100&amp;quot;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #define MQTT_SERVER &amp;quot;192.168.0.100&amp;quot;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // MAC Address of Arduino Ethernet Sheild (on sticker on shield)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // MAC Address of Arduino Ethernet Sheild (on sticker on shield)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte MAC_ADDRESS[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x31, 0xB8 };&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  byte MAC_ADDRESS[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x31, 0xB8 };&lt;/div&gt;&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-l20&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  EthernetClient ethClient;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  EthernetClient ethClient;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  PubSubClient client(server, 1883, callback, ethClient);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  PubSubClient client(server, 1883, callback, ethClient);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // Pin 8 is the LED output pin&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // Pin 8 is the LED output pin&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  int ledPin = 8;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  int ledPin = 8;&lt;/div&gt;&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-l87&quot;&gt;Line 87:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 87:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    client.loop();&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    client.loop();&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // handles message arrived on subscribed topic(s)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  // handles message arrived on subscribed topic(s)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  void callback(char* topic, byte* payload, unsigned int length) {  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  void callback(char* topic, byte* payload, unsigned int length) {  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;diff=47859&amp;oldid=prev</id>
		<title>Onnowpurbo at 01:12, 11 May 2017</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;diff=47859&amp;oldid=prev"/>
		<updated>2017-05-11T01:12:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&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 class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:12, 11 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-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Code:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; 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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #include &amp;lt;SPI.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #include &amp;lt;SPI.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #include &amp;lt;PubSubClient.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #include &amp;lt;PubSubClient.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;diff=47858&amp;oldid=prev</id>
		<title>Onnowpurbo: Created page with &quot; #include &lt;SPI.h&gt;  #include &lt;PubSubClient.h&gt;  #include &lt;Ethernet.h&gt;    /*   * LightSensorMqttDemo   *   * A simple m2m.io platform demo for Arduino.   */    #define MQTT_SERVE...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=MQTT:_Arduino_Light_Sensor&amp;diff=47858&amp;oldid=prev"/>
		<updated>2017-05-11T01:12:02Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; #include &amp;lt;SPI.h&amp;gt;  #include &amp;lt;PubSubClient.h&amp;gt;  #include &amp;lt;Ethernet.h&amp;gt;    &lt;span class=&quot;autocomment&quot;&gt;* LightSensorMqttDemo   *   * A simple m2m.io platform demo for Arduino.: &lt;/span&gt;    #define MQTT_SERVE...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; #include &amp;lt;SPI.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;PubSubClient.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;Ethernet.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * LightSensorMqttDemo&lt;br /&gt;
  *&lt;br /&gt;
  * A simple m2m.io platform demo for Arduino.&lt;br /&gt;
  */&lt;br /&gt;
 &lt;br /&gt;
 #define MQTT_SERVER &amp;quot;192.168.0.100&amp;quot;  &lt;br /&gt;
&lt;br /&gt;
 // MAC Address of Arduino Ethernet Sheild (on sticker on shield)&lt;br /&gt;
 byte MAC_ADDRESS[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x31, 0xB8 };&lt;br /&gt;
 IPAddress ip(192, 168, 0, 4);&lt;br /&gt;
 IPAddress server(192, 168, 0, 100);&lt;br /&gt;
 &lt;br /&gt;
 EthernetClient ethClient;&lt;br /&gt;
 PubSubClient client(server, 1883, callback, ethClient);&lt;br /&gt;
&lt;br /&gt;
 // Pin 8 is the LED output pin&lt;br /&gt;
 int ledPin = 8;&lt;br /&gt;
 // Analog 2 is the input pin&lt;br /&gt;
 int lightPinIn = 2;&lt;br /&gt;
 &lt;br /&gt;
 // defines and variable for sensor/control mode&lt;br /&gt;
 #define MODE_OFF    0  // not sensing light, LED off&lt;br /&gt;
 #define MODE_ON     1  // not sensing light, LED on&lt;br /&gt;
 #define MODE_SENSE  2  // sensing light, LED controlled by software&lt;br /&gt;
 int senseMode = 0;&lt;br /&gt;
 &lt;br /&gt;
 unsigned long time;&lt;br /&gt;
 &lt;br /&gt;
 char message_buff[100];&lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
   // initialize the digital pin as an output.&lt;br /&gt;
   pinMode(ledPin, OUTPUT);&lt;br /&gt;
   &lt;br /&gt;
   // init serial link for debugging&lt;br /&gt;
   Serial.begin(9600);&lt;br /&gt;
   &lt;br /&gt;
   if (Ethernet.begin(MAC_ADDRESS) == 0)&lt;br /&gt;
   {&lt;br /&gt;
       Serial.println(&amp;quot;Failed to configure Ethernet using DHCP&amp;quot;);&lt;br /&gt;
       return;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop()&lt;br /&gt;
 {&lt;br /&gt;
   if (!client.connected())&lt;br /&gt;
   {&lt;br /&gt;
       // clientID, username, MD5 encoded password&lt;br /&gt;
       // arduino-mqtt, mqtt-spt, e10adc3949ba59abbe56e057f20f883e (123456)&lt;br /&gt;
       client.connect(&amp;quot;arduino-mqtt&amp;quot;);&lt;br /&gt;
       client.publish(&amp;quot;arduino/lightsensor&amp;quot;, &amp;quot;I&amp;#039;m alive!&amp;quot;);&lt;br /&gt;
       client.subscribe(&amp;quot;arduino/lightsensor&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   // read from light sensor (photocell)&lt;br /&gt;
   int lightRead = analogRead(lightPinIn);&lt;br /&gt;
 &lt;br /&gt;
   // if there is light in the room, turn off LED&lt;br /&gt;
   // else, if it is &amp;quot;dark&amp;quot;, turn it on&lt;br /&gt;
   // scale of light in this circit is roughly 0 - 900&lt;br /&gt;
   // 900 is a &amp;quot;magic number&amp;quot; for &amp;quot;dark&amp;quot;&lt;br /&gt;
   if (lightRead &amp;gt; 900) {&lt;br /&gt;
      digitalWrite(ledPin, LOW);&lt;br /&gt;
   } else {&lt;br /&gt;
     digitalWrite(ledPin, HIGH);&lt;br /&gt;
   }&lt;br /&gt;
        &lt;br /&gt;
   // publish light reading every 5 seconds&lt;br /&gt;
   if (millis() &amp;gt; (time + 5000)) {&lt;br /&gt;
     time = millis();&lt;br /&gt;
     String pubString = &amp;quot;{\&amp;quot;report\&amp;quot;:{\&amp;quot;light\&amp;quot;: \&amp;quot;&amp;quot; + String(lightRead) + &amp;quot;\&amp;quot;}}&amp;quot;;&lt;br /&gt;
     pubString.toCharArray(message_buff, pubString.length()+1);&lt;br /&gt;
     //Serial.println(pubString);&lt;br /&gt;
     client.publish(&amp;quot;arduino/lightsensor&amp;quot;, message_buff);&lt;br /&gt;
   }&lt;br /&gt;
  &lt;br /&gt;
   // MQTT client loop processing&lt;br /&gt;
   client.loop();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 // handles message arrived on subscribed topic(s)&lt;br /&gt;
 void callback(char* topic, byte* payload, unsigned int length) { &lt;br /&gt;
 &lt;br /&gt;
   int i = 0;  &lt;br /&gt;
 &lt;br /&gt;
   //Serial.println(&amp;quot;Message arrived:  topic: &amp;quot; + String(topic));&lt;br /&gt;
   //Serial.println(&amp;quot;Length: &amp;quot; + String(length,DEC));&lt;br /&gt;
   &lt;br /&gt;
   // create character buffer with ending null terminator (string)&lt;br /&gt;
   for(i=0; i&amp;lt;length; i++) {&lt;br /&gt;
     message_buff[i] = payload[i];&lt;br /&gt;
   }&lt;br /&gt;
   message_buff[i] = &amp;#039;\0&amp;#039;;&lt;br /&gt;
   &lt;br /&gt;
   String msgString = String(message_buff);&lt;br /&gt;
   &lt;br /&gt;
   //Serial.println(&amp;quot;Payload: &amp;quot; + msgString);&lt;br /&gt;
   &lt;br /&gt;
   if (msgString.equals(&amp;quot;{\&amp;quot;command\&amp;quot;:{\&amp;quot;lightmode\&amp;quot;: \&amp;quot;OFF\&amp;quot;}}&amp;quot;)) {&lt;br /&gt;
     senseMode = MODE_OFF;&lt;br /&gt;
   } else if (msgString.equals(&amp;quot;{\&amp;quot;command\&amp;quot;:{\&amp;quot;lightmode\&amp;quot;: \&amp;quot;ON\&amp;quot;}}&amp;quot;)) {&lt;br /&gt;
     senseMode = MODE_ON;&lt;br /&gt;
   } else if (msgString.equals(&amp;quot;{\&amp;quot;command\&amp;quot;:{\&amp;quot;lightmode\&amp;quot;: \&amp;quot;SENSE\&amp;quot;}}&amp;quot;)) {&lt;br /&gt;
     senseMode = MODE_SENSE;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>