<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>Joezekistan Ministry of Public Works</title>
	<link href="http://joezekistan.com/projects/atom.php" rel="self" />
	<link href="http://joezekistan.com/projects/" />
	<id>http://joezekistan.com/projects/index.php</id>
	<updated>2026-04-29T21:57:38Z</updated>
	<author>
		<name>joe@joezekistan.com</name>
		<email>joe@joezekistan.com</email>
	</author>
	<entry>
		<title>Simple AC Monitor for Arduino</title>
		<link href="http://joezekistan.com/projects/index.php?entry=entry140316-074429" />
		<link rel="alternate" type="text/html" href="http://joezekistan.com/projects/index.php?entry=entry140316-074429" />
		<link rel="edit" href="http://joezekistan.com/projects/index.php?entry=entry140316-074429" />
		<id>http://joezekistan.com/projects/index.php?entry=entry140316-074429</id>
		<summary type="html"><![CDATA[A major part of my solar project is to provide emergency lighting for when the power goes out.  It doesn&#039;t happen very often.  Unfortunately, every time the commercial AC goes away (due to storms, etc.), my flashlights are all somewhere else - usually somewhere that would require a flashlight in order to find them.<br /><br />My thinking was that it would be awesome if I could simply have a couple of strategically placed DC lights that hooked into the solar controller batteries.  It would be even better if they would just magically come on when the power went off.  Sounds simple, right?  Well, I thought so, too.  Since I&#039;ve been enjoying the Arduino stuff so much, and it would be cool to actually make something useful with one, I thought this would be an ideal project.<br /><br />So off I went to ask my pal Google what it takes to monitor the AC.  Google was somewhat helpful, but it looked like everything that had been built was relying on relays, opto-isolation circuits, a used space shuttle, or some other gizmo that wasn&#039;t in my junk drawer.  I found one interesting thread that talked about using a wall wart, which felt right to me, but I didn&#039;t have anything suitable there either.<br /><br />Then I plugged in my cell phone to charge it up...<br /><br />There it was!  I had a nice regulated 5v (presumably) power source that connected right into the AC.  The Fluke quickly revealed it to be a 5.07vDC source (close enough).  You should check yours before you hook it up, too, by the way.<br /><br />So I stripped a USB cable (lots of extras around here), hooked the ground into the Arduino, hooked the positive power lead into an analog pin, and started playing around.  Eventually, I ended up with a monitor that has LEDs for status and a really loud buzzer.  I&#039;ve stripped away all but the essentials for you guys so that you can build whatever you like into yours.<br /><br />Here&#039;s how it looks:<br /><br /><img src="images/SimpleACMonitor.png" width="500" height="323" alt="" /><br /><br />... and here&#039;s a basic sketch:<br /><br /><pre><br />/*<br />  Simple AC Power Monitor<br />  J. McNeely<br />  2014-03-16<br />  <br />  This sketch allows a cheap and simple way of detecting an AC power<br />  failure.  I looked all over for a simple way to do this, and found<br />  that this is very inexpensive, and appears to be quite accurate.<br />  <br />  In order for this idea to work, the Arduino must be powered by <br />  batteries or alternative sources (mine is the solar gear).<br />  <br />  This sketch is just a basic starter setup to be incorporated into<br />  whatever larger project you have in mind.<br />  <br />  Best of Luck!<br />  Joe<br />  <br />*/<br /><br />#define ALARMPIN 2<br />#define POWERSENSEPIN A1<br /><br />float  voltage = 5;<br />float  voltageThreshold = 4.5;<br /><br />float  powerVal = 1023;<br />float  powerValPrv = powerVal;<br />int    powerState = 1;<br />int    powerStatePrv = powerState;<br />long   lastPowerDebounceTime = 0;<br />long   debouncePowerDelay = 5000;  // Delay before power status is considered to have changed.<br />int    alarmState = LOW;<br />int    alarmFlag = 0;<br /><br /><br />void setup() {<br />  pinMode(POWERSENSEPIN, INPUT_PULLUP);<br />  pinMode(ALARMPIN, OUTPUT);<br />  powerVal = analogRead(POWERSENSEPIN);<br />  voltage = powerVal * (5.0 / 1023.0);<br />  if (voltage &gt; voltageThreshold) {<br />    powerState = 1;<br />    alarmState = HIGH;<br />    powerValPrv = powerVal;<br />  } else {<br />    powerState = 0;<br />    alarmState = LOW;<br />    powerValPrv = powerVal;<br />  }<br />  digitalWrite(ALARMPIN, alarmState)<br />  Serial.begin(9600);<br />  Serial.println(&quot;Commercial Power Monitor&quot;);<br />  Serial.println(&quot;------------------------&quot;);<br />  Serial.println();<br />}<br /><br />void loop()<br />{<br />  if ((millis() - lastPowerDebounceTime) &gt; debouncePowerDelay) {<br />    powerVal = analogRead(POWERSENSEPIN);<br />    voltage = powerVal * (5 / 1023.0);<br />    if (voltage &gt; voltageThreshold) {<br />      powerState = 1;<br />      setAlarm(0);<br />    } else {<br />      powerState = 0;<br />      setAlarm(1);<br />    }<br />  }<br />  <br />  if (powerState != powerStatePrv) {<br />    lastPowerDebounceTime = millis();<br />    setPowerChange();<br />  }<br />}<br /><br />void setPowerChange() {<br />  // This is a stub.  More complex actions may be hooked into this function.<br />  powerStatePrv = powerState;<br />  Serial.print(&quot;\nCommercial Power Changed: &quot;);<br />  if (powerState == 1) {<br />    Serial.println(&quot;Power Restored&quot;);<br />  } else if (powerState == 0) {<br />    Serial.println(&quot;Power Failure&quot;);<br />  }<br />}<br /><br />void setAlarm(int alarmAction) {<br />  // This is a stub.  The ALARMPIN could be connected to an LED, buzzer, relay, whatever.<br />  if (alarmAction == 0) {<br />    alarmFlag = 0;<br />    alarmState = LOW;<br />    digitalWrite(ALARMPIN,alarmState);<br />  } else if (alarmAction == 1) {<br />    alarmFlag = 1;<br />    alarmState = HIGH;<br />    digitalWrite(ALARMPIN,alarmState);<br />  }<br />}<br /></pre><br /><br />To test it, just plug the USB charger into a power strip and open the serial monitor in the IDE.  Switch off the power strip, and wait for the delay, then you&#039;ll see the power failure message in the serial monitor.  Turn the power strip back on, and you&#039;ll see the restored message.  Simple, eh?<br /><br />Happy Hacking!<br />Joe]]></summary>
		<updated>2014-03-16T14:44:29Z</updated>
	</entry>
	<entry>
		<title>Another Arduino Sketch for the DHT-11</title>
		<link href="http://joezekistan.com/projects/index.php?entry=entry140225-062907" />
		<link rel="alternate" type="text/html" href="http://joezekistan.com/projects/index.php?entry=entry140225-062907" />
		<link rel="edit" href="http://joezekistan.com/projects/index.php?entry=entry140225-062907" />
		<id>http://joezekistan.com/projects/index.php?entry=entry140225-062907</id>
		<summary type="html"><![CDATA[If you would prefer a web-based sketch, I&#039;ve also been playing around with this one.  This may require a 2560.  I haven&#039;t tried it on an Uno...<br /><br />This one also has a telnet interface.  There is no real need for it, I suppose.  I just built it because it sounded interesting.<br /><br /><pre>#include &lt;Ethernet.h&gt;<br />#include &lt;SPI.h&gt;<br />#include &quot;DHTSensor.h&quot;<br /><br />// Network config<br />byte mac[] =     { 0xAA, 0x00, 0x00, 0xE1, 0x00, 0x72};<br />byte ip[]  =     {192, 168, 100, 72};<br />byte gateway[] = {192, 168, 100, 254};<br />byte subnet[]  = {255, 255, 255, 0};<br /><br />// Device config<br />#define DEVID &quot;F2&quot;<br />#define SENSORNAME &quot;Upstairs&quot;<br /><br />// Other globals<br />#define VERSION &quot;1.3&quot;<br />#define TELNETPORT 2323<br />#define WEBPORT 8080<br />#define DHTTYPE DHT11<br />#define DHTPIN 2<br />#define textBuffSize 20 //length of longest command string plus two spaces for CR + LF<br />String rcvdCmd = &quot;&quot;;<br />int charsReceived = 0;<br />boolean connectFlag = 0;<br />unsigned long timeOfLastActivity; //time in milliseconds of last activity<br />unsigned long allowedConnectTime = 300000; //five minutes<br />EthernetServer telnetServer(TELNETPORT);<br />EthernetClient telnetClient = 0;<br />EthernetServer webServer(WEBPORT);<br />EthernetClient webClient = 0;<br />DHT dht(DHTPIN, DHTTYPE);<br />float humid;<br />float tempf;<br /><br />// State Variables<br />char* commandText = &quot;&quot;;<br />char* devId = DEVID;<br />char* sensorName = SENSORNAME;<br />                   <br />void setup()<br />{<br />  Ethernet.begin(mac, ip, gateway, subnet);<br />  Serial.begin(9600);<br />  telnetServer.begin();<br />  webServer.begin();<br />  Serial.println(&quot;Remote Environment Monitor&quot;);<br />  Serial.print(&quot;Version &quot;);<br />  Serial.println(VERSION);<br />  Serial.println();<br />  Serial.print(&quot;Telnet service listening on port &quot;);<br />  Serial.println(TELNETPORT);<br />  Serial.print(&quot;Web service listening on port &quot;);<br />  Serial.println(WEBPORT);<br />  Serial.println();<br />  dht.begin();<br />}<br /><br />void loop()<br />{<br />  if (telnetServer.available() &amp;&amp; !connectFlag) {<br />    connectFlag = 1;<br />    telnetClient = telnetServer.available();<br />    telnetClient.println(&quot;\nRemote Environment Monitor&quot;);<br />    telnetClient.print(&quot;Device: &quot;);<br />    telnetClient.print(devId);<br />    telnetClient.print(&quot;  Sensor: &quot;);<br />    telnetClient.println(sensorName);<br />    telnetClient.println();<br />    showPrompt();<br />  }<br />  <br />  if (telnetClient.connected() &amp;&amp; telnetClient.available()) getReceivedText();<br /><br />  if(connectFlag) checkConnectionTimeout();<br />  <br />  webClient = webServer.available();<br />  <br />  if (webClient) {<br />    sendWebPage();<br />  }<br />}<br /><br />void showPrompt()<br />{<br />  timeOfLastActivity = millis();<br />  telnetClient.flush();<br />  charsReceived = 0;<br />  telnetClient.println();<br />  telnetClient.print(devId);<br />  telnetClient.print(&quot;&gt; &quot;);<br />}<br /><br />void checkConnectionTimeout()<br />{<br />  if(millis() - timeOfLastActivity &gt; allowedConnectTime) {<br />    telnetClient.println();<br />    telnetClient.println(&quot;\n*** SESSION TIMED OUT ***\n&quot;);<br />    telnetClient.stop();<br />    connectFlag = 0;<br />  }<br />}<br /><br />void getReceivedText()<br />{<br />  char c;<br />  int charsWaiting;<br /><br />  charsWaiting = telnetClient.available();<br />  do {<br />    c = telnetClient.read();<br />    if(c != 0x0d) {<br />      rcvdCmd += c;<br />      charsReceived++;<br />      charsWaiting--;<br />    }<br />  }<br />  while(charsReceived &lt;= textBuffSize &amp;&amp; c != 0x0d &amp;&amp; charsWaiting &gt; 0);<br />  <br />  if(c == 0x0d) {<br />    parseReceivedText();<br />    showPrompt();<br />  }<br />  <br />  if(charsReceived &gt;= textBuffSize) {<br />    telnetClient.println();<br />    showErrorMessage();<br />    showPrompt();<br />  }<br />}  <br /><br />void parseReceivedText()<br />{<br />  if (rcvdCmd == &quot;help&quot;) {<br />    showHelpMessage();<br />  } else if (rcvdCmd == &quot;show version&quot;) {<br />    telnetClient.print(&quot;\nVersion &quot;);<br />    telnetClient.println(VERSION);<br />    telnetClient.println();<br />  } else if (rcvdCmd == &quot;quit&quot;) {<br />    closeConnection();<br />  } else if (rcvdCmd == &quot;show reading&quot;) {<br />    showReading();<br />  } else if (rcvdCmd == &quot;reset&quot;) {<br />    telnetClient.println(&quot;\n--- Reset in 5 Seconds&quot;);<br />    closeConnection();<br />    delay(5000);<br />    softwareReset();<br />  } else {<br />    showErrorMessage();<br />  }<br />  rcvdCmd = &quot;&quot;;<br />}<br /><br />void showErrorMessage()<br />{<br />  telnetClient.println(&quot;&gt;&gt;&gt; Unrecognized Command&quot;);<br />}<br /><br />void closeConnection()<br />{<br />  telnetClient.println(&quot;\n*** DISCONNECT ***\n&quot;);<br />  telnetClient.stop();<br />  connectFlag = 0;<br />}<br /><br />void showHelpMessage()<br />{<br />  telnetClient.println(&quot;\nSupported commands:\n&quot;);<br />  telnetClient.println(&quot;  reset          Restart the firmware&quot;);<br />  telnetClient.println(&quot;  show reading   Show current temperature/humidity&quot;);<br />  telnetClient.println(&quot;  show version   Show version number&quot;);<br />  telnetClient.println(&quot;  help           Print this help message&quot;);<br />  telnetClient.println(&quot;  quit           Exit telnet session&quot;);<br />  telnetClient.println();<br />}<br /><br />void showReading() {<br />  humid = dht.readHumidity();<br />  tempf = dht.readTemperature(1);<br />  telnetClient.println(&quot;\nCurrent Reading&quot;);<br />  telnetClient.println(&quot;================================&quot;);<br />  telnetClient.print(&quot;Device ID   : &quot;);<br />  telnetClient.println(devId);<br />  telnetClient.print(&quot;Sensor Name : &quot;);<br />  telnetClient.println(sensorName);<br />  telnetClient.print(&quot;Temperature : &quot;);<br />  telnetClient.println(tempf);<br />  telnetClient.print(&quot;Humidity    : &quot;);<br />  telnetClient.println(humid);<br />  telnetClient.println(&quot;================================\n&quot;);<br />}<br /><br />void sendWebPage() {<br />  humid = dht.readHumidity();<br />  tempf = dht.readTemperature(1);<br />  boolean currentLineIsBlank = true;<br />  while (webClient.connected()) {<br />    if (webClient.available()) {<br />      char c = webClient.read();<br />      if (c == &#039;\n&#039; &amp;&amp; currentLineIsBlank) {<br />        webClient.println(&quot;HTTP/1.1 200 OK&quot;);<br />        webClient.println(&quot;Content-Type: text/html&quot;);<br />        webClient.println();<br />        webClient.print(&quot;Device:&quot;);<br />        webClient.print(devId);<br />        webClient.print(&quot;,SensorName:&quot;);<br />        webClient.print(sensorName);<br />        webClient.print(&quot;,Temperature:&quot;);<br />        webClient.print(tempf);<br />        webClient.print(&quot;,Humidity:&quot;);<br />        webClient.println(humid);<br />        break;<br />      }<br />      if (c == &#039;\n&#039;) {<br />        currentLineIsBlank = true;<br />      }<br />      else if (c != &#039;\r&#039;) {<br />        currentLineIsBlank = false;<br />      }<br />    }<br />  }<br />  delay(1);<br />  webClient.stop();<br />}<br /><br />void softwareReset() // Restarts program from beginning but does not reset the peripherals and registers<br />{<br />  asm volatile (&quot;  jmp 0&quot;);  <br />}  <br /><br /></pre>]]></summary>
		<updated>2014-02-25T13:29:07Z</updated>
	</entry>
	<entry>
		<title>Arduino Sketch for DHT11 Temperature Sensor</title>
		<link href="http://joezekistan.com/projects/index.php?entry=entry140126-054721" />
		<link rel="alternate" type="text/html" href="http://joezekistan.com/projects/index.php?entry=entry140126-054721" />
		<link rel="edit" href="http://joezekistan.com/projects/index.php?entry=entry140126-054721" />
		<id>http://joezekistan.com/projects/index.php?entry=entry140126-054721</id>
		<summary type="html"><![CDATA[Hi kids.  So, I have this thing where I like to know exactly how cold it is in the garage before I head out there.  Since I&#039;ve been wanting to play around with the arduino stuff, this seemed like a good project.<br /><br />This code pushes the sensor readings over MQTT, which I can then pick up and incorporate into the various places I want it.  The code is running on an arduino Uno with a wiznet ethernet shield.  I&#039;m running the ethernet through a bridged wifi client until I get some network in the garage.<br /><br />Here&#039;s the sketch:<br /><pre>/*<br /><br />  Environment Monitor<br />  Build for Garage - 1 DHT11 Sensor<br />  2014-01-23<br /><br />*/<br /><br />#include &lt;stdarg.h&gt;<br />#include &lt;SPI.h&gt;<br />#include &lt;Ethernet.h&gt;<br />#include &lt;PubSubClient.h&gt;<br />#include &quot;DHTSensor.h&quot;<br />#include &lt;ICMPPing.h&gt;<br /><br />// Fixed Definitions<br />#define VERSION &quot;1.2-Garage&quot;<br />#define DEVID &quot;F3&quot;<br />#define SENSORNAME &quot;Outdoors&quot;<br />#define CMDQ &quot;net-command&quot;<br />#define DHTTYPE DHT11<br />#define DHTPIN 2<br /><br />// Network config<br />byte mac[]= {0xAA, 0x00, 0x00, 0xE1, 0x00, 0x73};<br />byte ip[]= {192, 168, 100, 73};<br />byte gateway[]= {192, 168, 100, 254};<br />byte subnet[]= {255, 255, 255, 0};<br />byte mqtt_broker[]= {192, 168, 100, 150};<br /><br />// Function declarations<br />String splitString(String s, char parser,int index);<br />void callback(char* topic, byte* payload, unsigned int length);<br /><br />// Instances<br />EthernetClient ethClient;<br />PubSubClient client(mqtt_broker, 1883, callback, ethClient);<br />DHT dht(DHTPIN, DHTTYPE);<br /><br />// sockets<br />SOCKET pingSocket = 3;<br /><br />// State Variables<br />char* commandText = &quot;&quot;;<br />char* deviceId = DEVID;<br />char* cmdTopic = CMDQ;<br />char* sensorName = SENSORNAME;<br />char* sensorTemp = &quot;&quot;;<br />char* sensorRh = &quot;&quot;;<br />int sampleDelay = 30000;<br />long lastSampleTime = 0;<br />char pingBuffer[256];<br />int pingDelay = 10000;<br />long lastPingTime = 0;<br />int netUp = 1;<br /><br />// printf work-around<br />char* p(char *fmt, ... ){<br />  char tmp[128]; // resulting string limited to 128 chars<br />  va_list args;<br />  va_start (args, fmt );<br />  vsnprintf(tmp, 128, fmt, args);<br />  va_end (args);<br />  return tmp;<br />}<br /><br />void softwareReset() // Restarts program from beginning but does not reset the peripherals and registers<br />{<br />  asm volatile (&quot;  jmp 0&quot;);  <br />}<br /><br />void clientConnect() {<br />  if (client.connect(deviceId)) {<br />    commandText = p(&quot;Status:%s:Connected&quot;,deviceId);<br />    client.publish(cmdTopic,commandText);<br />    Serial.println(commandText);<br />    commandText = p(&quot;Status:%s:%i.%i.%i.%i&quot;,deviceId,ip[0],ip[1],ip[2],ip[3]);<br />    client.publish(cmdTopic,commandText);<br />    Serial.println(commandText);<br />    client.subscribe(cmdTopic);<br />    commandText = p(&quot;Status:%s:Subscribed to %s&quot;,deviceId,cmdTopic);<br />    Serial.println(commandText);<br />  } else {<br />    Serial.println(&quot;Connection failed to MQTT&quot;);<br />    netUp = 0;  // Set network down - loop will retry connect<br />  }<br />}<br /><br />// Program setup<br />void setup() {<br />  delay(200);<br />  Ethernet.begin(mac,ip,gateway,subnet);<br />  delay(200);<br />  <br />  dht.begin();<br />  <br />  Serial.begin(9600);<br />  <br />  Serial.println();<br />  Serial.println(&quot;Environment Monitor&quot;);<br />  Serial.println(VERSION);<br />  Serial.println();<br />  <br />  clientConnect();<br />  <br />  Serial.println();<br />}<br /><br />char* deblank(char* input)                                         <br />{<br />    char *output=input;<br />    int k,j;<br />    for (k = 0, j = 0; i&lt;strlen(input); k++,j++)          <br />    {<br />        if (input[k]!=&#039; &#039;)                           <br />            output[j]=input[k];                     <br />        else<br />            j--;                                     <br />    }<br />    output[j]=0;<br />    return output;<br />}<br /><br />// splitString function<br />String splitString(String s, char parser,int index){<br />  String rs=&#039;\0&#039;;<br />  int parserIndex = index;<br />  int parserCnt=0;<br />  int rFromIndex=0, rToIndex=-1;<br /><br />  while(index&gt;=parserCnt){<br />    rFromIndex = rToIndex+1;<br />    rToIndex = s.indexOf(parser,rFromIndex);<br /><br />    if(index == parserCnt){<br />      if(rToIndex == 0 || rToIndex == -1){<br />        return &#039;\0&#039;;<br />      }<br />      return s.substring(rFromIndex,rToIndex);<br />    }<br />    else{<br />      parserCnt++;<br />    }<br />  }<br />  return rs;<br />}<br /><br />void sendHumidity1() {<br />  float hum = dht.readHumidity();<br />  char hum_c[5] = &quot;&quot;;<br />    <br />  dtostrf(hum,5, 1, hum_c);<br />  sensorRh = hum_c;<br />    <br />  commandText = p(&quot;Status:%s:RH=%s&quot;,deviceId,deblank(hum_c));<br />  client.publish(cmdTopic,commandText);<br />  Serial.println(commandText);<br />}<br /><br />void sendTemperature1() {<br />  float tempf = dht.readTemperature(1);<br />  char tempf_c[5] = &quot;&quot;;<br />    <br />  dtostrf(tempf,5, 1, tempf_c);<br />  sensorTemp = tempf_c;<br />    <br />  commandText = p(&quot;Status:%s:Temp=%s&quot;,deviceId,deblank(tempf_c));<br />  client.publish(cmdTopic,commandText);<br />  Serial.println(commandText);<br />}<br /><br />// Callback function<br />void callback(char* topic, byte* payload, unsigned int length) {<br />  //convert byte to char<br />  payload[length] = &#039;\0&#039;;<br />  String strPayload = String((char*)payload);<br />  String strPayloadOrig = strPayload;<br />  strPayload += &quot;:&quot;; // splitString has issues...<br />  String receiveId = splitString(strPayload,&#039;:&#039;,0);<br />  String receiveCmd = splitString(strPayload,&#039;:&#039;,1);<br />  String receiveChn = splitString(strPayload,&#039;:&#039;,2);<br />  <br />  if (strPayloadOrig != commandText) {<br />    if (receiveId == deviceId) {<br />      if (receiveCmd == &quot;REQ&quot;) {<br />          commandText = p(&quot;Status:%s:OK&quot;,deviceId);<br />          client.publish(cmdTopic,commandText);<br />          Serial.println(commandText);<br />      }<br />      if (receiveCmd == &quot;RST&quot;) {<br />        commandText = p(&quot;Status:%s:Reset in 5 seconds&quot;,deviceId);<br />        client.publish(cmdTopic,commandText);<br />        Serial.println(commandText);<br />        delay(5000);<br />        softwareReset();<br />      }<br />      if (receiveCmd == &quot;VER&quot;) {<br />        commandText = p(&quot;Status:%s:%s&quot;,deviceId,VERSION);<br />        client.publish(cmdTopic,commandText);<br />        Serial.println(commandText);<br />      }<br />    }<br />  }<br />}<br /><br />void loop() {<br />  <br />  client.loop();<br />  <br />  if ((millis() - lastPingTime) &gt; pingDelay) {<br />    if ( netUp == 0 ) {<br />      delay(5000);<br />      clientConnect(); // Wait 5 seconds, and re-init client<br />    }<br />    ICMPPing ping(pingSocket);<br />    if (ping(4, mqtt_broker, pingBuffer)) {<br />      netUp = 1;<br />    } else {<br />      Serial.println(&quot;NetFail&quot;);<br />      netUp = 0;<br />    }<br />    lastPingTime = millis();<br />  }<br /><br />  if ((millis() - lastSampleTime) &gt; sampleDelay) {<br />    if ( netUp == 1 ) {<br />      commandText = p(&quot;Status:%s:Name=%s&quot;,deviceId,sensorName);<br />      client.publish(cmdTopic,commandText);<br />      Serial.println(commandText);<br />      sendTemperature1();<br />      sendHumidity1();<br />      lastSampleTime = millis();<br />    }<br />  }<br />}<br /><br /></pre><br /><br />To use it, you&#039;ll need a few libraries.  The DHT sensor library is from Adafruit.  You can read about it <a href="http://learn.adafruit.com/dht" >here</a>.  The MQTT piece uses the PubSubClient library, found <a href="http://knolleary.net/arduino-client-for-mqtt/" >here</a>.  To handle network glitches, it&#039;s using ping to check connectivity, and will reconnect if it can&#039;t find the server.  The ping library is <a href="http://www.blake-foster.com/projects/ICMPPing.zip" >here</a>.  All-in-all, it may not be the most sophisticated sketch, but this one is getting the job done.  Good luck!]]></summary>
		<updated>2014-01-26T12:47:21Z</updated>
	</entry>
</feed>
