<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can&#x27;t tell if time is set with TimeAwareSensor Sketch]]></title><description><![CDATA[<p dir="auto">I am running the TimeAwareSensor.ino sketch and I can't tell if the time ever gets set.  I added a couple of serial print lines to the receiveTime function and they never get logged to my serial monitor.  Also, timeReceived never gets set to true.</p>
<pre><code>// Example sketch showing how to request time from controller.
// Created by Henrik Ekblad &lt;henrik.ekblad@mysensors.org&gt;

#include &lt;SPI.h&gt;
#include &lt;MySensor.h&gt; 
#include &lt;Time.h&gt; 

MySensor gw;
boolean timeReceived = false;
unsigned long lastUpdate=0, lastRequest=0;

void setup() 
{ 
  gw.begin();
  // Send the sketch version information to the gateway and Controller
  gw.sendSketchInfo("Clock", "1.0");
  // Request time from controller.
  gw.requestTime(receiveTime); 
}

// This is called when a new time value was received
void receiveTime(unsigned long time) {
  // Ok, set incoming time
  Serial.print("Got Time");
  Serial.println(time);
  setTime(time);
  timeReceived = true;
}
 
void loop()    
{    
  unsigned long now = millis();
  gw.process();
 
   // If no time has been received yet, request it every 10 second from controller
  // When time has been received, request update every hour
  if ((!timeReceived &amp;&amp; now-lastRequest &gt; 20*100)
    || (timeReceived &amp;&amp; now-lastRequest &gt; 60*1000*60)) {
    // Request time from controller.
    Serial.println("requesting time");
    gw.requestTime(receiveTime); 
    lastRequest = now;
  }
 
  // Print time every second
  if (timeReceived &amp;&amp; now-lastUpdate &gt; 1000) {
    Serial.print(hour());
    printDigits(minute());
    printDigits(second());
    Serial.print(" ");
    Serial.print(day());
    Serial.print(" ");
    Serial.print(month());
    Serial.print(" ");
    Serial.print(year());
    Serial.println();
    lastUpdate = now;
  }
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits &lt; 10)
    Serial.print('0');
  Serial.print(digits);
}
</code></pre>
<p dir="auto">Here is the serial monitor output.</p>
<pre><code>sensor started, id 5
send: 5-5-0-0 s=255,c=0,t=17,pt=0,l=3,st=ok:1.4
send: 5-5-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
read: 0-0-5 s=255,c=3,t=6,pt=0,l=1:I
send: 5-5-0-0 s=255,c=3,t=11,pt=0,l=5,st=ok:Clock
send: 5-5-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 5-5-0-0 s=255,c=3,t=1,pt=0,l=3,st=ok:1.0
requesting time
send: 5-5-0-0 s=255,c=3,t=1,pt=0,l=3,st=ok:1.0
read: 0-0-5 s=255,c=3,t=4,pt=0,l=10:1411246677
requesting time
send: 5-5-0-0 s=255,c=3,t=1,pt=0,l=10,st=ok:1411246677
read: 0-0-5 s=255,c=3,t=4,pt=0,l=10:1411246679
requesting time
send: 5-5-0-0 s=255,c=3,t=1,pt=0,l=10,st=ok:1411246679
read: 0-0-5 s=255,c=3,t=4,pt=0,l=10:1411246681
</code></pre>
<p dir="auto">It seems like the sensor starts sending the time back to the controller but timeReceived never gets set to true so the current time is not printed to the serial monitor every second.  Any suggestions?</p>
]]></description><link>https://forum.mysensors.org/topic/405/can-t-tell-if-time-is-set-with-timeawaresensor-sketch</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 04:00:56 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/405.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Sep 2014 21:07:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can&#x27;t tell if time is set with TimeAwareSensor Sketch on Sun, 21 Dec 2014 14:23:11 GMT]]></title><description><![CDATA[<p dir="auto">I have the same problem. Work goes through a repeater. Everything works, other than time.</p>
<ul>
<li>Setup:<br />
sensor started, id=4, parent=0, distance=1<br />
send: 4-4-0-0 s=255,c=0,t=17,pt=0,l=5,st=fail:1.4.1<br />
send: 4-4-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0<br />
read: 0-0-4 s=255,c=3,t=6,pt=0,l=1:M<br />
send: 4-4-0-0 s=255,c=3,t=11,pt=0,l=18,st=fail:Temperature Sensor<br />
send: 4-4-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0<br />
send: 4-4-0-0 s=0,c=0,t=6,pt=0,l=5,st=fail:1.4.1<br />
lost parent<br />
find parent<br />
send: 4-4-255-255 s=255,c=3,t=7,pt=0,l=0,st=bc:<br />
read: 3-3-4 s=255,c=3,t=8,pt=1,l=1:1<br />
new parent=3, d=2<br />
read: 0-0-4 s=255,c=3,t=8,pt=1,l=1:0<br />
new parent=0, d=1<br />
send: 0-4-0-4 s=255,c=3,t=8,pt=1,l=1,st=fail:0<br />
send: 4-4-0-0 s=2,c=0,t=8,pt=0,l=5,st=fail:1.4.1<br />
send: 4-4-0-0 s=3,c=0,t=3,pt=0,l=5,st=fail:1.4.1<br />
send: 4-4-0-0 s=4,c=0,t=1,pt=0,l=5,st=fail:1.4.1<br />
gw.getStatus CHILD_ID_VIRT_Relay: 1<br />
send: 4-4-0-0 s=255,c=3,t=1,pt=0,l=5,st=fail:1.4.1<br />
lost parent<br />
read: 0-0-4 s=255,c=3,t=8,pt=1,l=1:0<br />
new parent=0, d=1<br />
requestTemperatures:<br />
requestTemperatures done:<br />
temperature done: 13.70<br />
temperature: 13.70<br />
send: 4-4-0-0 s=0,c=1,t=0,pt=7,l=5,st=fail:13.7<br />
send: 4-4-0-0 s=2,c=1,t=4,pt=7,l=5,st=fail:279<br />
send: 4-4-0-0 s=255,c=3,t=1,pt=1,l=1,st=fail:0<br />
gw.requestTime:0</li>
</ul>
]]></description><link>https://forum.mysensors.org/post/8030</link><guid isPermaLink="true">https://forum.mysensors.org/post/8030</guid><dc:creator><![CDATA[Daemon D]]></dc:creator><pubDate>Sun, 21 Dec 2014 14:23:11 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t tell if time is set with TimeAwareSensor Sketch on Sat, 20 Sep 2014 22:09:24 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, changing type from 4 to 1 fixed it.</p>
]]></description><link>https://forum.mysensors.org/post/4816</link><guid isPermaLink="true">https://forum.mysensors.org/post/4816</guid><dc:creator><![CDATA[mikeones]]></dc:creator><pubDate>Sat, 20 Sep 2014 22:09:24 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t tell if time is set with TimeAwareSensor Sketch on Sat, 20 Sep 2014 21:33:22 GMT]]></title><description><![CDATA[<p dir="auto">Looks like this when I run the sketch:</p>
<pre><code>requesting time
send: 5-5-0-0 s=255,c=3,t=1,pt=0,l=1,st=ok:5
read: 0-0-5 s=255,c=3,t=1,pt=0,l=10:1411255184
23:19:44 20 9 2014
23:19:44 20 9 2014
23:19:45 20 9 2014
23:19:46 20 9 2014
</code></pre>
<p dir="auto">There are some subtle differences. Why is your sensor sending in "1.0" as payload when requesting time? Looks wrong.<br />
Received package has t=4 on your side. That is not a time response (should be t=1). What type of controller are you running?</p>
]]></description><link>https://forum.mysensors.org/post/4815</link><guid isPermaLink="true">https://forum.mysensors.org/post/4815</guid><dc:creator><![CDATA[hek]]></dc:creator><pubDate>Sat, 20 Sep 2014 21:33:22 GMT</pubDate></item></channel></rss>