Hi
I use particle photon to ground truth a faucet on or off. I record the timestamp when a faucet on and off, then upload to the cloud. After that, I compare this date to other date that collect from the testing devices. I understand that there are some delay and time will not match exactly the same but as long as the gap is constant. However, I found out that time gap between the ground truth date and the date from the test device changing over time. It very between 1s to over 40s. I am new to this. Not sure what I did wrong. Or If anyone have idea how to troubleshoot this.
Summary
void loop ()
{
flow_frequency_0 = 0; //Set NbTops to 0 ready for calculations
interrupts(); //Enables interrupts
delay (300); //Wait 1/2 second
noInterrupts(); //Disable interrupts
if(flow_frequency_0 > 1 )
{
Particle.syncTime(); //sync the time thr wifi
if(lastStatus_0 != OPENED_ONE)
{
delay(100);
flow_frequency_0 = 0; //Set NbTops to 0 ready for calculations
interrupts(); //Enables interrupts
delay (500); //Wait 1/2 second
noInterrupts(); //Disable interrupts
if(flow_frequency_0 > 1)
{
status_ts = Time.now();
itoa(status_ts, buffer_open, 10);
strResult = String::format("{'home_id':'%s','events': [{'e':'o','t':'c','ts':%s}]}"
, pwd_id, buffer_open);
Spark.publish("sendgtdata2", strResult, 60, PRIVATE);
//Serial.println("0 is opened");
flashLed(50, 4);
lastStatus_0 = OPENED_ONE;
Calc_0 = flow_frequency_0;
}
}
else {Calc_0 += flow_frequency_0;}
}
else
{
if(lastStatus_0 != CLOSED_ONE)
{
delay(100);
flow_frequency_0 = 0; //Set NbTops to 0 ready for calculations
interrupts(); //Enables interrupts
delay (200); //Wait 1/2 second
noInterrupts(); //Disable interrupts
if(flow_frequency_0 == 0)
{
status_ts = Time.now();
itoa(status_ts, buffer_open, 10);
strResult = String::format("{'home_id':'%s','events': [{'e':'c','t':'c','ts':%s,'f':%d}]}"
, pwd_id, buffer_open, Calc_0);
Spark.publish("sendgtdata2", strResult, 60, PRIVATE);
//Serial.println("0 is closed");
flashLed(50, 4);
lastStatus_0 = CLOSED_ONE;
Calc_0 = 0;
}
}
}
}